Notes 943 Unit4 Graphs
Notes 943 Unit4 Graphs
Definition
• 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.
• Finite Graph
• Infinite Graph
Simple Graph
• A graph in which each edge connects two different vertices and where no two
edges connect the same pair of vertices is called a simple graph.
• When there is an edge of a simple graph associated to {u, v},we can also say,
without possible confusion, that {u, v} is an edge of the graph.
Multigraphs
• A computer network may contain multiple links between data
centers, as shown in Figure.
• To model such networks we need graphs that have more than one
edge connecting the same pair of vertices. Graphs that may have
multiple edges connecting the same vertices are called multigraphs.
• When there are m different edges associated to the same unordered
pair of vertices {u, v}, we also say that {u, v} is an edge of multiplicity
m.
Loops
• Edges in a graph that connect a vertex to itself. Such edges are called
loops.
• Graphs that may include loops, and possibly multiple edges
connecting the same pair of vertices or a vertex to itself, are
sometimes called pseudographs.
Directed Graph
• A directed graph (or digraph) (V ,E) consists of a nonempty set of
vertices V and a set of directed edges (or arcs) E.
• Each directed edge is associated with an ordered pair of vertices.
• The directed edge associated with the ordered pair (u, v) is said to
start at u and end at v
• Directed graphs that may have multiple directed edges from a vertex to a second
(possibly the same) vertex are called directed multigraphs.
Basic Terms
• Two vertices u and v in an undirected graph G are called adjacent (or
neighbors) in G if u and v are endpoints of an edge e of G. Such an
edge e is called incident with the vertices u and v and e is said to
connect u and v.
• The set of all neighbors of a vertex v of G = (V ,E), denoted by N(v), is
called the neighborhood of v. If A is a subset of V , we denote by N(A)
the set of all vertices in G that are adjacent to at least one vertex in A.
So, N(A) = v∈A N(v).
• 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).
Example
• What are the degrees and what are the neighborhoods of the vertices
in the graph?
deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, and
deg(d ) = 5.
The neighborhoods of these vertices are
N(a) = {b, d, e},
N(b) = {a, b, c, d, e},
N(c) = {b},
N(d) = {a, b, e}, and
N(e) = {a, b, d}.
Basic Terms contd..
• A vertex of degree zero is called isolated. It follows that an isolated vertex
is not adjacent to any vertex.
• A vertex is pendant if and only if it has degree one.
Question: How many edges are there in a graph with 10 vertices each of
degree six?
Answer:
Because the sum of the degrees of the vertices is 6 ・ 10 = 60, it follows that
2m = 60 where m is the number of edges. Therefore, m = 30.
Contd..
• When (u, v) is an edge of the graph G with directed edges, u is said to
be adjacent to v and v is said to be adjacent from u.
• The vertex u is called the initial vertex of (u, v), and v is called the
terminal or end vertex of (u, v).
• The initial vertex and terminal vertex of a loop are the same.
• In a graph with directed edges the in-degree of a vertex v, denoted by
deg−(v), is the number of edges with v as their terminal vertex. The
out-degree of v, denoted by deg+ (v), is the number of edges with v as
their initial vertex.
• Loop at a vertex contributes 1 to both the in-degree and the out-
degree of this vertex.)
Example
Find the in-degree and out-degree of each vertex in following graph
deg−(a) = 2,
deg−(b) = 2,
deg−(c) = 3,
deg−(d) = 2,
deg−(e) = 3, and deg−(f ) = 0.
• A simple graph for which there is at least one pair of distinct vertex
not connected by an edge is called noncomplete.
Cycle
• A cycle Cn, n ≥ 3, consists of n vertices v1, v2, . . . , vn and edges {v1,
v2},{v2, v3}, . . . , {vn−1, vn}, and {vn, v1}.
• The cycles C3, C4, C5, and C6 are displayed in Figure:
• Ans : Yes
Another Example
Graph G is bipartite because its vertex set is the Graph H is not bipartite
union of two disjoint sets, {a, b, d}and {c, e, f, g},
and each edge connects a vertex in one of these
subsets to a vertex in the other subset
• A simple graph is bipartite if and only if it is possible to assign one of two different
colors to each vertex of the graph so that no two adjacent vertices are assigned the same
color.
Complete Bipartite Graphs
• A complete bipartite graph Km,n is a graph that has its vertex set
partitioned into two subsets of m and n vertices, respectively with 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.
• The complete bipartite graphs K2,3, K3,3, K3,5, and K2,6 are displayed in
Figure:
Representing Graphs
• One way to represent a graph without multiple edges is to list all the
edges of this graph.
• Another way to represent a graph with no multiple edges is to use
adjacency lists, which specify the vertices that are adjacent to each
vertex of the graph.
• Use adjacency lists to describe the simple graph given in Figure:
Adjacency List for Directed Graph
Adjacency Matrices
• Suppose that G = (V ,E) is a simple graph where |V| = n. Suppose that
the vertices of G are listed arbitrarily as v1, v2, . . . , vn.
• The adjacency matrix A of G, with respect to this listing of the
vertices, is the n x n zero–one matrix with 1 as its (i, j )th entry when
vi and vj are adjacent, and 0 as its (i, j )th entry when they are not
adjacent.
• In other words, if its adjacency matrix is A = [aij ], then
aij = 1 if{vi , vj } is an edge of G,
0 otherwise.
Example
• Use an adjacency matrix to represent the graph shown in Figure:
a b c d
a
b
c
d
Some Points
• There may be as many as n! different adjacency matrices for a graph with n
vertices.
• The adjacency matrix of a simple graph(undirected) is symmetric, that is, aij
= aji , because both of these entries are 1 when vi and vj are adjacent, and
both are 0 otherwise.
• As a simple graph has no loops, each entry aii, i = 1, 2, 3, . . . , n, is 0.
• When multiple edges connecting the same pair of vertices vi and vj, or
multiple loops at the same vertex, are present, the adjacency matrix is no
longer a zero–one matrix.
• The adjacency matrix for a directed graph does not have to be symmetric.
• In the adjacency matrix for a directed multigraph, aij equals the number of
edges that are associated to (vi , vj ).
Example
• Use an adjacency matrix to represent the pseudograph shown in
Figure:
a b c d
a
b
c
d
Incidence Matrices
• Another common way to represent graphs is to use incidence
matrices. Let G = (V ,E) be an undirected graph. Suppose that v1, v 2, . .
. , v n are the vertices and e 1, e 2, . . . , e m are the edges of G.
• Then the incidence matrix with respect to this ordering of V and E is
the n × m matrix
• M = [mij ], where
mij = 1 when edge ej is incident with vi ,
0 otherwise.
Example
• Represent the graph shown in Figure with an incidence matrix.
Example
• Incidence matrices can also be used to represent multiple edges and
loops.
Graph Isomorphism
• The simple graphs G1 = (V1,E1) and G2 = (V2,E2) are isomorphic if
there exists a one to-one and onto function f from V1 to V2 with the
property that a and b are adjacent in G1 iff f (a) and f (b) are adjacent
in G2, for all a and b in V1.
• Such a function f is called an isomorphism.
• Two simple graphs that are not isomorphic are called nonisomorphic.
• Two graphs G=(V,E) and H=(W,F) are isomorphic if there is a bijective
function f: V → W such that for all v, w V:
{v,w} E {f(v),f(w)} F
• Show that the graphs G = (V ,E) and H = (W,
F) are isomorphic.
• The function f with f (u1) = v1, f (u2) = v4, f
(u3) = v3, and f (u4) = v2 is a one-to-one
correspondence between V and W.
• Note that adjacent vertices in G are u1 and
u2, u1 and u3, u2 and u4, and u3 and u4,
and each of the pairs f (u1) = v1 and f (u2) =
v4, f (u1) = v1 and f (u3) = v3, f (u2) = v4
and f (u4) = v2, and f (u3) = v3 and f (u4) =
v2 consists of two adjacent vertices in H.
Isomorphic Or Not?
Check if the following graphs are isomorphic or not.
G1 u v w
x y z
G2 6 1 3
1 5
5 2
4 3 2 4 6
Thus, graphs G1 and G2 are isomorphic.
Contd..
G3
The graphs G and H both have eight vertices and 10 edges. They
also both have four vertices of degree two and four of degree
three. However, G and H are not isomorphic.
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.
Connectivity
• Many problems can be modeled with paths formed by traveling along
the edges of graphs.
• For instance, the problem of determining whether a message can be
sent between two computers using intermediate links can be studied
with a graph model.
• Informally, a path is a sequence of edges that begins at a vertex of a
graph and travels from vertex to vertex along edges of the graph.
• Let n be a nonnegative integer and G an undirected graph. A path of
length n from u to v in G is a sequence of n edges e1, . . . , en of G for
which there exists a sequence x0 = u, x1, . . . , xn−1, xn = v of vertices
such that ei has, for i = 1, . . . , n, the endpoints xi−1 and xi .
Contd..
• When the graph is simple, we denote this path by its vertex sequence
x0, x1, . . . , xn(because listing these vertices uniquely determines the
path).
• The path is a circuit if it begin and ends at the same vertex, that is, if u
= v, and has length greater than zero.
• The path or circuit is said to pass through the vertices x1, x2, . . . , xn−1
or traverse the edges e1, e2, . . . , en.
• A path or circuit is simple if it does not contain the same edge more
than once.
Example
• Ans: Yes No
• There is a simple path between every pair of distinct vertices of a
connected undirected graph.
CONNECTED COMPONENTS
• In graph theory, a connected component (or just component) of
an undirected graph is a subgraph in which any two vertices are connected to
each other by paths, and which is connected to no additional vertices in
the super graph.
• For example, the graph shown in the illustration has three connected
components.
• The cut vertices of G1 are b, c, and e. The removal of one of these vertices (and
its adjacent edges) disconnects the graph.
• The cut edges are {a, b} and {c, e}. Removing either one of these edges
disconnects G1
Vertex Cut
• Not all graphs have cut vertices.
• For example, the complete graph Kn, where n ≥ 3, has no cut vertices.
When you remove a vertex from Kn and all edges incident to it, the
resulting subgraph is the complete graph Kn−1, a connected graph.
• Connected graphs without cut vertices are called non separable graphs,
and can be thought of as more connected than those with a cut vertex.
• A subset V’ of the vertex set V of G = (V ,E) is a vertex cut, or separating
set, if G − V’ is disconnected.
1 1 2
Connectedness in Directed Graphs
• 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.
• A directed graph is weakly connected if there is a path between every
two vertices in the underlying undirected graph.
• Are the directed graphs G and H shown in Figure strongly connected?
Are they weakly connected?
• G is strongly connected because there is a path between any
two vertices in this directed graph .
• G is also weakly connected.
• The graph H is not strongly connected. There is no directed
path from a to b in this graph..
• H is weakly connected,
Paths and Isomorphism
• There are several ways that paths and circuits can help determine
whether two graphs are isomorphic.
• For example, the existence of a simple circuit of a particular length
can be used to show that two graphs are not isomorphic
The graph G1 has an Euler circuit, The graph G2 do not have an No Euler Circuit
for example, a, e, c, d, e, b, a. Euler circuit and euler path G3 has an Euler path, namely, a, c, d, e,
b, d, a, b.
Example
• Which of the directed graphs in Figure have an Euler circuit? Of those
that do not, which have an Euler path?
G1 contains exactly two vertices of odd degree(b and d), One such Euler path is d, a, b, c, d, b.
G2 has exactly two vertices of odd degree(b and d). One such Euler path is b, a, g, f, e, d, c, g, b, c, f, d.
G3 has no Euler path because it has six vertices of odd degree.
Hamilton Paths and Circuits
• A simple path in a graph G that passes through every vertex exactly
once is called a Hamilton path.
• A simple circuit in a graph G that passes through every vertex exactly
once is called a Hamilton circuit.
• That is, the simple path x0, x1, . . . , xn-1, xn in the graph G = (V ,E) is a
Hamilton path if V = {x0, x1, . . . , xn-1, xn } and xi ≠ xj for 0 ≤ i < j ≤ n, and
the simple circuit x0, x1, . . . , xn-1, xn, x0 (with n > 0) is a Hamilton
circuit if x0, x1, . . . , xn-1, xn is a Hamilton path.
Example
• Which of the simple graphs have a Hamilton circuit or, if not, a
Hamilton path?
Yes
No
Euler’s Formula
• A planar representation of a graph splits the plane into regions,
including an unbounded region.
• For instance, the planar representation of the graph shown in Figure
splits the plane into six regions
3 4
• What is the chromatic number of Kn?
• Ans: n