You can't really have pointers to data with protobuf, only actual
data. You might do something like

message Node {
  optional string name;
  repeated string neighbor;
}

message Graph {
  repeated string names;
  repeated Node nodes;
}

And use the name (or some other unique identifier) to figure out which
Node a particular neighbor is.


On Thu, Jul 4, 2013 at 6:18 AM, Agnel Kurian <agnel.kur...@gmail.com> wrote:
> I have a struct representing a node in a graph. All instances of this struct
> store a list of references/pointers to their immediate neighbors in the
> graph. The following is what the struct looks like in C++:
>
> struct Node {
>   string name;
>   vector<Node*> neighbors;
>
>   //  ...
> };
>
> Suppose I have 4 nodes marking the corners of a square, each node would hold
> pointers to two neighbors. How do I represent the above struct as a protocol
> buffer message?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at http://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to