GRAPH
A graph G consists of a set of V vertices and a set of E edges.
Tree – A graph is a tree if it has two properties:
- It is connected
- There are no cycles in the graph
Graph representation
Commonly used representations are:
- 1. Adjacency matrix
Aij = 1 ; if edge (Vi,Vj) is in Eg
0 ; otherwise
=> It takes O(n2) space to represent a graph with n vertices
=> It takes O(n2) time to solve most of graph problem
- 2. Adjacency list representation
We store graph as a linked list
- 3. Multi-list representation
In it there are two parts, a directory of node information and a set of linked list of edge information.
Graph Traversal


