Module #19: Graph Theory: part II
-
Upload
chamomile-green -
Category
Documents
-
view
45 -
download
0
description
Transcript of Module #19: Graph Theory: part II
![Page 1: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/1.jpg)
Module #19:Graph Theory: part II
Rosen 5th ed., chs. 8-9
![Page 2: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/2.jpg)
§8.3: Graph Representations & Isomorphism
• Graph representations:– Adjacency lists.– Adjacency matrices.– Incidence matrices.
• Graph isomorphism:– Two graphs are isomorphic iff they are
identical except for their node names.
![Page 3: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/3.jpg)
Adjacency Lists
• A table with 1 row per vertex, listing its adjacent vertices.
a b
dc
fe
Vertex
Adjacent Vertices
a b
b, c a, c, e, f
c a, b, f d e b f c, b
![Page 4: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/4.jpg)
Directed Adjacency Lists
• 1 row per node, listing the terminal nodes of each edge incident from that node.
0 1
23
4
node Terminal nodes
0 3
1 0, 2, 4
2 1
3
4 0,2
![Page 5: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/5.jpg)
Adjacency Matrices
• Matrix A=[aij], where aij is 1 if {vi, vj} is an edge of G, 0 otherwise.
ab
c
d
0001
0011
0101
1110a
b
c
d
a b c d
![Page 6: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/6.jpg)
Adjacency Matrices for pseudo graph
• Matrix A=[aij], where aij is the number of edges that are associated to {vi, vj}
0212
2110
1103
2030a
b
c
d
a b c d
ab
cd
![Page 7: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/7.jpg)
Incidence matrices
• Matrix M=[mij], where mij is 1 when edge ej
is incident with vi, 0 otherwise
v1
v2
v3
v4
e1 e2 e3 e4v1v4
v3
v2
e5
11010
000
000
001
11
11
11e1
e2
e5
e4e3
![Page 8: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/8.jpg)
Graph Isomorphism
• Formal definition:– Simple graphs G1=(V1, E1) and G2=(V2, E2) are
isomorphic iff a bijection f:V1V2 such that a,bV1, a and b are adjacent in G1 iff f(a) and f(b) are adjacent in G2.
– f is the “renaming” function that makes the two graphs identical.
– Definition can easily be extended to other types of graphs.
![Page 9: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/9.jpg)
Graph Invariants under Isomorphism
Necessary but not sufficient conditions for G1=(V1, E1) to be isomorphic to G2=(V2, E2):
– |V1|=|V2|, |E1|=|E2|.– The number of vertices with degree n is the
same in both graphs.– For every proper subgraph g of one graph, there
is a proper subgraph of the other graph that is isomorphic to g.
![Page 10: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/10.jpg)
Isomorphism Example
• If isomorphic, label the 2nd graph to show the isomorphism, else identify difference.
a
b
cd
ef
b
d
a
efc
![Page 11: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/11.jpg)
Are These Isomorphic?
• If isomorphic, label the 2nd graph to show the isomorphism, else identify difference.
ab
c
d
e
* Same # ofvertices
* Same # ofedges
* Different# of vertices of
degree 2! (1 vs 3)Example 11: a more general solution
![Page 12: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/12.jpg)
§8.4: Connectivity
• In an undirected graph, a path of length n from u to v is a sequence of adjacent edges going from vertex u to vertex v.
• A path is a circuit if u=v.
• A path traverses the vertices along it.
• A path or circuit is simple if it contains no edge more than once.
![Page 13: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/13.jpg)
Paths in Directed Graphs
• Same as in undirected graphs, but the path must go in the direction of the arrows.
![Page 14: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/14.jpg)
Small world• Human relationship as a graph• Stanley Milgram’s “small world” experiment
– Stanley Milgram: The Small World Problem, Psychology Today, 1(1), 60-67 (1967)
– range = 2-10, median = 5• http://backspaces.net/PLaw/
• Oracle of Bacon– http://www.cs.virginia.edu/oracle/
• The Erdös Number Project– http://www.oakland.edu/enp/
• Tables in p. 569
![Page 15: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/15.jpg)
Connectedness
• An undirected graph is connected iff there is a path between every pair of distinct vertices in the graph.
• Theorem: There is a simple path between any pair of vertices in a connected undirected graph.
• A component is a maximal connected subgraph.– Connected component, connected subgraph
• A cut vertex or cut edge (bridge) separates 1 connected component into 2 if removed.
![Page 16: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/16.jpg)
Directed Connectedness
• A directed graph is strongly connected iff there is a directed path from a to b for any two vertices a and b.
• It is weakly connected iff the underlying undirected graph (i.e., with edge directions removed) is connected.
• Note strongly implies weakly but not vice-versa.
![Page 17: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/17.jpg)
Paths & Isomorphism
• Note that connectedness, and the existence of a circuit or simple circuit of length k are graph invariants with respect to isomorphism.
• Examples 12, 13
![Page 18: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/18.jpg)
Counting Paths w Adjacency Matrices
• Let A be the adjacency matrix of graph G.
• The number of paths of length k from vi to vj is equal to (Ak)i,j. (The notation (M)i,j denotes mi,j where [mi,j] = M.)
ab
c
d
0001
0011
0101
1110a
b
c
d
a b c d
0001
0011
0101
1110
ab c
![Page 19: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/19.jpg)
§8.5: Euler & Hamilton Paths
• An Euler circuit in a graph G is a simple circuit containing every edge of G.
• An Euler path in G is a simple path containing every edge of G.
• A Hamilton circuit is a circuit that traverses each vertex in G exactly once. – initial vertex is twice
• A Hamilton path is a path that traverses each vertex in G exactly once.
![Page 20: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/20.jpg)
Euler path
start finish
1 2
3
4
5
6
![Page 21: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/21.jpg)
Euler circuit
1 2
3
4
5
67start
![Page 22: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/22.jpg)
Hamilton Circuits and Paths
• Gray circle is the starting vertex; follow the red lines
• removing one edge (dashed line) from a Hamilton circuit makes a Hamilton path
- In some graphs, there are only Hamilton paths, not Hamilton circuits
![Page 23: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/23.jpg)
Module #19:Tree
Rosen 5th ed., ch. 9
![Page 24: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/24.jpg)
Trees Uses
• Trees are, by far, the most algorithmically and theoretically interesting structure in computer science, since they are used to solve a wide range of problems
• Even algorithms themselves are depicted as trees, as can be seen in decision trees and (some) flowcharts (the ones that aren't cyclic)
• The usefulness of trees are enormous, and we'll only touch the surface
![Page 25: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/25.jpg)
Definition• A tree is a connected graph with no cycles • E.g., tournament brackets, family trees,
organizational charts
• A forest is a graph whose components are trees.
![Page 26: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/26.jpg)
Trees: Leaves & Internal Vertices
• In the following tree the red vertices are leaves. The other vertices are internal vertices.
![Page 27: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/27.jpg)
Rooted Trees
• Sometimes it is useful to distinguish one vertex of a tree and call it the root of the tree. For instance we might, for whatever reasons, take the tree above and declare the red vertex to be its root. In that case we often redraw the tree to let it all “hang down” from the root
![Page 28: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/28.jpg)
Rooted Directed Trees• It is sometimes useful to turn a rooted tree into a rooted
directed tree T′ by directing every edge away from the root.
![Page 29: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/29.jpg)
Rooted Trees: Terminology• Some terminology is suggested by family trees. The level
of a vertex is the length of the path from it to the root. (The level of the root is 0.) The height of the tree is the length of the longest path from a leaf to the root.
• If there is a directed edge in T′ from a to b, then a is the parent of b and b is a child of a.
• If there are directed edges in T′ from a to b and c, then b and c are siblings.
• If there is a directed path from a to b, then a is an ancestor of b and b is a descendant of a.
• A subtree is a vertex and all its descendants
“Directed” can be omitted in undirected graphs, but …
![Page 30: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/30.jpg)
(Rooted) Trees: Binary & m-ary
• A directed tree is binary if no vertex has outdegree over 2. • A directed tree m-ary if no vertex has outdegree over m
• It is more common to call a tree binary if no vertex has degree over 3.
• In general a tree is m-ary if no vertex has degree over m+1.
• In a rooted binary tree, one can describe each child vertex as the left child or right child of its parent.
Left subtree, right subtree
![Page 31: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/31.jpg)
Full, balanced
• A rooted tree is a full m-ary tree if every internal vertex has exactly m children.
• A rooted m-ary tree of height h is balanced if all leaves are at levels h or h-1
• What is a full, balanced m-ary tree?
![Page 32: Module #19: Graph Theory: part II](https://reader036.fdocuments.us/reader036/viewer/2022062308/56812ab7550346895d8e7c7d/html5/thumbnails/32.jpg)
Final exam• Slides • Chapter 5
– Sections 1,2,3
• Chapter 6– Sections 1,2,3– 6.2 Theorem 6 is excluded
• Chapter 7– Sections 1,2,3,4,5,6
• Chapter 8– Sections 1,2,3,4,5
• Chapter 9– Section 1
Chs 8,9 에서 O,X 문제 혹은 증명 문제가 나올 수 있음 , 단 8.5 제외