Before going to discuss further details about Graphlib module, let us discuss about graphs briefly.
GRAPHS
Definition: Graph is a non-linear datastructure consists of a finite set of
vertices(or nodes) and a set of edges which connect a pair of nodes.
G=(V,E) V=vertices, E=edges.
why we need Graphs?
Graphs are used to solve many real-life problems.some of the few
examples are given below.
1)To calculate the shortest path between source and destination
example : Google maps uses graphs for building transportation
systems, where intersection of two(or more) roads are considered to be a vertex and the road connecting two vertices is considered to be an edge, thus their navigation system is based on the algorithm to calculate the shortest path between two vertices.
2)Graphs are used to define the flow of computation.
3)Graphs are used to represent networks of communication.
4)Graphs are used torepresent data organisation.
GRAPH REPRESNTATION
Using Adjacency matrix: An adjacency matrix is a square matrix of size
N*N, where N is number of vertices in the graph.Elements of the
matrix indicate whether pairs of adjacent or not in the graph
Comments