Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Unit 3 - Session 4

Directed graphs and shortest paths


𝑣3
𝑒3 𝑒4

𝑣1 𝑒2
𝑒1 𝑣2
C. P. S. Pathirana.
Senior Lecturer
Department of Mathematics & Philosophy of Engineering.
The Open University of Sri Lanka.
Definition 4.1

A directed graph (or a digraph) is an ordered pair


𝐺 = (𝑉, 𝐸) where 𝑉 is a non empty finite set
whose elements are vertices of 𝐺 and 𝐸 is a
collection of ordered pairs of 𝑉 and it is called
the set of all edges of 𝐺.

The Open University of Sri Lanka 8/6/2022 2


Example
Consider the graph 𝐺(𝑉, 𝐸) where,
𝑉 = 𝑣1 , 𝑣2 , 𝑣3 , 𝑣4 , 𝑣5 and
𝐸 = { 𝑣1 , 𝑣2 , 𝑣1 , 𝑣3 , 𝑣1 , 𝑣4 , 𝑣3 , 𝑣2 , 𝑣4 , 𝑣2 ,
𝑣3 , 𝑣5 , (𝑣4 , 𝑣5 )}
𝑣3

𝑣1 𝑣2 𝑣5

𝑣4
The Open University of Sri Lanka 8/6/2022 3
11.2 Matrix representation

• We know adjacency matrix only counts the number


of edges.

• So it is same for both undirected and directed


graphs.

• But the incidence matrix are different.

The Open University of Sri Lanka 8/6/2022 4


Definition 4.2

Let 𝐺 be a diagraph (or multi graph), 𝑉 𝐺 =


{𝑣1 , ⋯ , 𝑣𝑛 } and 𝐸 𝐺 = 𝑒1 , ⋯ , 𝑒𝑚 . Then the
incidence matrix 𝐼(𝐺) of 𝐺 is an 𝑛 × 𝑚 matrix and
𝐼 𝐺 = (𝑎𝑖𝑗 ) where,

1 ; 𝑒𝑗 𝑖𝑠 𝑖𝑛𝑐𝑖𝑑𝑒𝑛𝑡 𝑜𝑢𝑡 𝑜𝑓 𝑣𝑖
−1 ; 𝑒𝑗 𝑖𝑠 𝑖𝑛𝑐𝑖𝑑𝑒𝑛𝑡 𝑖𝑛𝑡𝑜 𝑣𝑖
𝑎𝑖𝑗 =
0 ; 𝑒𝑗 𝑖𝑠 𝑛𝑒𝑖𝑡ℎ𝑒𝑟 𝑖𝑛𝑐𝑖𝑑𝑒𝑛𝑡 𝑜𝑢𝑡 𝑛𝑜𝑟 𝑖𝑛𝑡𝑜 𝑣𝑖
2 ; 𝑣𝑖 𝑖𝑠 𝑎𝑑𝑗𝑎𝑐𝑒𝑛𝑡 𝑡𝑜 𝑖𝑡𝑠𝑒𝑙𝑓 𝑏𝑦 𝑒𝑗

The Open University of Sri Lanka 8/6/2022 5


Example
Let 𝐺 be a multi-graph. Draw a diagram of 𝐺, if
𝑒1 𝑒2 𝑒3 𝑒4
𝑣1 −1 0 1 0
𝐼 𝐺 = 𝑣2 1 2 0 −1
𝑣3 0 0 −1 1

𝑣3
𝑒3 𝑒4

𝑣1 𝑒2
𝑒1 𝑣2
The Open University of Sri Lanka 8/6/2022 6
11.3 In-degree and Out-degree
Definition 4.3
Let 𝐺 be a digraph (or a multi-digraph) and
𝑣∈𝑉 𝐺 .
• The number of edges (arcs) incident out of 𝑣
is called the out-degree of 𝒗 and it is
denoted by 𝐝𝐞𝐠 + (𝒗).
• The number of edges (arcs) incident into 𝑣 is
called the in-degree and it is denoted by
𝐝𝐞𝐠 − (𝒗)
Then total degree,
𝐝𝐞𝐠 𝒗 = 𝐝𝐞𝐠 + 𝒗 + 𝐝𝐞𝐠 − (𝒗)
8/6/2022 7
The Open University of Sri Lanka
Example

Consider the previous example.

𝑣3
𝑒3 𝑒4

𝑣1 𝑒2
𝑒1 𝑣2

deg 𝑣1 = deg + 𝑣1 + deg − 𝑣1 = 1 + 1 = 2


deg 𝑣2 = deg + 𝑣2 + deg − 𝑣2 = 2 + 2 = 4
deg 𝑣3 = deg + 𝑣3 + deg − 𝑣3 = 1 + 1 = 2
The Open University of Sri Lanka 8/6/2022 8
Theorem 4.1 : (Handshaking Lemma)

Let 𝐺 be a digraph (or a multi digraph).


Then,

σ𝑣∈𝑉(𝐺) deg + (𝑣) = σ𝑣∈𝑉(𝐺) deg − 𝑣 = |𝐸 𝐺 |

➢ That is in the graph 𝐺,

In-degree = out-degree = Number of


sum sum edges
The Open University of Sri Lanka 8/6/2022 9
Example
Consider the previous example.

𝑣3
𝑒3 𝑒4

𝑣1 𝑒2
𝑒1 𝑣2
σ𝑣∈𝑉(𝐺) deg + 𝑣 = 1 + 2 + 1 = 4
σ𝑣∈𝑉(𝐺) deg − 𝑣 = 1 + 2 + 1 = 4

So the number of edges in the graph is 4.


The Open University of Sri Lanka 8/6/2022 10
11.4 Shortest path

• Shortest path is the path between two vertices


with a minimum number of edges.

• Let 𝐺 be a graph. If 𝐺 is an undirected , un


weighted graph then for each vertices 𝑢 and 𝑣,
the length of the shortest path between 𝑢 and 𝑣
is 𝑑𝑖𝑠𝑡 𝑢, 𝑣 .

The Open University of Sri Lanka 8/6/2022 11


Example

Find the shortest path between 𝑣1 and 𝑣7 .


𝑣3 𝑣6 𝑣7
𝑣4 𝑣5
𝑣1 𝑣8

𝑣2 𝑣9
𝑣1 , 𝑣4 , 𝑣5 , 𝑣6 , 𝑣7 is the shortest path between 𝑣1
and 𝑣7 .
𝑑𝑖𝑠𝑡 𝑣1 , 𝑣7 = 4.
The Open University of Sri Lanka 8/6/2022 12
Thank You

You might also like