bidirectional graph implementation

Hi.

What is the best way to represent bidirectional graph of objects?

For example, I need a reference from A->B->C and also C->B->A.

How can I search a object in such of graph? I need the serach to be as simple as possible.

Is it better to represent it as to maps, like:

Map1:

A ->B

B-> C

Map2:

C->B

B->A

Please advise.

Thanks in advanced.

[442 byte] By [nonusha] at [2007-10-2 17:02:14]
# 1
Your example does only show what I would call a double linked list.Can an object in the graph have multiple references, and can multiple references point to an object?Kaj
kajbja at 2007-7-13 18:16:10 > top of Java-index,Java Essentials,Java Programming...
# 2
Multiple references are enabled.
nonusha at 2007-7-13 18:16:10 > top of Java-index,Java Essentials,Java Programming...
# 3
I would probably create a node class which has two sets as attributes. One set is "previous", and the other set is "next".Kaj
kajbja at 2007-7-13 18:16:10 > top of Java-index,Java Essentials,Java Programming...
# 4
(The sets can of course be changed to lists or maps if you need to)
kajbja at 2007-7-13 18:16:10 > top of Java-index,Java Essentials,Java Programming...
# 5
Google for "adjacency matrix" and "adjacency list". These are the two main ways of representing a graph.
YAT_Archivista at 2007-7-13 18:16:10 > top of Java-index,Java Essentials,Java Programming...