Unit 3 Lecture 1
Unit 3 Lecture 1
Graph
Lecture No.-3.1 DISCOVER . LEARN .
EMPOWER
Index
• Concept of graph
• Graph Terminology
• Adjacency Matrix
• Path matrix
2 2
Graph definition
Graph:-Graph is an ordered set G (V, E), where V is
the nonempty set of vertices and E is the set of
edges, connecting the pairs of vertices. A Graph is
a non-linear data structure. A Graph G(V, E) with 7
vertices (A, B, C, D, E,F,G) and six edges ((A,B), (B,E),
(E,G), (A,C), (D,F), (A,D)) is shown in the following
figure.
Directed and Undirected
Graph
• In a directed graph, edges form an ordered pair.
Edges represent a specific path from some vertex A
to another vertex B. C
A B
• In an undirected graph, edges are not associated
with the directions with them. An undirected graph
is shown in the above figure since its edges are not
attached with any of the directions. If an edge
exists between vertex A and B then the vertices can
be traversed from B to A as well as A to B.
C
A
B
Graph Terminology
• Adjacency − Two node or vertices are adjacent if
they are directly connected to each other through
an edge. In the following example, B is adjacent to
A, E is adjacent to B, and so on. C is not adjacent to
B.
• Path − Path represents a sequence of edges
between the two vertices. In the following example,
ABEG represents a path from A to G.
Continue..
• Closed Path: A path will be called as closed path if
the initial node is same as terminal node. A path
will be closed path if V0=VN.
• Cycle: A cycle can be defined as the path which has
no repeated edges or vertices except the first and
last vertices.
• Connected Graph:A connected graph is the one in
which some path exists between every two vertices
(u, v) in V. There are no isolated nodes in connected
graph.
Continue..
• Complete Graph: In complete graph every node is
A
connected with all other nodes.
B C
• Weighted Graph:In a weighted graph, each edge is
assigned with some data such as length or weight.
The weight of an edge e can be given as w(e) which
must be a positive (+) value indicating the cost of
traversing the edge. A
3 2
B C
2
Continue..
• Loop: In graph theory, a loop (also called a self-
loop or a buckle) is an edge that connects a vertex
to itself. A simple graph contains no loops.
A B
17