Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graphs.  Definition A simple graph G= (V, E) consists of vertices, V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements.

Similar presentations


Presentation on theme: "Graphs.  Definition A simple graph G= (V, E) consists of vertices, V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements."— Presentation transcript:

1 Graphs

2  Definition A simple graph G= (V, E) consists of vertices, V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements of V called edges.

3 - no arrows - no loops - can't have multiple edges joining vertices A simple graph

4  Definition A multigraph G=(V, E) consists of a set V of vertices, a set E of edges, and a function f from E to {{u, v} | u, v  V, u  v}. The edges e 1 and e 2 are called multiple or parallel edges if f(e 1 ) = f(e 2 ).

5 A multigraph  No loop is allowed. Multiple edges are allowed.

6  Definition A pseudograph G = (V, E) consists of a set V of vertices, a set E of edges, and a function f from E to {{u, v} | u, v  V}. An edge is a loop if f(e) = {u, v} for some v  V.

7

8  Definition ◦ A directed graph (V, E) consists of a set of a set of vertices V and a set of edges E that are ordered pairs of elements of V.

9  Loops, ordered pairs or the same element, are allowed.  Multiple edges in the same direction between two vertices are not allowed. A directed graph

10  Definition ◦ A directed multigraph G = (V, E) consists of a set V of vertices, a set E of edges, and a function f from E to {(u, v) | u, v  V}. The edges e 1 and e 2 are multiple edges if f(e 1 ) = f(e 2 ).

11 Loops, ordered pairs or the same element, are allowed. Multiple edges in the same direction between two vertices are allowed. A directed multigraph

12  Summary TypeEdgesMultiple edges allowed? Loops allowed? Simple graph UndirectedNo Multigraph Undirected YesNo PseudographUndirectedYes Directed graph DirectedNoYes Directed multigraph DirectedYes

13

14  There will be an edge (a, b) from team a to team b, if team a beats team b.

15 Adjacent: Two vertices u and v in an undirected graph G are called adjacent (or neighbours) if {u, v} is an edge of G. If e = {u, v} the edge e is called incident with u and v. The edge e is also said to connect u and v. The vertices u and v are called endpoints of the edge {u, v}. 15

16 a b c d e e1e1 e2e2 e3e3 e4e4 e5e5 e6e6 Vertex a is adjacent to b because there is an edge e 1 that connects vertices a and b. Edge e 4 is incident with vertices a and d. Edge e 4 connect vertices a and d. Edge e 6 connect vertices e and e.

17 The degree of a vertex in an undirected graph is the number of edges incident with it, except that a loop at a vertex contributes twice to the degree of that vertex. The degree of the vertex v is denoted by deg(v).

18 18  What are the degrees of the vertices in the following graph? b a c fe d g deg( a ) = deg( b ) = deg( c ) = deg( d ) = deg( e ) = deg( f ) = deg( g ) = 2 4 4 3 1 4 0 Vertex of degree zero is called isolated

19 19 Theorem: Suppose the vertices of graph G are v 1, v 2, …, v n, where n is a non-negative integer, then the total degree of G =deg(v 1 ) + deg(v 2 ) + …. + deg(v n ) = 2 (the number of edges of G).

20  Total number of edges: 4  Total degree: 1 + 1 + 1 + 5 = 8.  Handshaking theorem: 2 x 4 = 8.

21 21  How many edges are there in a graph with seven vertices each of degree four? The sum of the degrees of the vertices is 4x7 = 28. 2 e = 28 e = 14.

22  Three methods 1.Adjacency lists 2.Adjacency matrices 3.Incidence matrices

23  Adjacency lists b a c d e A simple graph UNABLE TO REPRESENT MULTIPLE-EDGES.

24 A directed graph

25  Adjacency matrices Suppose that G=(V, E) is a simple graph where |V|=n. Suppose that the vertices of G are listed arbitrary as v 1,v 2,..., v n. The adjacency matrix A of G is a n×n zero-one matrix with 1 as its (i, j)th entry when v i and v j are adjacent, and 0 as its entry when they are not adjacent.

26 a b c d G Adjacency matrix for G

27  Representing multigraph or pseudograph

28 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 a b c d e abcdeabcde Adjacency Matrix

29  Incidence Matrices  Let G=(V, E) be an undirected graph. Suppose that v 1, v 2,..., v n are the vertices and e 1, e 2,..., e m are the edges G. The incidence matrix of G is a nx m matrix M=[m ij ], where

30 Incidence Matrix

31  Definition  Let n be a nonnegative integer and G a directed multigraph. A path of length n from u to v in G is a sequence of edges e 1, e 2,..., e n of G such that f(e 1 )=(x 0, x 1 ), f(e 2 )=(x 1, x 2 ), f(e n )=(x n-1, x n ), where x 0 =u and x n =v.

32  Definition  When there are non multiple edges in the directed graph, this path is denoted by its vertex sequence x 0, x 1, x 2,..., x n.  A path of length greater than zero that begins and ends at the same vertex is called a circuit or cycle.  A path or circuit is simple if it does not contain the same edge more than once.

33 a, d, c, f, e is a simple path of length 4 since {a, d}, {d, c}, {c, f}, and {f, e} are all edges and no repeated edge. b, c, f, e, b is a circuit of length 4 since this path begins and ends at b. The path a, b, e, d, a, b is of length 5, is not simple since it contains the edge {a, b} twice. Is a, d, e, a, b a simple path?

34 Paths from v 0 to v 7 1. v 0 v 1 v 2 v 5 v 7 2. v 0 v 1 v 4 v 5 v 4 v 5 v 7 3. v 0 v 3 v 4 v 6 v 7 Which path(s) is (are) simple?

35

36  Definition  An undirected graph is called connected if there is a path between every pair of distinct vertices of the graph. G is connected, whereas H is not.

37  Theorem  There is a simple path between every pair of distinct vertices of a connected undirected graph.

38  Definition A directed graph is strongly connected if there is a path from a to b and from b to a whenever a and b are vertices in the graph.  Definition A directed graph is weakly connected if there is a path between any two vertices in the underlying undirected graph.

39 G is strongly connected because there is a path between any two vertices in this directed graph. The graph H is not strongly connected. There is no directed path from a to b in this graph. H is weakly connected since there is a path between any two vertices in the underlying undirected graph of H.

40  Questions  Can we travel along the edges of graph starting at a vertex and returning to it by traversing each edge of the graph exactly once?  Can we travel along the edges of a graph starting at a vertex and returning to it while visiting each vertex of the graph exactly once?

41  Definition  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 in G. Note: Both in Euler path and Euler circuit, each edge cannot be repeated more than once. If a graph has Euler circuit then it must has Euler path, the opposite could be false.

42  Example

43 Theorem 1 A connected multigraph has an Euler circuit if and only if each of its vertices has even degree. Theorem 2 A connected multigraph has an Euler path but not an Euler circuit if and only if it has exactly two vertices of odd degree.

44 For graph G1, the degree for each vertex in this graph is even, hence this graph contain Euler circuit. For graph G2, the degree for vertex e, a are odd, so there is no Euler circuit. G1 G2

45 G1 contains exactly two vertices of odd degree, b and d. Hence it has an Euler path that must have b and d as its end points. E.g.: b, c, d, a, b, d. G2 also contains exactly two vertices of odd degree, d and b. One of the Euler path is b, a, g, b, c, g, f, c, f, e, d.

46  Definition A path x 0, x 1,..., x n-1, x n in the graph G = (V, E) is called a Hamilton path if V={x 0, x 1,..., x n-1, x n } and x i  x j for 0  i  j  n  A circuit x 0, x 1,..., x n-1, x n, x 0 (with n > 1) in a graph G = (V,E) is called a Hamilton circuit ◦ if x 0, x 1,..., x n-1 Hamilton path.

47 Graph G1 has a Hamilton circuit: a, b, c, d, e, a. There is no Hamilton circuit in G2 because edge (a, b) will be always use twice. E.g.: d, c, b, a, b, d. G2 has Hamilton path, a, b, c, d.

48 A graph with a vertex of degree 1 cannot have a Hamilton circuit. If each vertex in a graph is adjacent to every other vertex there is always a Hamilton circuit.


Download ppt "Graphs.  Definition A simple graph G= (V, E) consists of vertices, V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements."

Similar presentations


Ads by Google