Professional Documents
Culture Documents
MATH 1205
Discrete Mathematics
Definition (Graph)
A graph G = (V, E) consists of V , a nonempty set of vertices (or
nodes) and E, a set of edges. Each edge has either one or two
vertices associated with it, called its endpoints. An edge is said to
connect its endpoints.
Simple graph:
No edge connects a vertex to itself.
No two different edges connect the same pair of vertices.
V = {s, l, d, c, t, w, n}
E = {{s, l}, {s, d}, {l, d}, {d, c}, {c, t}, {c, n}, {c, w}, {t, n}, {n, w}}
Theorem
An undirected graph has an even number of vertices of odd degree.
When this condition holds, we call the pair (V1 , V2 ) a bipartition of the
vertex set V of G.
Complete bipartite graph, Km,n : the graph that has its vertex set
partitioned into two subsets of m and n vertices, respectively. There is
an edge between two vertices if and only if one vertex is in the first
subset and the other vertex is in the second subset.
Definition (Subgraph)
A subgraph of a graph G = (V, E) is a graph H = (W, F ), where
W V and F E. A subgraph H of G is a proper subgraph of G if
H 6= G.
Definition (Isomorphic)
The simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic if
there is a one-to-one and onto function f from V1 to V2 with the
property that a and b are adjacent in G1 if and only if f (a) and f (b) are
adjacent in G2 , for all a and b in V1 .
If we can show that a graph invariant in the two graphs is different, they
must not be isomorphic.
Example
Show that the following graphs are not isomorphic.
Solution: Both G and H have five vertices and six edges. However, H
has a vertex of degree one, namely, e, whereas G has no vertices of
degree one. It follows that G and H are not isomorphic.
Example
Show that the following graphs are not isomorphic.
Solution: Both the graphs G and H have the same numbers of vertices
and edges. The numbers of vertices of degree two and degree four are
the same. Note that because deg(a) = 2 in G, a must correspond to
either t, u, x, or y in H, because these are the vertices of degree two
in H. However, each of these four vertices in H is adjacent to another
vertex of degree two in H, which is not true for a in G.
When the graph is simple, we denote this path by its vertex sequence
x0 , x1 , . . . , xn .
A path or circuit is simple if it does not contain the same edge more
than once.
Definition (Connected)
An undirected graph is called connected if there is a path between
every pair of distinct vertices of the graph.
Theorem
There is a simple path between every pair of distinct vertices of a
connected undirected graph.
Proof.
Let u and v be two distinct vertices of the connected undirected graph
G = (V, E). Because G is connected, there is at least one path
between u and v. Let x0 , x1 , . . . , xn , where x0 = u and xn = v, be the
vertex sequence of a path of least length. This path of least length is
simple. It is because if it is not simple, we have xi = xj for some i and
j with 0 i < j. This means that there is a path from u and v of
shorter length with vertex sequence x0 , x1 , . . . , xi1 , xj , . . . , xn
obtained by deleting the edges corresponding to the vertex sequence
xi , . . . , xj1 .
Theorem
Let G be a (directed or undirected, simple or not) graph with adjacency
matrix A with respect to the ordering v1 , v2 , . . . , vn . The number of
different paths length r from vi to vj , where r is a positive integer,
equals the (i, j)th entry of Ar .
Proof.
Proof by mathematical induction.
Theorem
A connected multigraph with at least two vertices has an Euler circuit if
and only if each of its vertices has even degree.
Theorem
A connected multigraph has an Euler path but not an Euler circuit if
and only if it has exactly two vertices of odd degree.
There are no known simple necessary and sufficient criteria for the
existence of Hamilton circuits.
However, many theorems are known that give sufficient conditions for
the existence of Hamilton circuits.
Theorem (Diracs Theorem)
If G is a simple graph with n vertices with n 3 such that the degree of
every vertex in G is at least n/2, then G has a Hamilton circuit.
while z
/S
u := a vertex not in S with L(u) minimal
S := S {u}
for all vertices v not in S
if L(u) + w(u, v) < L(v) then L(v) := L(u) + w(u, v)
end
Example
Find the length of a shortest path between the vertices a and z in the
following weighted graph.
Example
S L(a) L(b) L(c) L(d) L(e) L(z)
0
{a} 4(a) 2(a)
{a, d} 4(a) 5(a, d)
{a, d, b} 7(a, b) 5(a, d)
{a, d, b, e} 7(a, b) 6(a, d, e)
{a, d, b, e, z}
Example
Find the length of a shortest path between the vertices a and z in the
following weighted graph.
Example (cont.)
Solution: The following table shows the changes of the variables in the
algorithm.
Theorem
Dijkstras algorithm uses O(n2 ) operations (additions and
comparisons) to find the length of a shortest path between two vertices
in a connected simple undirected weighted graph with n vertices.
Definition (Tree)
A tree is a connected undirected graph with no simple circuits.
Theorem
An undirected graph is a tree if and only if there is a unique simple
path between any two of its vertices.
Theorem
A tree with n vertices has n 1 edges.
Note that different choices of the root produce different rooted trees.
In a binary tree, if an internal vertex has two children, the first child is
called the left child and the second child is called the right child.
The tree rooted at the left child of a vertex is called the left subtree of
this vertex, and the tree rooted at the right child of a vertex is called the
right subtree of the vertex.
Proof.
When n = 1, a tree with n = 1 vertex has no edges. Thus, the theorem
is true when n = 1.
Assume every tree with k vertices has k 1 edges, where k is a
positive integer.
Suppose that a tree T has k + 1 vertices and that v is a leaf of T , and
let w be the parent of v. Removing from T the vertex v and the edge
connecting w to v produces a tree T 0 with k vertices, because the
resulting graph is still connected and has no simple circuits. By the
induction hypothesis, T 0 has k 1 edges. It follows that T has k edges
because it has one more edge than T 0 , the edge connecting v and
w.
The level of a vertex v in a rooted tree is the length of the unique path
from the root to this vertex. The level of the root is defined to be zero.
Theorem
A simple graph is connected if and only if it has a spanning tree.
Prims Algorithm
procedure Prim(G: weighted connected undirected graph with
n vertices)
T := a minimum-weight edge
for i := 1 to n 2
e := an edge of minimum weight incident to a vertex in T
and not forming a simple circuit in T if added to T .
T := T with e added
end
There may be more than one minimum spanning tree for a given
connected weighted simple graph.
Dr. Sun Pak Kiu (MATH 1205) Discrete Mathematics Graphs 50 / 52
Minimum Spanning Trees
Example
Use Prims algorithm to design a minimum-cost communication
network connecting all the computers represented by the following
graph.
Example
Solution:
Choice Edge Cost
1 {Chicago, Atlanta} 700
2 {Atlanta, New York} 800
3 {Chicago, San Francisco} 1200
4 {San Francisco, Denver} 900
Total: 3600