• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Graph representation

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean the class structure... and realisation of the link between nodes - (class structure too)...
Thanks,
Oleg
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Oleg Korsakov
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My big thanks to Mr. Stan and yes I'll show it here later (in this topic)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic