Graph Representation
Graph Representation
What is Graph ?
A graph G consists of a finite set of ordered pairs, called edges E, of certain entities called vertices V. Edges are also called as arcs or links. Vertices are also called as nodes or points.
G=(V,E)
A graph is a set of vertices and edges. A vertex may represent a state or a condition while the edge may represent a relation between two vertices.
Types of Representation
Two ways are there for representing graph in the memory of a computer. They are: Sequential Representation Linked Representation
Sequential Representation
Graphs can be represented through matrix in systems memory. This is sequential in nature. This type of representation is called sequential representation of graphs.
Linked Representation
Graphs can be represented through Linked List in systems memory. This is Linked in nature. This type of representation is called Linked representation of graphs.
Examples
Examples
e1 e2 e3 e4
1 2 3 4
Examples
Examples
Examples
Example
In Computers
Even there are many mathematical representations adjacency matrix and adjacency lists are only used for representing graphs in computers.
Dense Graph
Sparse Graph
Conclusion
Adjacency matrix is good for dense graphs. Adjacency lists is good for sparse graphs and also for changing the no of nodes.
Thank You!