Graph Terminologies Department of CE/IT M.S.P.V.L.Polytechnic College,
-
Upload
emily-stewart -
Category
Documents
-
view
231 -
download
0
description
Transcript of Graph Terminologies Department of CE/IT M.S.P.V.L.Polytechnic College,
Graph Terminologies
Department of CE/ITM.S.P.V.L.Polytechnic College,
Pavoorchatram.
Graph definitions There are two kinds of graphs: directed graphs
(sometimes called digraphs) and undirected graphs
Birmingham Rugby
LondonCambridge
Bristol
Southhampton
Dover
60
140190
190
150100
120
110
An undirected graph
start
fill panwith water
take eggfrom fridge
break egginto pan
boilwater
add saltto water
A directed graph
www.ustudy.in
Graph terminology I A graph is a collection of nodes (or vertices, singular is
vertex) and edges (or arcs) Each node contains an element Each edge connects two nodes together (or possibly the same node
to itself) and may contain an edge attribute A directed graph is one in which the edges have a direction An undirected graph is one in which the edges do not have
a direction Note: Whether a graph is directed or undirected is a logical
distinction—it describes how we think about the graph Depending on the implementation, we may or may not be able to
follow a directed edge in the “backwards” direction
www.ustudy.in
Graph Terminology A graph G = (V, E)
V = set of vertices E = set of edges
In an undirected graph: edge(u, v) = edge(v, u)
In a directed graph: edge(u,v) goes from vertex u to vertex v, notated u v edge(u, v) is not the same as edge(v, u)
www.ustudy.in
Graph Terminologies
Directed graph:
V = {A, B, C, D}E = {(A,B), (A,C), (A,D), (C,B)}
A
C
D
B
Undirected graph:
V = {A, B, C, D}E = {(A,B), (A,C), (A,D), (C,B), (B,A), (C,A), (D,A), (B,C)}
A
C
D
B
www.ustudy.in
Graph Terminology Adjacent vertices: connected by an edge
Vertex v is adjacent to u if and only if (u, v) E. In an undirected graph with edge (u, v), and hence (v,
u), v is adjacent to u and u is adjacent to v.
a b
d e
c
a b
d e
c
Vertex a is adjacent to c andvertex c is adjacent to a
Vertex c is adjacent to a, butvertex a is NOT adjacent to c
www.ustudy.in
A Path in a graph from u to v is a sequence of edges between vertices w0, w1, …, wk, such that (wi, wi+1) E, u = w0 and v = wk, for 0 i k The length of the path is k, the number of edges on the
path
a b
d e
c
a b
d e
c
abedce is a path.cdeb is a path.bca is NOT a path.
acde is a path.abec is NOT a path.
Graph Terminology
www.ustudy.in
Loops If the graph contains an edge (v, v) from a vertex to itself, then
the path v, v is sometimes referred to as a loop.
The graphs we will consider will generally be loopless.
A simple path is a path such that all vertices are distinct, except that the first and last could be the same.
a b
d e
c abedc is a simple path.cdec is a simple path.abedce is NOT a simple path.
a b
d e
c
Graph Terminology
www.ustudy.in
Graph Terminology simple path: no repeated vertices
www.ustudy.in
Cycles A cycle in a directed graph is a path of length at least 2 such
that the first vertex on the path is the same as the last one; if the path is simple, then the cycle is a simple cycle.
A cycle in a undirected graph A path of length at least 3 such that the first vertex on the path is the
same as the last one. The edges on the path are distinct.
abeda is a simple cycle.abeceda is a cycle, but is NOT a simple cycle.abedc is NOT a cycle.
a b
d e
c
a b
d e
c
aba is NOT a cycle.abedceda is NOT a cycle.abedcea is a cycle, but NOT simple.abea is a simple cycle.
Graph Terminology
www.ustudy.in
Graph Terminology If each edge in the graph carries a value, then the graph is
called weighted graph. A weighted graph is a graph G = (V, E, W), where each
edge, e E is assigned a real valued weight, W(e). A complete graph is a graph with an edge between every
pair of vertices. A graph is called complete graph if every vertex is
adjacent to every other vertex.
Graph Terminology Complete Undirected Graph
has all possible edges
n = 1 n = 2 n = 3 n = 4
www.ustudy.in
Graph Terminology connected graph: any two
vertices are connected by some path An undirected graph is
connected if, for every pair of vertices u and v there is a path from u to v.
Graph Terminology tree - connected graph without cycles
forest - collection of trees
www.ustudy.in
Graph Terminology
www.ustudy.in
End vertices (or endpoints) of an edge a U and V are the endpoints of a
Edges incident on a vertex V a, d, and b are incident on V
Adjacent vertices U and V are adjacent
Degree of a vertex X X has degree 5
Parallel edges h and i are parallel edges
Self-loop j is a self-loop
XU
V
W
Z
Y
a
c
b
ed
fg
h
i
j
Graph Terminology
www.ustudy.in
P1
Path sequence of alternating vertices
and edges begins with a vertex ends with a vertex
Simple path path such that all its vertices and
edges are distinct. Examples
P1 = (V, X, Z) is a simple path. P2 = (U, W, X, Y, W, V) is a path
that is not simple.
XU
V
W
Z
Y
a
c
b
e
d
fg
hP2
Graph Terminology
www.ustudy.in
Cycle circular sequence of alternating
vertices and edges
Simple cycle cycle such that all its vertices and
edges are distinct
Examples C1 = (V, X, Y, W, U, V) is a
simple cycle C2 = (U, W, X, Y, W, V, U) is a
cycle that is not simple
C1
XU
V
W
Z
Y
a
c
b
e
d
fg
hC2
Graph Terminology
www.ustudy.in
19
Graph Terminology Wheels
They are denoted by Wn; they are obtained by adding a vertex to the graphs Cn and connect this vertex to all vertices
www.ustudy.in
20
Graph Terminology
W3 W4
W5W6
The Wheels W3,W4, W5 & W6
www.ustudy.in
In-Degree of a Vertex in-degree is number of incoming edges
indegree(2) = 1, indegree(8) = 0
23
8101
45 9 11
67
www.ustudy.in
Out-Degree of a Vertex out-degree is number of outbound edges
outdegree(2) = 1, outdegree(8) = 2
23
8101
45 9 11
67
www.ustudy.in
The End
Thank U
Ilakkiya.Vwww.ustudy.in