Graph vs. Tree

The difference between graph and tree Graph and tree are used in structuring data. Graph and tree definitely…

The difference between graph and tree

Graph and tree are used in structuring data. Graph and tree definitely has some differences between them. A binary relation of a set of vertices is called as a graph while on the other hand a data structure which contains a set of joints or connections linked to it is called as a tree.


Edges connecting a set of items where each item is called as node or vertex is said to be as graph. Instead, a graph can be well said as the set of vertices which have a binary relation among the vertices.

The nodes are implemented as objects or structures while implementation of graph. There are many ways to symbolize the edges. Each joint can be connected with an incident array in a way. The array acts as pointers to nodes representing the edges when the information is stored in the nodes in lieu of the edges. The advantage of this is that another more nodes can be added to the graph. The subsisting nodes can be linked by adding elements to the rays. But it takes more time to decide whether there are edges in between the nodes.

The other method to do this is by keeping a two dimensional array that has Boolean values. The entry Mij specifies the existence of edge from node i to j whereas it can be found out whether there is any edge between the nodes which is an advantage.


Computer science uses tree as a data structure. It is same as the formation of a tree and contains set of nodes linked to each other.

Every node of a tree may contain value or condition. The node represents either its own value or the value of a different data structure. In a tree data structure there are zero or more nodes. Moreover, there are even child for nodes. The node having child is called as parent nodes. At the most there is one parent of a node. The height of a node is the longest downward path from node to leaf.  The path of its roots decides the depth of node.

The uppermost node in the tree is called as the root node. There is no parent for the root node as it is the top most part in the tree. All the operations of the tree begin from the root node.

The links or edges can be used from the root node to reach other required nodes. The bottom-most level nodes are said to be as leaf nodes. Leaf nodes can’t have children as they are the lower-most node. A node is called inner node or internal node, if it has a ore numbers of children.

Difference between graph and tree Summary:

  • A tree is a specialized case of graph which doesn’t have self loops and circuits.
  • Tree cannot have loops but graph can have loops.
  • Edges, vertices and set that represents their relation are thee three sets in a graph whereas nodes are connected to each other in a tree. The links between the nodes are said as tree.
Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Calories vs. Fat Calories

Difference Between Calories and Fat Calories Fat calorie and calorie are unrelated although their names appear similar. People…

Yorkie Vs. Silky

Difference Between Yorkie And Silky When it comes to comparing races the difference between a Yorkie and Silky…

Behavior vs. Habit

Difference Between Behavior and Habit Both behavior and habit are both used to describe a person’s character or…

H1 Vs. L1 Visa

H1 and L1 Visa Certain instances occur wherein businesses operating in the US would have to bring in…