4. What is a Graph?
A graph is a structure that consists of a set of nodes
(vertices) and a set of edges that relate the nodes to each
other.
A graph G is defined as follows:
G=(V,E)
V: set of vertices
E: set of edges connecting the vertices in
V
6. Types of Graphs:
Though there are a lot of different types of graphs in
data structure. There are some common graphs given
below:
Bipartite Graph:
Complete Graph:
Cycle Graph:
11. Connected & Disconnected graph:
A graph is connected when there is a path between
every pair of vertices. In a connected graph, there
are no unreachable vertices. A graph that is not
connected is disconnected.
A B
12. Undirected Graph:
Which graph has no specific direction between the
vertices is called undirected graph.
• Edge (u,v) = edge (v,u)
• No self-loops
We uses undirected edges as to represent symmetrical
relationship.
→Two way streets
→Network traffic
→Mazes
13. Directed Graph:
A directed graph has edges that are “One way”. We
can go from one vertices to another, but not vice
versa.
Edge (u,v) goes from vertex u to vertex v, notated
u→v
14. Weighted Graph:
A weighted graph has weights associated with each
edge. The weight can represent distance, cost etc.
→A road map.
15. Multigraph:
A multigraph is a directed graph which is permitted to
have multiple edges, e.g. edges with the own, source
and target vertices.
17. Following representations:
• Two are most popular computer representations of a
graph.
• 1: Adjacency Matrix
• 2: Adjacency List
• But it has one other representation:
• 3: Incidence Matrix