Graph theory

Jeane Paguio
Jeane PaguioElectronics and Communications Engineering Society
Graph Theory
Graphs are discrete structures consisting of vertices
and edges that connects these vertices. There are
several types of graphs that differ with respect to the
kind and number of edges that can connect a pair of
vertices.
A simple graph G = (V, E) consists of V, a nonempty
set of vertices, and E, a set of unordered pairs of
distinct elements V called edges.
A multigraph G = (V, E) consists of a set V of
vertices, a set of E of edges, and a function f from E to
{{u, v} | u, v є V, u ≠ v}. The edges e1 and e2 are called
multiple or parallel edges if f(e1) = f(e2).
A pseudograph G = (V, E) consists of a set V of
vertices, a set E of edges, and a function f from E to
{{u, v} | u, v є V}. An edge is loop of f(e) = {u, u} = {u}
for some u є V.
A directed graph (V, E) consists of a set of vertices V
and a set of edges E that are ordered pairs of
elements V.
A directed multigraph G = (V, E) consists of a set of
vertices V and a set of edges E, and d function f from
E to {(u, v) | u, v ε V}. The edges e1 and e2 are multiple
edges if f(e1) = f(e2).
Summary
Graph Terminology
Type

Edges

Multiple Loops
edges

Simple Graph

Undirected

No

No

Multigraph

Undirected

Yes

No

Pseudograph

Undirected

Yes

Yes

Directed Graph

Directed

No

Yes

Directed multigraph

Directed

Yes

Yes
Basic Terminology
Two vertices u and v in an undirected graph G are
called adjacent (or neighbors) in G if {u, v} is an
edge of G. If e = {u, v}, the edge e is called incident
with the vertices u and v. The edge e is also said to
connect u and v. The vertices u and v are called
endpoints of the edge {u, v}
The degree of a vertex in an undirected graph is the
number of edges incident with it, except that a loop at
a vertex contributes twice to the degree of that
vertex. The degree of the vertex v is denoted by
deg(v).
A vertex of degree 0 is called isolated.
A vertex is pendant if and only if it has degree 1.
Example: What are the degrees of the vertices in
graphs G and H.
b

G
a

c

b

H
e

g

e

f
a

d

d

c
Theorem 1
The Handshaking Theorem Let G = (V, E) be an
undirected graph with e edges. Then

2e = ∑ deg( v )
vεV

Example: How many edges are there in a graph with
10 vertices each of degree 6.
2e = (10)(6)
2e = 60
e = 30
Theorem 2
An undirected graph has an even number of vertices
of odd degree.
When (u, v) is an edge of the graph G with directed
edges, u is said to adjacent to u and v is said to be
adjacent from u. The vertex u is called the initial
vertex of (u, v), and v is called the terminal or end
vertex of (u, v). The initial vertex and terminal vertex
of a loop are the same.
In a graph with directed edges the in-degree of a
vertex v, denoted by deg – (v), is the number of edges
with v as their terminal vertex. The out-degree of v,
denoted by deg + (v), is the number of edges with v
as their initial vertex. (Note that a loop at a vertex
contributes 1 to both the in-degree and the outdegree of this vertex.)
Let G = (V, E) be a graph with directed edges. Then
−

+

∑ deg ( v ) = ∑ deg ( v ) = E

vεV

vεV
Example: Find the in-degree and out-degree of each
vertex in the graph shown below with directed edges.
a

b
c

f
e

d
Cycles – the cycle Cn, n ≥ 3, consists of n vertices v1,
v2,…., vn and edges {v1, v2}, {v2, v3},…, {vn-1, vn}, and
{vn, v1}.

C3

C4

C5

C6
Wheels – we obtain the wheel Wn when we add an
additional vertex to the cycle Cn, for n ≥ 3, and
connect this new vertex to each of the n vertices C n,
by new edges.

W3

W4

W5

W6
Representing Graphs
Adjacency lists – is used to represent a graph with
no multiple edges which specify the vertices that are
adjacent to each vertex of the graph.
B
A
E

B
C

A

D

C
E

D

Vertex Adjacent
Vertices

Vertex Adjacent
Vertices

A
B
C
D
E

A
B
C
D
E

B, C, E
A
A, D, E
C, E
A, C, D

B, C, D, E
B, D
A, C, E
B, C, D
Adjacency matrix (Ag), with respect to this listing of
the vertices, is the n x n zero-one matrix with 1 as its
(i, j)th entry when vi and vj are adjacent, and 0 as its
(i, j) entry when they are not adjacent. In other words,
if its adjacency matrix is A = [aij], then

1
aij = 
0

a
c

If {vi, vj} is an edge of G,
otherwise.

0
b 
1

1
d 
1

1
0
1
0

1
1
0
0

1

0
0

0

a
d

0
b
1

1
c
0

1
0
0
1

1
0
0
1

0

1
1

0
Adjacency matrices can also be used to represent
undirected graphs with loops and with multiple
edges. A loop at the vertex ai is represented by 1 at
the (i, j)th position of the adjacency matrix. When
multiple edges are present, the adjacency matrix is
no longer zero-one matrix, since the (i, j) entry of this
matrix equals the number of edges that are
associated to {ai, aj}. All undirected graphs, including
multigraphs and pseudographs, have symmetric
adjacency matrices
0 3 0 2
a
b


d

c

3 0 0 1

0 0 1 2


2 1 2 0
Incidence matrices – Let G = (V, E) be an
undirected graph. Suppose that v1, v2, …, vn are the
vertices and e1, e2, …., em are the edges of G. Then
the incidence matrix with respect to this ordering of V
and E is the n x m matrix M = [mij], where

1
mij = 
0
v1
e1
v4

e3
e2

when edge ej is incident with vi,
otherwise.

v 2 e6
e4
v5

v3
e5

1
0

0

1
0


1 0 0 0 0

0 1 1 0 1
0 0 0 1 1

0 1 0 0 0
1 0 1 1 0

Exercises: I. Represent the following
adjacency and incidence matrix.
e1
e2
b
a
a
b
1.
2.
e3
e3
e1
e4
e4 e5
e
c

e2

d

d
e9

a
3. e1
d
e11

e7
e5
e2 e3
e6
e8

e10

b
e4

c
e12

e6
e7

e8

5

c

using
II. Draw the graph represented by the given
adjacency matrix.

1 0 1 1 2 0
0 0 1 

4.
 5.2 0 2
1 1 1 0 2 1 

 


1
2
6.
0

1

2 0 1

0 3 0
3 1 1

0 1 0

III. Draw the graph and represent it using adjacency
matrix.
7. K4

8. K6

9. C10 10. W6
Shortest Path Problems
Applications: mileage, flight times, fares, distance,
response time, least rates, and so on.
Weighted graphs are graphs that have a number
assigned to each edge.
The length of a path in a weighted graph is the sum
of the weights of the edges of this path.
Dijktra’s Algorithm (a shortest path algorithm)
Theorem 1
Dijktra’s algorithm finds the length of a shortest path
between two vertices in a connected simple undirected
weighted graph.
Theorem 2
Dijktra’s algorithm uses O(n2) operations (additions
and comparisons) to find the length of the shortest
path between two vertices in a connected simple
undirected weighted graph.
Find the length of the shortest path between a and z
in the given weighted graph.
b

d

5

f

5

7

4
3

2

a

1

2

z

3

4
c

6

e

5

g
The traveling salesman problem
It asks for the circuit of minimum total weigh in a
weighted, complete, undirected graph that visits each
vertex exactly once and returns to its starting point.
Saginaw
113
Ground
Rapids
56

137

142

98

147
167
Detroit

135
Kalamazoo

58

133
Toledo
Route

Total distance
(miles)

D–T–G–S–K–D
D–T–G–K–S–D
D–T–K–S–G–D
D–T–K–G–S–D
D–T–S–K–G–D
D–T–S–G–K–D
D–S–T–G–K–D
D–S–T–K–G–D
D–S–K–T–G–D
D–S–G–T–K–D
D–G–S–T–K–D
D–G–T–S–K–D

610
516
588
458
540
504
598
576
682
646
670
728
Euler and Hamilton Paths
An Euler circuit in a graph G is s simple circuit
containing every edge of G. An Euler path in G is a
simple path containing every edge of G.
Theorem 1
A connected multigraph has an Euler circuit if and only
if each of its vertices has even degree.
Theorem 2
A connected multigraph has an Euler path but not
Euler circuit if and only if it has exactly two vertices of
odd degree.
A path x0, x1, …., xn-1, xn in the graph G = (V, E) is
called a Hamilton path if V = {x0, x1, …, xn-1, xn} and xi
≠ xj for 0 ≤ i , j ≤ n. A circuit x0, x1, …, xn-1, x0 (with n >
1) in a graph G = (V, E) is called Hamilton circuit if
x0, x1, …, xn-1, xn is a Hamilton path.
Theorem 3
If G is connected simple graph with n vertices where
n ≥ 3, then G has a Hamilton circuit if the degree of
each vertex is at least n/2.
Exercises:
1. Find the shortest path from a to z and a to x.
d
30

a

20

42

b
35

75
40

x

c
55

75

85

e
45
z
2. Solve the traveling salesman problem for the
following graph by finding the total weight of all the
circuits and determining a circuit with minimum total
weight.
3

a

b

7

10
2

8
5

e
1

4

c
9

d

6
1 de 26

Recomendados

Graph Theory Introduction por
Graph Theory IntroductionGraph Theory Introduction
Graph Theory IntroductionMANISH T I
1.9K vistas18 diapositivas
Graph theory presentation por
Graph theory presentationGraph theory presentation
Graph theory presentationAliul Kadir Akib
24.7K vistas24 diapositivas
introduction to graph theory por
introduction to graph theoryintroduction to graph theory
introduction to graph theoryChuckie Balbuena
21.6K vistas49 diapositivas
Graph Theory por
Graph TheoryGraph Theory
Graph TheoryEhsan Hamzei
4.1K vistas14 diapositivas
Introduction to Graph Theory por
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph TheoryPremsankar Chakkingal
35.1K vistas35 diapositivas
Graphs - Discrete Math por
Graphs - Discrete MathGraphs - Discrete Math
Graphs - Discrete MathSikder Tahsin Al-Amin
13.7K vistas18 diapositivas

Más contenido relacionado

La actualidad más candente

Ppt of graph theory por
Ppt of graph theoryPpt of graph theory
Ppt of graph theoryArvindBorge
600 vistas81 diapositivas
Graph theory por
Graph  theoryGraph  theory
Graph theoryManash Kumar Mondal
4.1K vistas42 diapositivas
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring por
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringSaurabh Kaushik
10.7K vistas52 diapositivas
Graph theory introduction - Samy por
Graph theory  introduction - SamyGraph theory  introduction - Samy
Graph theory introduction - SamyMark Arokiasamy
1.9K vistas90 diapositivas
Graph theory por
Graph theory Graph theory
Graph theory iranian translate
877 vistas56 diapositivas
Graph theory por
Graph theoryGraph theory
Graph theoryAparnaKumari31
2K vistas13 diapositivas

La actualidad más candente(20)

Ppt of graph theory por ArvindBorge
Ppt of graph theoryPpt of graph theory
Ppt of graph theory
ArvindBorge600 vistas
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring por Saurabh Kaushik
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Saurabh Kaushik10.7K vistas
Graph theory introduction - Samy por Mark Arokiasamy
Graph theory  introduction - SamyGraph theory  introduction - Samy
Graph theory introduction - Samy
Mark Arokiasamy1.9K vistas
Interesting applications of graph theory por Tech_MX
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theory
Tech_MX54.5K vistas
graph theory por ganith2k13
graph theory graph theory
graph theory
ganith2k1314.5K vistas
Graph theory concepts complex networks presents-rouhollah nabati por nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
nabati2.8K vistas
Slides Chapter10.1 10.2 por showslidedump
Slides Chapter10.1 10.2Slides Chapter10.1 10.2
Slides Chapter10.1 10.2
showslidedump3.1K vistas
Introduction to Graph Theory por Kazi Md. Saidul
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
Kazi Md. Saidul1.6K vistas
Cs6702 graph theory and applications 2 marks questions and answers por appasami
Cs6702 graph theory and applications 2 marks questions and answersCs6702 graph theory and applications 2 marks questions and answers
Cs6702 graph theory and applications 2 marks questions and answers
appasami13.5K vistas
Real life application por umadeviR3
Real life applicationReal life application
Real life application
umadeviR3194 vistas
Graph theory por Kumar
Graph theoryGraph theory
Graph theory
Kumar 9.9K vistas

Destacado

Matrix Representation Of Graph por
Matrix Representation Of GraphMatrix Representation Of Graph
Matrix Representation Of GraphAbhishek Pachisia
26K vistas8 diapositivas
Graph representation por
Graph representationGraph representation
Graph representationTech_MX
37.2K vistas34 diapositivas
Graphs In Data Structure por
Graphs In Data StructureGraphs In Data Structure
Graphs In Data StructureAnuj Modi
45.6K vistas32 diapositivas
Graph theory1234 por
Graph theory1234Graph theory1234
Graph theory1234muhamadsyafiqzaini
781 vistas36 diapositivas
Graph theory por
Graph theoryGraph theory
Graph theoryLifeparticle
10.3K vistas44 diapositivas
Zato my iz_zato por
Zato my iz_zatoZato my iz_zato
Zato my iz_zatomarymam
293 vistas14 diapositivas

Destacado(19)

Graph representation por Tech_MX
Graph representationGraph representation
Graph representation
Tech_MX37.2K vistas
Graphs In Data Structure por Anuj Modi
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
Anuj Modi45.6K vistas
Zato my iz_zato por marymam
Zato my iz_zatoZato my iz_zato
Zato my iz_zato
marymam293 vistas
Zato my iz_zato por marymam
Zato my iz_zatoZato my iz_zato
Zato my iz_zato
marymam281 vistas
Metadata & brokering - a modern approach #2 por Daniele Bailo
Metadata & brokering - a modern approach #2Metadata & brokering - a modern approach #2
Metadata & brokering - a modern approach #2
Daniele Bailo622 vistas
Alimentacióny nutrición alejandrina ibarra avila por cynthiardzb
Alimentacióny nutrición alejandrina ibarra avilaAlimentacióny nutrición alejandrina ibarra avila
Alimentacióny nutrición alejandrina ibarra avila
cynthiardzb335 vistas
Safe Routes to School - Elise Bremer-Nei por njbikeped
Safe Routes to School - Elise Bremer-NeiSafe Routes to School - Elise Bremer-Nei
Safe Routes to School - Elise Bremer-Nei
njbikeped1.1K vistas
Bali island por AIZZY118
Bali islandBali island
Bali island
AIZZY118341 vistas
UCL of Slideshare por Jeane Paguio
UCL of SlideshareUCL of Slideshare
UCL of Slideshare
Jeane Paguio1.3K vistas
Kurchatow por marymam
KurchatowKurchatow
Kurchatow
marymam334 vistas
PRESENTACIÓN DEL IIEP _ NC por nadiamjiiep
PRESENTACIÓN DEL IIEP _ NCPRESENTACIÓN DEL IIEP _ NC
PRESENTACIÓN DEL IIEP _ NC
nadiamjiiep185 vistas
зато мы из ЗАТО por marymam
зато мы из ЗАТОзато мы из ЗАТО
зато мы из ЗАТО
marymam345 vistas

Similar a Graph theory

graph ASS (1).ppt por
graph ASS (1).pptgraph ASS (1).ppt
graph ASS (1).pptARVIND SARDAR
33 vistas158 diapositivas
graph.ppt por
graph.pptgraph.ppt
graph.pptSumitSamanta16
55 vistas98 diapositivas
graph.ppt por
graph.pptgraph.ppt
graph.pptRakeshPandey951330
98 vistas107 diapositivas
Chapter 5 Graphs (1).ppt por
Chapter 5 Graphs (1).pptChapter 5 Graphs (1).ppt
Chapter 5 Graphs (1).pptishan743441
230 vistas148 diapositivas
Graph ASS DBATU.pptx por
Graph ASS DBATU.pptxGraph ASS DBATU.pptx
Graph ASS DBATU.pptxARVIND SARDAR
4 vistas151 diapositivas
Elements of Graph Theory for IS.pptx por
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxmiki304759
48 vistas48 diapositivas

Similar a Graph theory(20)

Chapter 5 Graphs (1).ppt por ishan743441
Chapter 5 Graphs (1).pptChapter 5 Graphs (1).ppt
Chapter 5 Graphs (1).ppt
ishan743441230 vistas
Elements of Graph Theory for IS.pptx por miki304759
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
miki30475948 vistas
Ass. (3)graph d.m por Syed Umair
Ass. (3)graph d.mAss. (3)graph d.m
Ass. (3)graph d.m
Syed Umair564 vistas
Tn 110 lecture 8 por ITNet
Tn 110 lecture 8Tn 110 lecture 8
Tn 110 lecture 8
ITNet45 vistas
graph.pptx por hijigaf
graph.pptxgraph.pptx
graph.pptx
hijigaf14 vistas
Lecture 1--Graph Algorithms -- Basics.pptx por ChandanGiri21
Lecture 1--Graph Algorithms -- Basics.pptxLecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptx
ChandanGiri2136 vistas
Data structure - Graph por Madhu Bala
Data structure - GraphData structure - Graph
Data structure - Graph
Madhu Bala6.2K vistas
Graph terminologies & special type graphs por Nabeel Ahsen
Graph terminologies & special type graphsGraph terminologies & special type graphs
Graph terminologies & special type graphs
Nabeel Ahsen6.4K vistas

Último

.conf Go 2023 - Data analysis as a routine por
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routineSplunk
90 vistas12 diapositivas
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy por
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy
"Role of a CTO in software outsourcing company", Yuriy NakonechnyyFwdays
40 vistas21 diapositivas
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu... por
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...NUS-ISS
32 vistas54 diapositivas
"Fast Start to Building on AWS", Igor Ivaniuk por
"Fast Start to Building on AWS", Igor Ivaniuk"Fast Start to Building on AWS", Igor Ivaniuk
"Fast Start to Building on AWS", Igor IvaniukFwdays
36 vistas76 diapositivas
[2023] Putting the R! in R&D.pdf por
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdfEleanor McHugh
38 vistas127 diapositivas
Web Dev - 1 PPT.pdf por
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdfgdsczhcet
52 vistas45 diapositivas

Último(20)

.conf Go 2023 - Data analysis as a routine por Splunk
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routine
Splunk90 vistas
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy por Fwdays
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy
"Role of a CTO in software outsourcing company", Yuriy Nakonechnyy
Fwdays40 vistas
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu... por NUS-ISS
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
Architecting CX Measurement Frameworks and Ensuring CX Metrics are fit for Pu...
NUS-ISS32 vistas
"Fast Start to Building on AWS", Igor Ivaniuk por Fwdays
"Fast Start to Building on AWS", Igor Ivaniuk"Fast Start to Building on AWS", Igor Ivaniuk
"Fast Start to Building on AWS", Igor Ivaniuk
Fwdays36 vistas
[2023] Putting the R! in R&D.pdf por Eleanor McHugh
[2023] Putting the R! in R&D.pdf[2023] Putting the R! in R&D.pdf
[2023] Putting the R! in R&D.pdf
Eleanor McHugh38 vistas
Web Dev - 1 PPT.pdf por gdsczhcet
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet52 vistas
The details of description: Techniques, tips, and tangents on alternative tex... por BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada110 vistas
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur por Fwdays
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur
"Thriving Culture in a Product Company — Practical Story", Volodymyr Tsukur
Fwdays40 vistas
Understanding GenAI/LLM and What is Google Offering - Felix Goh por NUS-ISS
Understanding GenAI/LLM and What is Google Offering - Felix GohUnderstanding GenAI/LLM and What is Google Offering - Felix Goh
Understanding GenAI/LLM and What is Google Offering - Felix Goh
NUS-ISS39 vistas
TE Connectivity: Card Edge Interconnects por CXL Forum
TE Connectivity: Card Edge InterconnectsTE Connectivity: Card Edge Interconnects
TE Connectivity: Card Edge Interconnects
CXL Forum96 vistas
AI: mind, matter, meaning, metaphors, being, becoming, life values por Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
Transcript: The Details of Description Techniques tips and tangents on altern... por BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada119 vistas
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ... por Fwdays
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ..."Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ...
"Quality Assurance: Achieving Excellence in startup without a Dedicated QA", ...
Fwdays33 vistas
Astera Labs: Intelligent Connectivity for Cloud and AI Infrastructure por CXL Forum
Astera Labs:  Intelligent Connectivity for Cloud and AI InfrastructureAstera Labs:  Intelligent Connectivity for Cloud and AI Infrastructure
Astera Labs: Intelligent Connectivity for Cloud and AI Infrastructure
CXL Forum125 vistas
Microchip: CXL Use Cases and Enabling Ecosystem por CXL Forum
Microchip: CXL Use Cases and Enabling EcosystemMicrochip: CXL Use Cases and Enabling Ecosystem
Microchip: CXL Use Cases and Enabling Ecosystem
CXL Forum129 vistas
Future of Learning - Yap Aye Wee.pdf por NUS-ISS
Future of Learning - Yap Aye Wee.pdfFuture of Learning - Yap Aye Wee.pdf
Future of Learning - Yap Aye Wee.pdf
NUS-ISS38 vistas
Combining Orchestration and Choreography for a Clean Architecture por ThomasHeinrichs1
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean Architecture
ThomasHeinrichs168 vistas
Five Things You SHOULD Know About Postman por Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman25 vistas

Graph theory

  • 1. Graph Theory Graphs are discrete structures consisting of vertices and edges that connects these vertices. There are several types of graphs that differ with respect to the kind and number of edges that can connect a pair of vertices. A simple graph G = (V, E) consists of V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements V called edges. A multigraph G = (V, E) consists of a set V of vertices, a set of E of edges, and a function f from E to {{u, v} | u, v є V, u ≠ v}. The edges e1 and e2 are called multiple or parallel edges if f(e1) = f(e2).
  • 2. A pseudograph G = (V, E) consists of a set V of vertices, a set E of edges, and a function f from E to {{u, v} | u, v є V}. An edge is loop of f(e) = {u, u} = {u} for some u є V. A directed graph (V, E) consists of a set of vertices V and a set of edges E that are ordered pairs of elements V. A directed multigraph G = (V, E) consists of a set of vertices V and a set of edges E, and d function f from E to {(u, v) | u, v ε V}. The edges e1 and e2 are multiple edges if f(e1) = f(e2).
  • 3. Summary Graph Terminology Type Edges Multiple Loops edges Simple Graph Undirected No No Multigraph Undirected Yes No Pseudograph Undirected Yes Yes Directed Graph Directed No Yes Directed multigraph Directed Yes Yes
  • 4. Basic Terminology Two vertices u and v in an undirected graph G are called adjacent (or neighbors) in G if {u, v} is an edge of G. If e = {u, v}, the edge e is called incident with the vertices u and v. The edge e is also said to connect u and v. The vertices u and v are called endpoints of the edge {u, v} The degree of a vertex in an undirected graph is the number of edges incident with it, except that a loop at a vertex contributes twice to the degree of that vertex. The degree of the vertex v is denoted by deg(v). A vertex of degree 0 is called isolated. A vertex is pendant if and only if it has degree 1.
  • 5. Example: What are the degrees of the vertices in graphs G and H. b G a c b H e g e f a d d c
  • 6. Theorem 1 The Handshaking Theorem Let G = (V, E) be an undirected graph with e edges. Then 2e = ∑ deg( v ) vεV Example: How many edges are there in a graph with 10 vertices each of degree 6. 2e = (10)(6) 2e = 60 e = 30
  • 7. Theorem 2 An undirected graph has an even number of vertices of odd degree. When (u, v) is an edge of the graph G with directed edges, u is said to adjacent to u and v is said to be adjacent from u. The vertex u is called the initial vertex of (u, v), and v is called the terminal or end vertex of (u, v). The initial vertex and terminal vertex of a loop are the same.
  • 8. In a graph with directed edges the in-degree of a vertex v, denoted by deg – (v), is the number of edges with v as their terminal vertex. The out-degree of v, denoted by deg + (v), is the number of edges with v as their initial vertex. (Note that a loop at a vertex contributes 1 to both the in-degree and the outdegree of this vertex.) Let G = (V, E) be a graph with directed edges. Then − + ∑ deg ( v ) = ∑ deg ( v ) = E vεV vεV
  • 9. Example: Find the in-degree and out-degree of each vertex in the graph shown below with directed edges. a b c f e d
  • 10. Cycles – the cycle Cn, n ≥ 3, consists of n vertices v1, v2,…., vn and edges {v1, v2}, {v2, v3},…, {vn-1, vn}, and {vn, v1}. C3 C4 C5 C6
  • 11. Wheels – we obtain the wheel Wn when we add an additional vertex to the cycle Cn, for n ≥ 3, and connect this new vertex to each of the n vertices C n, by new edges. W3 W4 W5 W6
  • 12. Representing Graphs Adjacency lists – is used to represent a graph with no multiple edges which specify the vertices that are adjacent to each vertex of the graph. B A E B C A D C E D Vertex Adjacent Vertices Vertex Adjacent Vertices A B C D E A B C D E B, C, E A A, D, E C, E A, C, D B, C, D, E B, D A, C, E B, C, D
  • 13. Adjacency matrix (Ag), with respect to this listing of the vertices, is the n x n zero-one matrix with 1 as its (i, j)th entry when vi and vj are adjacent, and 0 as its (i, j) entry when they are not adjacent. In other words, if its adjacency matrix is A = [aij], then 1 aij =  0 a c If {vi, vj} is an edge of G, otherwise. 0 b  1  1 d  1 1 0 1 0 1 1 0 0 1  0 0  0 a d 0 b 1  1 c 0 1 0 0 1 1 0 0 1 0  1 1  0
  • 14. Adjacency matrices can also be used to represent undirected graphs with loops and with multiple edges. A loop at the vertex ai is represented by 1 at the (i, j)th position of the adjacency matrix. When multiple edges are present, the adjacency matrix is no longer zero-one matrix, since the (i, j) entry of this matrix equals the number of edges that are associated to {ai, aj}. All undirected graphs, including multigraphs and pseudographs, have symmetric adjacency matrices 0 3 0 2 a b   d c 3 0 0 1  0 0 1 2   2 1 2 0
  • 15. Incidence matrices – Let G = (V, E) be an undirected graph. Suppose that v1, v2, …, vn are the vertices and e1, e2, …., em are the edges of G. Then the incidence matrix with respect to this ordering of V and E is the n x m matrix M = [mij], where 1 mij =  0 v1 e1 v4 e3 e2 when edge ej is incident with vi, otherwise. v 2 e6 e4 v5 v3 e5 1 0  0  1 0  1 0 0 0 0  0 1 1 0 1 0 0 0 1 1  0 1 0 0 0 1 0 1 1 0 
  • 16. Exercises: I. Represent the following adjacency and incidence matrix. e1 e2 b a a b 1. 2. e3 e3 e1 e4 e4 e5 e c e2 d d e9 a 3. e1 d e11 e7 e5 e2 e3 e6 e8 e10 b e4 c e12 e6 e7 e8 5 c using
  • 17. II. Draw the graph represented by the given adjacency matrix. 1 0 1 1 2 0 0 0 1   4.  5.2 0 2 1 1 1 0 2 1      1 2 6. 0  1 2 0 1  0 3 0 3 1 1  0 1 0 III. Draw the graph and represent it using adjacency matrix. 7. K4 8. K6 9. C10 10. W6
  • 18. Shortest Path Problems Applications: mileage, flight times, fares, distance, response time, least rates, and so on. Weighted graphs are graphs that have a number assigned to each edge. The length of a path in a weighted graph is the sum of the weights of the edges of this path.
  • 19. Dijktra’s Algorithm (a shortest path algorithm) Theorem 1 Dijktra’s algorithm finds the length of a shortest path between two vertices in a connected simple undirected weighted graph. Theorem 2 Dijktra’s algorithm uses O(n2) operations (additions and comparisons) to find the length of the shortest path between two vertices in a connected simple undirected weighted graph.
  • 20. Find the length of the shortest path between a and z in the given weighted graph. b d 5 f 5 7 4 3 2 a 1 2 z 3 4 c 6 e 5 g
  • 21. The traveling salesman problem It asks for the circuit of minimum total weigh in a weighted, complete, undirected graph that visits each vertex exactly once and returns to its starting point. Saginaw 113 Ground Rapids 56 137 142 98 147 167 Detroit 135 Kalamazoo 58 133 Toledo
  • 23. Euler and Hamilton Paths An Euler circuit in a graph G is s simple circuit containing every edge of G. An Euler path in G is a simple path containing every edge of G. Theorem 1 A connected multigraph has an Euler circuit if and only if each of its vertices has even degree. Theorem 2 A connected multigraph has an Euler path but not Euler circuit if and only if it has exactly two vertices of odd degree.
  • 24. A path x0, x1, …., xn-1, xn in the graph G = (V, E) is called a Hamilton path if V = {x0, x1, …, xn-1, xn} and xi ≠ xj for 0 ≤ i , j ≤ n. A circuit x0, x1, …, xn-1, x0 (with n > 1) in a graph G = (V, E) is called Hamilton circuit if x0, x1, …, xn-1, xn is a Hamilton path. Theorem 3 If G is connected simple graph with n vertices where n ≥ 3, then G has a Hamilton circuit if the degree of each vertex is at least n/2.
  • 25. Exercises: 1. Find the shortest path from a to z and a to x. d 30 a 20 42 b 35 75 40 x c 55 75 85 e 45 z
  • 26. 2. Solve the traveling salesman problem for the following graph by finding the total weight of all the circuits and determining a circuit with minimum total weight. 3 a b 7 10 2 8 5 e 1 4 c 9 d 6