Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graph.

Similar presentations


Presentation on theme: "Graph."— Presentation transcript:

1 Graph

2 Outline Introduction to graph Is there a Eulerian trail, curcuit?
Isomorphism and planarity Shortest path problem

3 Graph G=(V,E), V is the set of vertices (nodes), E is the set of edges
Connected graph: where there is a path between any pair of distinct nodes A graph H is a subgraph of a G if all nodes and edges in H are also nodes and edges in G, i.e. H=(V’,E’) where A connected component of a graph G is a connected subgraph H of G such that no other connected subgraph of G containing H exists. Simple graph: no loop or parallel edges c a d b e f V={a, b, c, d, e, f} E={(a,b), (a,c), (a,d),(c,d), (b,d), (e,f)}

4 Walks in graph use every node edge
nontrivial & only repeated node is first/last closed walk trail path circuit Eulerian trail Eulerian circuit cycle no repeated edge no repeated vertices Hamiltonian

5 Does a graph has an Eulerian trail ?
C A Walk that go through all edges exactly once Proposition: in any graph, if a vertex x has an odd degree, then x cannot be an interior vertex (i.e., a vertex other than the starting or stopping point) in an Eulerian trail. For interior vertex: vs…e1xe2 … e3xe4 … ve A D B

6 Two theorems Graph G is called Eulerian if G has an Eulerian circuit (a closed walk that used every edge once and only once) Let G be a connected graph. G is Eulerian if and only if every node in G has even degree. 1 2 3 4 5 6 7 8 10 9

7 Construct Eulerian circuit
1. Find any curcuit C in graph G: starting at a certain node, walking along unused edges until getting back to original node. 2. Form a graph G’ by removing from G all edges in C and all vertices that have no edges left. 3. G’ consists of graphs where every node has even degree; Use same process 1 to determine Eulerian circuits for G’ or its components. 4. Piece together circuit C, and Eulerian curcuits found for G’, and get an Eulerian curcuit for G. 1 2 3 4 5 6 7 8 10 9

8 Eulerian Trail A connected graph G has an Eulerian trail if and only if G has exactly two nodes of odd degree. Moveover, the trail must begin and end at these two nodes If G has exactly two nodes of odd degree, after adding an edge connecting these two nodes, G has Eulerian circuit (by previous theorem). By removing added edge from circuit, we get a trail starting/ending at two nodes. If G has an Eulerian trail, it’s easy to see that the starting/ending nodes have odd degree, all other nodes have even degree.

9 Example 1 2 5 6 3 4

10 Outline Introduction to graph Is there a Eulerian trail, curcuit?
Isomorphism and planarity Shortest path problem

11 Isomorphic Graphs Formal Def. Graph G and H are called isomorphic if there is a one-to-one correspondence f, between the vertices in G to vertices in H, so that (u,v) is edge in G if and only if (f(u),f(v)) is edge in H. One can rearrange G to get H z 3 4 y x u 1 v 2 5 6 w

12 Are these two graphs isomorphic ?
ƒ(b) = 6 ƒ(c) = 8 ƒ(d) = 3 ƒ(g) = 5 ƒ(h) = 2 ƒ(i) = 4 ƒ(j) = 7

13 Checking isomorphism Two graphs that are isomorphic to one another must have Same number of nodes Same number of edges Same number of nodes of any given degree Same number of cycles Same number of cycles of any given size A pair of graphs satisfying above conditions are not necessarily isomorphic

14 Examples

15 Planar Graph Often we want to draw graphs as clean as possible, as few crossings as possible Can we connect three factories to three utilities without one service crossing over the other ? Three utilities Three factories

16 Definitions A graph is called planar if it can be drawn on a plane so that no edges cross. Such a drawing is called an embedding. Bipartite graph: the set of nodes can be partitioned into two sets so that every edge has one endpoint in one set, one endpoint in another set. Complete bipartite graph, Km,n, is a bipartite graph with nodes S1={a1,…,am} and S2={b1,…,bn}, and every nodes in S1 is connecting to every node in S2. Complete graph, Kn

17 Are these graphs planar?
K4 K3,2 Kn,2

18 Are these graphs planar?
K5 K3,3

19 Kuratowski’s Theorem A graph G is planar if and only if contains no “copies” of K3,3 or K5 as subgraphs A graph is planar if and only if it does not contain a subgraph that is a subdivision of K5 or K3,3. A subdivision of a graph results from inserting vertices into edges

20 Euler’s Formula for planar graph
Def: for a planar graph G embedded in the plane, a face of the graph is a region of the plane created by the drawing. Note that we have one unbounded region. K4 a d b b

21 Euler’s Formula for Planar Graph
Given an embedding of a graph, Removing any edge from a cycle decrease by 1 the num. of faces Every edge on a cycle borders exactly two faces For acyclic graph, # of faces is 1 For any connected planar graph G embedded in the plane with V vertices, E edges and F faces, it must be the case that V+F=E+2 (Euler’s formula)

22 Now why K3,3 is not planar ?

23 Outline Introduction to graph Is there a Eulerian trail, curcuit?
Isomorphism and planarity Shortest path problem

24 Shortest Path Problem Given a weighted graph and two vertices, u and v, find a path with minimum total weights between u and v Applications: driving direction, flight reservation etc

25 Dijkstra’s Algorithm Find the shortest paths from a single source to all other nodes All weights are non-negative Ideas: Maintain a set S of vertices whose final shortest-path weights from source have been decided Select from V-S a vertex with minimum shortest-path estimate, insert into S Updating shortest-path estimates for nodes in V-S Until S=V, all nodes have been determined

26 Idea of Dijkstra’s algorithm
9 6 2 7 b c 2 11 2 8 3 f 1 a 1 5 6 4 e d 3 5 5 S: nodes colored with red Label of vertex: the estimated or determined shortest-path weight Highlighted edges: used in the shortest paths

27 Practice Problem Find shortest path from f to all other nodes 7 b c 2
3 f 1 a 1 5 6 4 e d


Download ppt "Graph."

Similar presentations


Ads by Google