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

**Graph**

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.

**Tree**

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.