![Page 1: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/1.jpg)
Introduction to Introduction to Graph TheoryGraph Theory
Presented byPresented by
Mushfiqur Rouf (100505056)Mushfiqur Rouf (100505056)
![Page 2: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/2.jpg)
Graph Theory - HistoryGraph Theory - History
Leonhard Euler's paper on Leonhard Euler's paper on ““Seven Bridges of Seven Bridges of Königsberg”Königsberg” , ,
published in 1736. published in 1736.
![Page 3: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/3.jpg)
Famous problemsFamous problems
““The traveling salesman problem” The traveling salesman problem” – A traveling salesman is to visit a number of cities; how to plan A traveling salesman is to visit a number of cities; how to plan
the trip so every city is visited once and just once and the whole the trip so every city is visited once and just once and the whole trip is as short as possible ? trip is as short as possible ?
![Page 4: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/4.jpg)
Famous problemsFamous problems
In 1852 Francis Guthrie posed the “four color problem” In 1852 Francis Guthrie posed the “four color problem” which asks if it is possible to color, using only four which asks if it is possible to color, using only four colors, any map of countries in such a way as to colors, any map of countries in such a way as to prevent two bordering countries from having the prevent two bordering countries from having the same color. same color.
This problem, which was only solved a century later in This problem, which was only solved a century later in 1976 by Kenneth Appel and Wolfgang Haken, can be 1976 by Kenneth Appel and Wolfgang Haken, can be considered the birth of graph theory. considered the birth of graph theory.
![Page 5: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/5.jpg)
ExamplesExamples
Cost of wiring electronic componentsCost of wiring electronic components
Shortest route between two cities.Shortest route between two cities.
Shortest distance between all pairs of cities in Shortest distance between all pairs of cities in a road atlas.a road atlas.
Matching / Resource AllocationMatching / Resource Allocation
Task schedulingTask scheduling
Visibility / CoverageVisibility / Coverage
![Page 6: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/6.jpg)
ExamplesExamples
Flow of material Flow of material – liquid flowing through pipesliquid flowing through pipes
– current through electrical networkscurrent through electrical networks
– information through communication networksinformation through communication networks
– parts through an assembly lineparts through an assembly line
In Operating systems to model resource handling In Operating systems to model resource handling (deadlock problems)(deadlock problems)
In compilers for parsing and optimizing the code.In compilers for parsing and optimizing the code.
![Page 7: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/7.jpg)
BasicsBasics
![Page 8: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/8.jpg)
What is a Graph?What is a Graph?
Informally a Informally a graphgraph is a set of nodes joined by is a set of nodes joined by a set of lines or arrows.a set of lines or arrows.
1 12 3
4 45 56 6
2 3
![Page 9: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/9.jpg)
Definition: GraphDefinition: Graph
G is an ordered triple G:=(V, E, f)G is an ordered triple G:=(V, E, f)– V is a set of nodes, points, or vertices. V is a set of nodes, points, or vertices. – E is a set, whose elements are known as edges or E is a set, whose elements are known as edges or
lines. lines. – f is a function f is a function
maps each element of E maps each element of E
to an unordered pair of vertices in V. to an unordered pair of vertices in V.
![Page 10: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/10.jpg)
DefinitionsDefinitions
VertexVertex– Basic ElementBasic Element– Drawn as a Drawn as a nodenode or a or a dotdot..– VVertex setertex set of of GG is usually denoted by is usually denoted by VV((GG), or ), or VV
EdgeEdge– A set of two elementsA set of two elements– Drawn as a line connecting two vertices, called Drawn as a line connecting two vertices, called
end vertices, or endpoints. end vertices, or endpoints. – The edge set of G is usually denoted by E(G), or E.The edge set of G is usually denoted by E(G), or E.
![Page 11: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/11.jpg)
ExampleExample
V:={1,2,3,4,5,6} V:={1,2,3,4,5,6}
E:={{1,2},{1,5},{2,3},{2,5},{3,4},{4,5},{4,6}} E:={{1,2},{1,5},{2,3},{2,5},{3,4},{4,5},{4,6}}
![Page 12: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/12.jpg)
Simple Graphs Simple Graphs
Simple graphsSimple graphs are graphs without multiple are graphs without multiple edges or self-loops.edges or self-loops.
![Page 13: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/13.jpg)
PathPath
1 2 3
4 5 6
Cycle
Simple path from 1 to 5 = [ 1, 2, 4, 5 ]Our text’s alternates the verticesand edges.
A
D E F
B C
Unreachable
Cycle
If there is path If there is path pp from from uu to to vv then we then we say say vv is is reachablereachable from from uu via via pp. .
A A pathpath is a sequence of vertices such that there is an is a sequence of vertices such that there is an edge from each vertex to its successor. edge from each vertex to its successor.
A path is A path is simplesimple if each vertex is distinct. if each vertex is distinct.
![Page 14: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/14.jpg)
CycleCycle
A path from a vertex to itself is called a A path from a vertex to itself is called a cyclecycle. .
A graph is called A graph is called cycliccyclic if it contains a cycle; if it contains a cycle; – otherwise it is called otherwise it is called acyclicacyclic
1 2 3
4 5 6
Cycle
A
D E F
B C
Unreachable
Cycle
![Page 15: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/15.jpg)
ConnectivityConnectivity
is is connectedconnected if if – you can get from any node to any other by following a you can get from any node to any other by following a
sequence of edges OR sequence of edges OR
– any two nodes are connected by a path.any two nodes are connected by a path.
A directed graph is A directed graph is strongly connectedstrongly connected if there is a if there is a directed path from any node to any other node.directed path from any node to any other node.
![Page 16: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/16.jpg)
Sparse/DenseSparse/Dense
A graph is A graph is sparsesparse if | if | EE | | | | VV | |
A graph is A graph is densedense if | if | EE | | | | VV | |2.2.
![Page 17: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/17.jpg)
A A weighted graphweighted graph
1 2 3
4 5 6
.5
1.2
.2
.5
1.5.3
1
4 5 6
2 32
135
is a graph for which each edge has an associated is a graph for which each edge has an associated weightweight, usually given by a , usually given by a weight functionweight function w: Ew: E RR..
![Page 18: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/18.jpg)
Directed Graph (digraph)Directed Graph (digraph)
Edges have directionsEdges have directions– An edge is an An edge is an ordered ordered pair of nodespair of nodes
![Page 19: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/19.jpg)
BipartiteBipartite graphgraph
VV can be partitioned into 2 can be partitioned into 2 sets sets VV11 and and VV22
such that (such that (uu,,vv))EE implies implies – either either uu VV11 and and vv VV2 2
– OR OR vv VV1 1 and and uuVV2.2.
![Page 20: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/20.jpg)
Special TypesSpecial Types
Empty Graph / Edgeless graphEmpty Graph / Edgeless graph– No edgeNo edge
Null graphNull graph– No nodesNo nodes– Obviously no edgeObviously no edge
![Page 21: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/21.jpg)
Complete GraphComplete Graph
Denoted KDenoted Knn
Every pair of vertices are adjacentEvery pair of vertices are adjacent
Has n(n-1) edgesHas n(n-1) edges
![Page 22: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/22.jpg)
Complete Bipartite GraphComplete Bipartite Graph
Bipartite Variation of Complete GraphBipartite Variation of Complete Graph
Every node of one set is connected to every Every node of one set is connected to every other node on the other setother node on the other set
![Page 23: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/23.jpg)
Planar GraphPlanar Graph
Can be drawn on a plane such that no two edges intersectCan be drawn on a plane such that no two edges intersect
KK44 is the largest complete graph that is planar is the largest complete graph that is planar
![Page 24: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/24.jpg)
Dual GraphDual Graph
Faces are considered as Faces are considered as nodesnodes
Edges denote face Edges denote face adjacencyadjacency
Dual of dual is the Dual of dual is the original graphoriginal graph
![Page 25: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/25.jpg)
TreeTree
Connected Acyclic GraphConnected Acyclic Graph
Two nodes have Two nodes have exactlyexactly one one path between thempath between them
![Page 26: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/26.jpg)
Generalization: HypergraphGeneralization: Hypergraph
Generalization of a graph, Generalization of a graph, – edges can connect any number of vertices. edges can connect any number of vertices.
Formally, an hypergraph is a pair (X,E) where Formally, an hypergraph is a pair (X,E) where – X is a set of elements, called nodes or vertices, and X is a set of elements, called nodes or vertices, and – E is a set of subsets of X, called hyperedges. E is a set of subsets of X, called hyperedges.
Hyperedges are arbitrary sets of nodes, Hyperedges are arbitrary sets of nodes, – contain an arbitrary number of nodes.contain an arbitrary number of nodes.
![Page 27: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/27.jpg)
DegreeDegree
Number of edges incident on a nodeNumber of edges incident on a node
A
D E F
B C
The degree of B is 2.
![Page 28: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/28.jpg)
Degree (Directed Graphs)Degree (Directed Graphs)
In degree: Number of edges enteringIn degree: Number of edges enteringOut degree: Number of edges leavingOut degree: Number of edges leaving
Degree = indegree + outdegreeDegree = indegree + outdegree
1 2
4 5
The in degree of 2 is 2 andthe out degree of 2 is 3.
![Page 29: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/29.jpg)
Degree: Simple FactsDegree: Simple Facts
If If G G is a digraph with is a digraph with mm edges, then edges, then
indeg( indeg(vv) = ) = outdeg( outdeg(vv) = ) = m = |Em = |E | |
If If G G is a graph with is a graph with mm edges, then edges, then
deg( deg(vv) = 2) = 2mm = 2 | = 2 |EE | |
– Number of Odd degree Nodes is evenNumber of Odd degree Nodes is even
![Page 30: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/30.jpg)
SubgraphsSubgraphs
![Page 31: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/31.jpg)
SubgraphSubgraph
Vertex and edge sets are subsets of those of GVertex and edge sets are subsets of those of G– a a supergraphsupergraph of a graph G is a graph that contains of a graph G is a graph that contains
G as a subgraph. G as a subgraph.
A graph G contains another graph H if some A graph G contains another graph H if some subgraph of G subgraph of G – is H or is H or – is isomorphic to H.is isomorphic to H.
H is a H is a proper subgraphproper subgraph if H!=G if H!=G
![Page 32: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/32.jpg)
Spanning subgraphSpanning subgraph
Subgraph H has the same vertex set as G. Subgraph H has the same vertex set as G. – Possibly not all the edgesPossibly not all the edges– ““H spans G”.H spans G”.
![Page 33: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/33.jpg)
Induced SubgraphInduced Subgraph
For any pair of vertices x and y of H, xy is an For any pair of vertices x and y of H, xy is an edge of H if and only if xy is an edge of G.edge of H if and only if xy is an edge of G.– H has the most edges that appear in G over the H has the most edges that appear in G over the
same vertex set.same vertex set.
![Page 34: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/34.jpg)
Induced Subgraph (2)Induced Subgraph (2)
If H is chosen based on a vertex subset S of If H is chosen based on a vertex subset S of V(G), then H can be written as G[S]V(G), then H can be written as G[S]– ““induced by S”induced by S”
A graph that does not contain H as an induced A graph that does not contain H as an induced subgraph is said to be subgraph is said to be H-freeH-free
![Page 35: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/35.jpg)
ComponentComponent
Maximum Connected sub graphMaximum Connected sub graph
![Page 36: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/36.jpg)
IsomorphismIsomorphism
![Page 37: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/37.jpg)
IsomorphismIsomorphism
Bijection, i.e., a one-to-one mapping:Bijection, i.e., a one-to-one mapping:f : V(G) -> V(H) f : V(G) -> V(H)
u and v from G are adjacent if and only if f(u) u and v from G are adjacent if and only if f(u) and f(v) are adjacent in H.and f(v) are adjacent in H.
If an isomorphism can be constructed between If an isomorphism can be constructed between two graphs, then we say those graphs are two graphs, then we say those graphs are isomorphicisomorphic..
![Page 38: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/38.jpg)
Isomorphism ProblemIsomorphism Problem
Determining whether two Determining whether two graphs are isomorphicgraphs are isomorphic
Although these graphs look Although these graphs look very different, they are very different, they are isomorphic; one isomorphism isomorphic; one isomorphism between them isbetween them isf(a) = 1 f(b) = 6 f(c) = 8 f(d) = 3 f(a) = 1 f(b) = 6 f(c) = 8 f(d) = 3
f(g) = 5 f(h) = 2 f(i) = 4 f(j) = 7 f(g) = 5 f(h) = 2 f(i) = 4 f(j) = 7
![Page 39: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/39.jpg)
Graph Graph Abstract Data TypeAbstract Data Type
![Page 40: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/40.jpg)
Graph ADTGraph ADT
In computer science, a graph is an abstract In computer science, a graph is an abstract data type (ADT) data type (ADT)
that consists of that consists of – a set of nodes and a set of nodes and – a set of edges a set of edges
establish relationships (connections) between the nodes. establish relationships (connections) between the nodes.
The graph ADT follows directly from the The graph ADT follows directly from the graph concept from mathematics.graph concept from mathematics.
![Page 41: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/41.jpg)
Representation (Matrix)Representation (Matrix)
Incidence MatrixIncidence Matrix– E x VE x V– [edge, vertex] contains the edge's data [edge, vertex] contains the edge's data
Adjacency MatrixAdjacency Matrix– V x VV x V– Boolean values (adjacent or not)Boolean values (adjacent or not)– Or Edge WeightsOr Edge Weights
![Page 42: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/42.jpg)
Representation (List)Representation (List)
Edge ListEdge List– pairs (ordered if directed) of verticespairs (ordered if directed) of vertices– Optionally weight and other data Optionally weight and other data
Adjacency ListAdjacency List
![Page 43: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/43.jpg)
Implementation of a Graph.Implementation of a Graph.
Adjacency-list representation Adjacency-list representation – an array of |an array of |VV | lists, one for each vertex in | lists, one for each vertex in VV. . – For each For each uu VV , , ADJADJ [ [ uu ] points to all its adjacent ] points to all its adjacent
vertices.vertices.
![Page 44: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/44.jpg)
Adjacency-list representation for a Adjacency-list representation for a directed graph.directed graph.
1
5
1
22
5
4 4
3 3
2 5
5 3 4
4
5
5
Variation: Can keep a second list of edges coming into a vertex.
![Page 45: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/45.jpg)
Adjacency listsAdjacency lists
Advantage: Advantage: – Saves space for sparse graphs. Most graphs are Saves space for sparse graphs. Most graphs are
sparse.sparse.– Traverse all the edges that start at v, in Traverse all the edges that start at v, in
(degree(v))(degree(v))
Disadvantage:Disadvantage:– Check for existence of an edge (v, u) in worst Check for existence of an edge (v, u) in worst
case time case time (degree(v))(degree(v))
![Page 46: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/46.jpg)
Adjacency ListAdjacency List
StorageStorage– For a directed graph the number of items areFor a directed graph the number of items are
(out-degree ((out-degree (vv)) = | )) = | EE | |
So we need So we need ( ( V + V + EE ) )
– For undirected graph the number of items areFor undirected graph the number of items are
(degree ((degree (vv)) = 2 | )) = 2 | EE | |
Also Also ( ( V + V + EE ) )Easy to modify to handle weighted graphs. How?Easy to modify to handle weighted graphs. How?
v V
v V
![Page 47: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/47.jpg)
Adjacency matrix representationAdjacency matrix representation
1
5
2
4
3
1 2 3 4 5
12345
0 1 0 0 11 0 1 1 10 1 0 1 0
0 1 1 0 11 1 0 1 0
||VV | x | | x |V |V | matrix matrix A A = ( = ( aaijij ) ) such that such that
aaijij = 1 if ( = 1 if (i, ji, j ) ) EE and 0 otherwise. and 0 otherwise.
We We arbitrarily uniquely assign the numbers 1, arbitrarily uniquely assign the numbers 1, 2, . . . , | 2, . . . , | VV | to each vertex. | to each vertex.
![Page 48: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/48.jpg)
Adjacency Matrix Representation Adjacency Matrix Representation for a Directed Graphfor a Directed Graph
1 2 3 4 5
12345
0 1 0 0 10 0 1 1 10 0 0 1 0
0 0 0 0 10 0 0 0 0
1
5
2
4
3
![Page 49: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/49.jpg)
Adjacency Matrix RepresentationAdjacency Matrix Representation
Advantage:Advantage:– Saves space for:Saves space for:
Dense graphs. Dense graphs.
Small unweighted graphs using 1 bit per edge.Small unweighted graphs using 1 bit per edge.
– Check for existence of an edge in Check for existence of an edge in (1)(1)
Disadvantage:Disadvantage:– Traverse all the edges that start at v, in Traverse all the edges that start at v, in (|V|)(|V|)
![Page 50: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/50.jpg)
Adjacency Matrix RepresentationAdjacency Matrix Representation
Storage Storage ( | ( | VV | |22) ( We usually just write, ) ( We usually just write, ( ( VV 22) )) )– For undirected graphs you can save storage (only For undirected graphs you can save storage (only
1/2(V1/2(V22)) by noticing the adjacency matrix of an )) by noticing the adjacency matrix of an undirected graph is symmetric. How?undirected graph is symmetric. How?
Easy to handle weighted graphs. How?Easy to handle weighted graphs. How?
![Page 51: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/51.jpg)
Graph AlgorithmsGraph Algorithms
![Page 52: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/52.jpg)
Graph AlgorithmsGraph Algorithms
Shortest PathShortest Path– Single SourceSingle Source
– All pairs (Ex. Floyd Warshall)All pairs (Ex. Floyd Warshall)
Network FlowNetwork Flow
MatchingMatching– BipartiteBipartite
– WeightedWeighted
Topological OrderingTopological Ordering
Strongly ConnectedStrongly Connected
![Page 53: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/53.jpg)
Graph AlgorithmsGraph Algorithms
Biconnected Component / Articulation PointBiconnected Component / Articulation PointBridgeBridgeGraph ColoringGraph ColoringEuler TourEuler TourHamiltonian TourHamiltonian TourCliqueCliqueIsomorphismIsomorphismEdge CoverEdge CoverVertex CoverVertex CoverVisibilityVisibility
![Page 54: Introduction to Graph Theory Presented by Mushfiqur Rouf (100505056)](https://reader036.vdocuments.us/reader036/viewer/2022062519/5697c0151a28abf838ccdcd8/html5/thumbnails/54.jpg)
Thank youThank you