SlideShare una empresa de Scribd logo
1 de 26
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

Más contenido relacionado

La actualidad más candente

Interesting applications of graph theory
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theoryTech_MX
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph TheoryYosuke Mizutani
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabatinabati
 
Cs6702 graph theory and applications 2 marks questions and answers
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 answersappasami
 
Graph theory and its applications
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applicationsManikanta satyala
 
Graph Theory Introduction
Graph Theory IntroductionGraph Theory Introduction
Graph Theory IntroductionMANISH T I
 
Ppt of graph theory
Ppt of graph theoryPpt of graph theory
Ppt of graph theoryArvindBorge
 
Chapter 5 Graphs (1).ppt
Chapter 5 Graphs (1).pptChapter 5 Graphs (1).ppt
Chapter 5 Graphs (1).pptishan743441
 
Ford Fulkerson Algorithm
Ford Fulkerson AlgorithmFord Fulkerson Algorithm
Ford Fulkerson AlgorithmAdarsh Rotte
 
Slides Chapter10.1 10.2
Slides Chapter10.1 10.2Slides Chapter10.1 10.2
Slides Chapter10.1 10.2showslidedump
 
Graph isomorphism
Graph isomorphismGraph isomorphism
Graph isomorphismCore Condor
 
Isomorphic graph
Isomorphic graphIsomorphic graph
Isomorphic graphumair khan
 

La actualidad más candente (20)

Interesting applications of graph theory
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theory
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
 
Graph theory
Graph  theoryGraph  theory
Graph theory
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
 
Cs6702 graph theory and applications 2 marks questions and answers
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
 
Planar graph
Planar graphPlanar graph
Planar graph
 
Graph theory and its applications
Graph theory and its applicationsGraph theory and its applications
Graph theory and its applications
 
Graph Theory Introduction
Graph Theory IntroductionGraph Theory Introduction
Graph Theory Introduction
 
Ppt of graph theory
Ppt of graph theoryPpt of graph theory
Ppt of graph theory
 
Chapter 5 Graphs (1).ppt
Chapter 5 Graphs (1).pptChapter 5 Graphs (1).ppt
Chapter 5 Graphs (1).ppt
 
Ford Fulkerson Algorithm
Ford Fulkerson AlgorithmFord Fulkerson Algorithm
Ford Fulkerson Algorithm
 
Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
 
Graph Theory
Graph TheoryGraph Theory
Graph Theory
 
Slides Chapter10.1 10.2
Slides Chapter10.1 10.2Slides Chapter10.1 10.2
Slides Chapter10.1 10.2
 
Graph
GraphGraph
Graph
 
Graph isomorphism
Graph isomorphismGraph isomorphism
Graph isomorphism
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Isomorphic graph
Isomorphic graphIsomorphic graph
Isomorphic graph
 
graph theory
graph theory graph theory
graph theory
 

Destacado

Matrix Representation Of Graph
Matrix Representation Of GraphMatrix Representation Of Graph
Matrix Representation Of GraphAbhishek Pachisia
 
Graph representation
Graph representationGraph representation
Graph representationTech_MX
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data StructureAnuj Modi
 
Zato my iz_zato
Zato my iz_zatoZato my iz_zato
Zato my iz_zatomarymam
 
Zato my iz_zato
Zato my iz_zatoZato my iz_zato
Zato my iz_zatomarymam
 
Metadata & brokering - a modern approach #2
Metadata & brokering - a modern approach #2Metadata & brokering - a modern approach #2
Metadata & brokering - a modern approach #2Daniele Bailo
 
Alimentacióny nutrición alejandrina ibarra avila
Alimentacióny nutrición alejandrina ibarra avilaAlimentacióny nutrición alejandrina ibarra avila
Alimentacióny nutrición alejandrina ibarra avilacynthiardzb
 
Safe Routes to School - Elise Bremer-Nei
Safe Routes to School - Elise Bremer-NeiSafe Routes to School - Elise Bremer-Nei
Safe Routes to School - Elise Bremer-Neinjbikeped
 
Arus bolak balik klompok 4
Arus bolak balik klompok 4Arus bolak balik klompok 4
Arus bolak balik klompok 4FITRIA NENGSIH
 
Bali island
Bali islandBali island
Bali islandAIZZY118
 
Kurchatow
KurchatowKurchatow
Kurchatowmarymam
 
PRESENTACIÓN DEL IIEP _ NC
PRESENTACIÓN DEL IIEP _ NCPRESENTACIÓN DEL IIEP _ NC
PRESENTACIÓN DEL IIEP _ NCnadiamjiiep
 
зато мы из ЗАТО
зато мы из ЗАТОзато мы из ЗАТО
зато мы из ЗАТОmarymam
 

Destacado (18)

Matrix Representation Of Graph
Matrix Representation Of GraphMatrix Representation Of Graph
Matrix Representation Of Graph
 
Graph representation
Graph representationGraph representation
Graph representation
 
Graphs In Data Structure
Graphs In Data StructureGraphs In Data Structure
Graphs In Data Structure
 
Graph theory1234
Graph theory1234Graph theory1234
Graph theory1234
 
Zato my iz_zato
Zato my iz_zatoZato my iz_zato
Zato my iz_zato
 
Zato my iz_zato
Zato my iz_zatoZato my iz_zato
Zato my iz_zato
 
MD Grand Akashu Riau
MD Grand Akashu RiauMD Grand Akashu Riau
MD Grand Akashu Riau
 
Metadata & brokering - a modern approach #2
Metadata & brokering - a modern approach #2Metadata & brokering - a modern approach #2
Metadata & brokering - a modern approach #2
 
Alimentacióny nutrición alejandrina ibarra avila
Alimentacióny nutrición alejandrina ibarra avilaAlimentacióny nutrición alejandrina ibarra avila
Alimentacióny nutrición alejandrina ibarra avila
 
Safe Routes to School - Elise Bremer-Nei
Safe Routes to School - Elise Bremer-NeiSafe Routes to School - Elise Bremer-Nei
Safe Routes to School - Elise Bremer-Nei
 
Arus bolak balik klompok 4
Arus bolak balik klompok 4Arus bolak balik klompok 4
Arus bolak balik klompok 4
 
Bali island
Bali islandBali island
Bali island
 
UCL of Slideshare
UCL of SlideshareUCL of Slideshare
UCL of Slideshare
 
Hazyl Joan Amellos
Hazyl Joan AmellosHazyl Joan Amellos
Hazyl Joan Amellos
 
Strat Plan May 31 2014
Strat Plan May 31 2014Strat Plan May 31 2014
Strat Plan May 31 2014
 
Kurchatow
KurchatowKurchatow
Kurchatow
 
PRESENTACIÓN DEL IIEP _ NC
PRESENTACIÓN DEL IIEP _ NCPRESENTACIÓN DEL IIEP _ NC
PRESENTACIÓN DEL IIEP _ NC
 
зато мы из ЗАТО
зато мы из ЗАТОзато мы из ЗАТО
зато мы из ЗАТО
 

Similar a Graph theory

Similar a Graph theory (20)

graph ASS (1).ppt
graph ASS (1).pptgraph ASS (1).ppt
graph ASS (1).ppt
 
graph.ppt
graph.pptgraph.ppt
graph.ppt
 
graph.ppt
graph.pptgraph.ppt
graph.ppt
 
Graph ASS DBATU.pptx
Graph ASS DBATU.pptxGraph ASS DBATU.pptx
Graph ASS DBATU.pptx
 
Graphs.pdf
Graphs.pdfGraphs.pdf
Graphs.pdf
 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
 
LEC 1.pptx
LEC 1.pptxLEC 1.pptx
LEC 1.pptx
 
Ass. (3)graph d.m
Ass. (3)graph d.mAss. (3)graph d.m
Ass. (3)graph d.m
 
1. Graph and Graph Terminologiesimp.pptx
1. Graph and Graph Terminologiesimp.pptx1. Graph and Graph Terminologiesimp.pptx
1. Graph and Graph Terminologiesimp.pptx
 
Tn 110 lecture 8
Tn 110 lecture 8Tn 110 lecture 8
Tn 110 lecture 8
 
Graphs
GraphsGraphs
Graphs
 
graph.pptx
graph.pptxgraph.pptx
graph.pptx
 
graph theory
graph theorygraph theory
graph theory
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
 
Unit 2: All
Unit 2: AllUnit 2: All
Unit 2: All
 
Graph-theory.ppt
Graph-theory.pptGraph-theory.ppt
Graph-theory.ppt
 
Graph.ppt
Graph.pptGraph.ppt
Graph.ppt
 
DIGITAL TEXT BOOK
DIGITAL TEXT BOOKDIGITAL TEXT BOOK
DIGITAL TEXT BOOK
 
Ch08.ppt
Ch08.pptCh08.ppt
Ch08.ppt
 
Lecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptxLecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptx
 

Último

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 

Último (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 

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