Sunday, 15 May 2011

Nonlinear data structures tree vs graph



Tree - is a hierarchical data structure of nodes.
Nodes are usually structured in the parent-child manner. However line joining two nodes has no significance.



Graph - similar to the tress except that line joining the nodes is also important (generally known as edge). In graph a edge could represent anything (time, distance etc possibilities are endless).  i.e. In a train map line may represent the distance or time.

In plain words a scaled train map in the example of graph whereas same train map without scaling is the example of a tree.



Moreover edges are broadly categorized in the two categories as follows:
            1) Bi-directional graph, i.e. edges is bidirectional.
            2) Unidirectional graph, ugh just opposite to bi-directional.
 

2 comments:

  1. Nice! Maybe you could have added how the graph images themselves were created

    ReplyDelete
  2. An edge in a directed graph ideally should be shown with only a single arrow head. To represent the 2-way (A to B and B to A), you must ideally add 2 separate directed edges - one pointing in each direction.

    ReplyDelete

Total Pageviews

Popular Posts