You are on page 1of 9

Graph and Tree

Graph Theory
The graph is a collection of circles,
called nodes or vertices, which are
linked by a series of lines called edges.
The analysis of graphics or graph
theory is an important aspect of a
variety of studies in the fields of
mathematics , engineering and
computer science.
Tree
A tree is a finite set of one or more nodes, such
as –

There's a specially named node called base.


The remaining nodes are partitioned to n>=0
disjoint sets T1 , T2, T3, ..., Tn
Where T1, T2, T3, ..., Tn is considered root
subtrees.
Graph vs Tree
GRAPH TREE

Graph is a non-linear data structure. Tree is a non-linear data structure.

It is a collection of vertices/nodes and It is a collection of nodes and edges.


edges.

Each node can have any number of edges. General trees consist of the nodes having
any number of child nodes. But in case of
binary trees every node can have at the
most two child nodes.

There is no unique node called root in There is a unique node called root in trees.
graph.

A cycle can be formed. There will not be any cycle.

Applications: For finding shortest path in Applications: For game trees, decision
networking graph is used. trees, the tree is used.

You might also like