aspose file tools*
The moose likes Beginning Java and the fly likes Graph representation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Graph representation" Watch "Graph representation" New topic
Author

Graph representation

Oleg Korsakov
Greenhorn

Joined: Jan 14, 2007
Posts: 14
Hello!
Very needed help....)

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...

Thanks,
Oleg.
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Did you mean showing it on a User interface..??

or are you asking how to represent a node in a class structure??
Oleg Korsakov
Greenhorn

Joined: Jan 14, 2007
Posts: 14
I mean the class structure... and realisation of the link between nodes - (class structure too)...
Thanks,
Oleg
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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
My big thanks to Mr. Stan and yes I'll show it here later (in this topic)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Graph representation