Hi what will the best possible way to represent a graph in XML, where a node can be the child of a parent node and may be the parent of another child node. It can refer to itself, and multiple nodes can have same parent. And a node can have multiple parents.
All nodes are from same class. I want to build it efficiently, so that if I can learn about a child node from a parent node I can go to the specific child tag without having to iterate all the nodes. Is it possible?
for example here is an overview,
A->B,C,D
B->C,D
it may look like
<Node name=A>
<childNode name=B>
<childNode name=C>
<childNode name=D>
</Node>
<Node name=B>
<childNode name=C>
<childNode name=D>
</Node>
So are there any better approaches than this? Whenever I get a child from A i.e. B, than I will have to basically iterate through all Nodes and match there name attribute with B to find the Node that represents B. Can I somehow do it faster?
Since you have a graph, and not a tree as you first thought, why not use GraphML?