Download presentation
Presentation is loading. Please wait.
Published byAdelia Nash Modified over 9 years ago
2
Module #19: Graph Theory: part II Rosen 5 th ed., chs. 8-9
3
§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.
4
Adjacency Lists A table with 1 row per vertex, listing its adjacent vertices. a b d c f e
5
Directed Adjacency Lists 1 row per node, listing the terminal nodes of each edge incident from that node. nodeTerminal nodes 03 10, 2, 4 21 3 40,2
6
Adjacency Matrices Matrix A=[a ij ], where a ij is 1 if {v i, v j } is an edge of G, 0 otherwise. a b c d a b c d abcd
7
Adjacency Matrices for pseudo graph Matrix A=[a ij ], where a ij is the number of edges that are associated to {v i, v j } a b c d abcd a b c d
8
Incidence matrices Matrix M=[m ij ], where m ij is 1 when edge e j is incident with v i, 0 otherwise v1 v2 v3 v4 e1e2e3e4 v1 v4 v3 v2 e5 e1 e2 e5 e4 e3
9
Graph Isomorphism Formal definition: –Simple graphs G 1 =(V 1, E 1 ) and G 2 =(V 2, E 2 ) are isomorphic iff a bijection f:V 1 V 2 such that a,b V 1, a and b are adjacent in G 1 iff f(a) and f(b) are adjacent in G 2. –f is the “renaming” function that makes the two graphs identical. –Definition can easily be extended to other types of graphs.
10
Graph Invariants under Isomorphism Necessary but not sufficient conditions for G 1 =(V 1, E 1 ) to be isomorphic to G 2 =(V 2, E 2 ): –|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.
11
Isomorphism Example If isomorphic, label the 2nd graph to show the isomorphism, else identify difference. a b c d e f b d a e f c
12
Are These Isomorphic? If isomorphic, label the 2nd graph to show the isomorphism, else identify difference. a b c d e * Same # of vertices * Same # of edges * Different # of vertices of degree 2! (1 vs 3) Example 11: a more general solution
13
§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.
14
Paths in Directed Graphs Same as in undirected graphs, but the path must go in the direction of the arrows.
15
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
16
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.
17
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.
18
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
19
Counting Paths w Adjacency Matrices Let A be the adjacency matrix of graph G. The number of paths of length k from v i to v j is equal to (A k ) i,j. (The notation (M) i,j denotes m i,j where [m i,j ] = M.) a b c d a b c d abcd a b c
20
§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.
21
Euler path startfinish 12 3 4 5 6
22
Euler circuit 12 3 4 5 6 7 start
23
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
24
Module #19: Tree Rosen 5 th ed., ch. 9
25
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
26
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.
27
Trees: Leaves & Internal Vertices In the following tree the red vertices are leaves. The other vertices are internal vertices.
28
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
29
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.
30
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 …
31
(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
32
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?
33
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 제외
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.