Download presentation
Presentation is loading. Please wait.
1
Graph Theory and Algorithm 01
COP 6726: New Directions in Database Systems Graph Theory and Algorithm 01
2
Basics A graph is a pair G = (V, E) of sets such that E ⊆ [V]2.
The elements of V are the vertices (or nodes, or points) of the Graph G. The elements of E are its edges (or lines). A vertex v is incident with an edge e if v ∈ e; then e is an edge at v.
3
Graphs If all the vertices of G are pairwise adjacent, the G is complete. A complete graph on n vertices is a Kn. Pairwise non-adjacent vertices or edges are called independent. A class of graphs that is closed under isomorphism is called a graph property. If G`⊆ G and G` contains all the edges xy ∈ E with x,y ∈ V, then G` is an induced subgraph of G. The degree (or valency) dG(v) = d(v) of a vertex v is the number |E(v)| of edges at v.
4
Isomorphism
5
Subgraph A subgraph S of a graph G is a graph such that
The vertices of S are a subset of the vertices of G The edges of S are a subset of the edges of G A spanning subgraph of G is a subgraph that contains all the vertices of G Subgraph Spanning subgraph
6
Paths A path is a non-empty graph P=(V, E) of the form
V = {x0, x1, …, xk} E = {x0x1, x1x2, …, xk-1xk} ,where the xi are all distinct. Two a-b paths are independent if and only if a and b are their only common vertices.
7
Cycles The minimum length of a cycle in a graph G is the girth g(G) of G. The maximum length of a cycle in G is its circumference.
8
Connectivity A non-empty graph G is called connected if any two of its vertices are linked by a path in G. A maximal connected subgraph of G is a component of G. The components are induced subgraphs, and their vertex sets partition V. If A,B ⊆ V and X ⊆ V ∪ E are such that every AB in G contains a vertex or an edge from X, we say that X separates the sets A and B in G. A separating set of vertices is a separator. A vertex which separates two other vertices of the same components is a cut-vertex and an edge separating its ends is a bridge.
9
Non connected graph with two connected components
Connectivity Connected graph Non connected graph with two connected components
10
Connectivity G is called k-connected (for k ∈ ℕ) if G > k and G-X is connected for every set X ⊆ V with |X| < k. The greatest integer k such that G is k-connected is the connectivity k(G) of G. The greatest integer l such that G is l-edge connected is the edge-connectivity λ(G) of G.
11
Connectivity
12
Connectivity Block is a maximal connected subgraph without a cut-vertex. Thus, every block is either a maximal 2-conntected subgraph, or a bridge (with its ends), or an isolated vertex. Different blocks of G overlap in at most one vertex, which is the a cut-vertex of G.
13
Block Tree
14
Menger’s theorem Let G=(V,E) be a graph and A,B ⊆ V. Then the minimum number of vertices separating A from B in G is equal to the maximum number of disjoint A-B paths in G. A graph is k-connected if and only if it contains k independent paths between any two vertices A graph is k-edge-connected if and only if it contains k edge-disjoint paths between any two vertices.
15
Tree and forest An acyclic graph, one not contains any cycles, is called a forest. A connected forest is called tree. The following assentation are equivalent for a graph T: T is a tree. Any two vertices of T are linked by a unique path in T. T is minimally connected. T is maximally acyclic. The vertices at distance k from the root have height k and form the kth level of T.
16
Tree and forest Tree Forest
17
Tree A subtree of a graph is a subgraph which is a tree. If this tree is a spanning subgraph, it is called a spanning tree of the graph.
18
Bipartite graphs A graph G =(V,E) is called r-partite if V admits a partition into r classes such that every edge has its ends in different classes.
19
Matching in bipartite graphs
20
Complete Graph A complete graph A complete bipartite graph
21
Contraction and minors
22
Incidence and adjacency matrices
Incidence matrix Adjacency matrix
23
Basic Graph Algorithm
24
Depth First Search
25
Depth First Search Courtesy : https:// goo.gl/QVPy1i Adjacency Lists
A: F G B: A H C: A D D: C F E: C D G F: E: G: : H: B: I: H: B H C G I D E F Courtesy : goo.gl/QVPy1i
26
Depth First Search A-F A-G Function call stack: A B H C G I D E F
dfs(A) A-F A-G Function call stack:
27
Depth First Search F-E A-F A-G Function call stack: 27 A B H C G I D
visit(F) F-E E F dfs(A) A-F A-G Function call stack: 27
28
Depth First Search E-C E-D E-G F-E A-F A-G Function call stack: 28 A B
dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 28
29
Depth First Search C-A C-D E-C E-D E-G F-E A-F A-G
dfs(C) C-A C-D B H C G dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 29
30
Depth First Search C-A C-D E-C E-D E-G F-E A-F A-G
dfs(C) C-A C-D B H C G dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 30
31
Depth First Search D-C D-F C-A C-D E-C E-D E-G F-E A-F A-G
dfs(D) D-C D-F dfs(C) C-A C-D B H C G dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 31
32
Depth First Search D-C D-F C-A C-D E-C E-D E-G F-E A-F A-G
dfs(D) D-C D-F dfs(C) C-A C-D B H C G dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 32
33
Depth First Search D-C D-F C-A C-D E-C E-D E-G F-E A-F A-G
dfs(D) D-C D-F dfs(C) C-A C-D B H C G dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 33
34
Depth First Search C-A C-D E-C E-D E-G F-E A-F A-G
dfs(C) C-A C-D B H C G dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 34
35
Depth First Search E-C E-D E-G F-E A-F A-G Function call stack: 35 A B
dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 35
36
Depth First Search E-C E-D E-G F-E A-F A-G Function call stack: 36 A B
dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 36
37
Depth First Search E-C E-D E-G F-E A-F A-G Function call stack: 37 A
dfs(G) B H C G dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 37
38
Depth First Search E-C E-D E-G F-E A-F A-G Function call stack: 38 A B
dfs(E) E-C E-D E-G I D dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 38
39
Depth First Search F-E A-F A-G Function call stack: 39 A B H C G I D
dfs(F) F-E E F dfs(A) A-F A-G Function call stack: 39
40
Depth First Search A-F A-G Function call stack: 40 A B H C G I D E F
dfs(A) A-F A-G Function call stack: 40
41
Depth First Search A-F A-G Function call stack: 41 A B H C G I D E F
dfs(A) A-F A-G Function call stack: 41
42
Breadth First Search
43
Breadth First Search A B C D E F G H I FIFO Queue Closed Nodes
44
Breadth First Search FIFO Queue Closed Nodes A B C FIFO Queue
G H I FIFO Queue Closed Nodes FIFO Queue Closed Nodes FIFO Queue Closed Nodes
45
Dijkstra Algorithm
46
Dijkstra Algorithm 2 1 A B C 1 1 1 1 1 D E F 1 1 3 1 G H I A B C D E F
Priority Queue ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ Closed Nodes
47
Dijkstra Algorithm 2 1 Priority Queue Closed Nodes A B C D E F G H I A
A B C 1 1 1 Priority Queue Closed Nodes A B C D E F G H I 1 1 D E F 1 1 Priority Queue Closed Nodes A B C D E F G H I 3 1 G H I Priority Queue Closed Nodes A B C D E F G H I
48
Bellman Ford
49
Bellman-Ford Algorithm
2 -1 A B C 1 1 1 1 1 D E F 1 1 -3 1 G H I A B C D E F G H I ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞
50
Bellman-Ford Algorithm
2 -1 A B C D E F G H I A B C 1 1 1 1 1 D E F 1 1 -3 1 G H I
51
Potential Function
52
Potential Function 1 1 -2 1 A B C D
53
Potential Function d ( u, v) = d (u, v) – p(v) + p (u) 1 1 -1 1 -2 1 A
1 -1 1 -2 1 A B C D
54
Potential Function d ( u, v) = d (u, v) – p(v) + p (u) 1 1 -1 A B C D
55
Take Home Message Basic Graph theory Basic Graph Algorithms
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.