I have to represent a graph. It has nodes connected with arrows from the top node towards the lower ones. How can I using java language to model this graph. Which class should be used for the node and how to represent the arrows between nodes also. Node can have two downward arrows... How to describe this...

In structures like this each node has pointers to other nodes. The "leaf" nodes at the end have empty or null pointers.

For a singly linked list, each node has one pointer to the next node.

For a doubly linked list, each node has one pointer to the next node, and a pointer back to the prior.

For a binary tree, each node has pointers to two children.

It sounds like your tree might have more than two children, so a collection could be in order.

The existance and direction of the arrow is implied ... the Node with the collection is the plain end of the line, the Nodes in the collection have the arrow end.

Does that work for you? Show us what you make!

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi

Oleg Korsakov
Greenhorn

Joined: Jan 14, 2007
Posts: 14

posted

0

My big thanks to Mr. Stan and yes I'll show it here later (in this topic)