Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]

Similar presentations


Presentation on theme: "Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]"— Presentation transcript:

1 Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]
[O2 Proof Techniques] [O3 Basic Analysis Techniques]

2 What is a Graph? [O1] A graph G = (V, E) consists of
V, the set of vertices (nodes, points), and E, the set of edges (lines) Undirected graphs are graphs where edges have no direction (unordered pairs of V). Example: V = {a, b, c, d, e} E = {{a,b}, {a, c}, {c, d}, {c, e}, {d, e}} Directed graphs are graphs where edges have directions, i.e., E consists of ordered pairs of V V = {u, x, y, z} E = {(x, y), (x, z), (y, u), (z, x), (z, u)} a b c d e z x y u

3 Simple Graphs and Multigraphs
Simple graphs - at most one edge between any pair of vertices, no self-loop. Unless otherwise stated, a “graph” means a simple graph. Multi-graphs - having multiple edges between the same (ordered) pair of vertices, or even with self-loops. Examples: Multiple roads between same pair of cities If x, y are two vertices, and e = {x, y} is in E, then x and y are adjacent e is incident with x and y x and y are the endpoints of e Degree (v) = number of edges incident with vertex v deg (y)=2, deg (u)=2, deg (x)=3, deg (z)=5? z x y u

4 Graph properties: Degrees
By pigeon hole principle, given any simple graph, there exist two vertices with the same degree. For an undirected graph G = (V, E): e.g. sum of degrees = = 12, |E| = 6 Proof: every edge is counted twice in counting degrees. Fact: Any undirected graph has an even number of odd-degree vertices (as the sum of degrees is even) For a directed graph G = (V, E): z x y u

5 Some Special Graphs Complete graphs (Kn) Cycle graphs (Cn) |V| = n
|E| = Cn,2 = n(n-1)/2 Degree = n-1 |V| = n, |E| = n Degree = 2

6 Some Special Graphs Star graphs (Sn) Wheel graphs (Wn)
|V| = n+1, |E| = n Degree =1 or n |V| = n+1, |E| = 2n Degree = 3 or n

7 Graph Operations A graph H = (V’, E’) is a subgraph of G = (V, E) if V’V, E’  E. The complement of G, denoted G, is the subgraph of Kn consisting of all the edges that are not in G. V’=V G H G The union of two graphs G1 = (V1, E1) and G2 = (V2, E2) is G1  G2 = (V1  V2, E1  E2) G1 G2 G1  G2 a b c d e

8 Graph Isomorphism A graph G = (V, E) consists of
x y z w A graph G = (V, E) consists of V = the set of vertices E = the set of edges (relation of V) Directed graph if edges are directed. Are these two graphs “the same”? Although they look different, they represent the same adjacency relationships, i.e., set of ordered pairs Example: f(a) = x, f(b) = w, f(c) = z, f(d) = y Two graphs G1 = (V1, E1) and G2 = (V2, E2) are isomorphic if there is a bijection f: V1  V2 such that (u, v)  E1 if and only if (f(u), f(v))  E2. a b c d

9 How to Determine Isomorphism?
Isomorphic graphs have certain invariants: Same number of vertices and edges Same set of vertex degrees If two graphs do not agree on these invariants, they must not be isomorphic. (but converse is not true!) Example: Isomorphism can be established if the function f can be found. However, in general, this is very difficult. Not isomorphic: how many degree-1 vertices?

10 Are these graphs identical?
b a b c d h a h g c c e g e d d g e f h b f f b e a c g h d f

11 Paths A path of length n from u to v in a graph G is a sequence of edges e1, e2, … en, such that e1 = (u, x1), e2 = (x1, x2), …, en = (xn-1, v). A path is simple if it does not contain the same vertex more than once. Example: Undirected graph: Directed graph: Not a path A path

12 Circuits A circuit of length n in a graph G is a sequence of edges e1, e2, … en, such that e1 = (x0, x1), e2 = (x1, x2), …, en = (xn-1, x0). A cycle is a circuit that does not contain the same vertex more than once. If there is a path between u and v, then there is a simple path between u and v: u  a  b  c  d  e  f  a  b  v is a path u  a  b  v is a simple path u v a b c d e f

13 Bipartite Graphs A graph is bipartite if the vertices V can be partitioned into two disjoint sets V1, V2 such that every edge connects a vertex in V1 to a vertex in V2 i.e. no edge within V1, no edge within V2 Number of edges ≤ |V1| |V2| A complete bipartite graph Km,n is a bipartite graph with all possible edges between a set of m vertices and a set of n vertices. It has mn edges. e.g. K3,4 has 12 edges

14 Bipartite Graphs Are these graphs bipartite?
A graph is bipartite iff the graph contains no odd cycles. Proof: (if) assign any vertex v in V1, assign all v’s neighbors in V2, assign all v’s neighbors’ neighbors in V1, … etc. Because the graph has no odd cycle, this can be done without conflicts. (only if) Assume G is bipartite, a cycle can only be formed after changing from V1 to V2 and from V2 toV1 even number of times. Thus no odd cycle.

15 Undirected Graph Connectivity
An undirected graph is connected if there is a path between any two vertices. If a graph is not connected, each connected subgraph is called a connected component of the graph. Example: (3 connected components)

16 Directed Graph Connectivity
A directed graph is strongly connected if there is a path from u to v and from v to u for any vertices u, v in the graph. Example: Strongly connected A directed graph is weakly connected if the underlying undirected graph (i.e. without considering directions) is connected. Example: Not strongly connected

17 Königsberg’s Bridge Problem
Is it possible to walk around all bridges once and only once, and return to the starting point? (circuit) What about a “path” which visits all bridges? Modeling the problem in terms of graphs: Is there a circuit containing every edge in this graph? Equivalent problem: Can you draw this graph without lifting the pen from paper and repeating any lines (edges)?)

18 Euler Paths and Circuits
An Euler circuit (or cycle) is a circuit containing every edge exactly once in the graph. (Draw the graph with a cycle) An Euler path is a path containing every edge exactly once in the graph. (Draw the graph with a broken line) Example: How to determine whether a graph has an Euler path/circuit?

19 Existence of Euler Paths/Circuits [O3]
? Some observations: Connectivity? ? Degree-1 vertex: Euler circuit? Degree-3? Degree-4? Vertices must have even degree for an Euler path, unless it is the start/end vertex. All vertices must have even degree for an Euler circuit. It can be proved that this is sufficient: A connected graph has an Euler circuit iff all vertices have even degrees A connected graph has an Euler path (but not an Euler circuit) iff exactly two vertices have odd degrees

20 Proof of Euler Circuit [O2]
Theorem: A connected graph has an Euler circuit iff all vertices have even degrees. Proof: Only if (=>) part (necessary condition): Each time an Euler circuit passes through a vertex u it “consumes” two edges incident with u (one “in” and one “out”). An Euler circuit covers all edges of G exactly once. If a vertex u is visited by the circuit x times, deg(u) = 2x.

21 Sufficient Condition for Euler Circuit
If (<=) part: (If G is a connected graph with all vertices of even degree, then G contains an Euler circuit) The proof is by construction. pick any arbitrary vertex u, follow any edge from u to another vertex v, again reach at another vertex through another unvisited edge from v (this is possible because the number of incident edges at any vertex is even) u v b The path will continue until it reaches vertex u again.

22 Proof for the Sufficient Condition
It is done if the closed path covers the whole graph, otherwise repeat the previous procedure at some vertex u’ in the closed path. A longer closed path will be formed by merging these closed paths by inserting the new closed path to the old closed path at vertex u’. u u’ This process will repeat until all edges are exhausted.


Download ppt "Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]"

Similar presentations


Ads by Google