0% found this document useful (0 votes)
30 views

Notes 943 Unit4 Graphs

Uploaded by

kewep39969
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Notes 943 Unit4 Graphs

Uploaded by

kewep39969
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

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.

The out-degrees are


deg+(a) = 4, deg+(b) = 1, deg+(c) = 2,
deg+(d) = 2, deg+(e) = 3, and deg+(f ) = 0.
Complete Graph
• A complete graph on n vertices, denoted by Kn, is a simple graph that
contains exactly one edge between each pair of distinct vertices. The
graphs Kn, for n = 1, 2, 3, 4, 5, 6, are displayed in Figure.

• 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:

• We obtain a wheel Wn when we add an additional vertex to a cycle Cn, for n ≥ 3,


and connect this new vertex to each of the n vertices in Cn, by new edges.
• The wheels W3, W4, W5, and W6 are displayed in Figure:
Bipartite Graph
• A simple graph G is called bipartite if its vertex set V can be
partitioned into two disjoint sets V1 and V2 such that every edge in
the graph connects a vertex in V1 and a vertex in V2(so that no edge
in G connects either two vertices in V1 or two vertices in V2). When
this condition holds, we call the pair (V1, V2) a bipartition of the
vertex set V of G.
• Is this bipartite graph?

• 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

G3 is not isomorphic to G1 and G2.

• It is often difficult to determine whether two simple


graphs are isomorphic because there are n! possible
one-to-one correspondences between the vertex sets
of two simple graphs with n vertices.
Some Points
• Isomorphic simple graphs must have the same number of vertices.
• Isomorphic simple graphs also must have the same number of edges.
• Degrees of the vertices in isomorphic simple graphs must be the same
• Show that the graphs displayed in Figure are not isomorphic

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
Contd..
• The number of vertices, the number of edges, and the number of vertices of each
degree are all invariants under isomorphism.
• If any of these quantities differ in two simple graphs, these graphs cannot be
isomorphic.
• However, when these invariants are the same, it does not necessarily mean that
the two graphs are isomorphic. E.g.

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

• a, d, c, f , e is a simple path of length 4,


• However, d, e, c, a is not a path.
• b, c, f , e, b is a circuit of length 4.
• path a, b, e, d, a, b, which is of length 5, is not simple because it
contains the edge {a, b} twice.
Path(In Directed Graph)
• Let n be a nonnegative integer and G a directed graph. A path of
length n from u to v in G is a sequence of edges e1, e2, . . . , en of G
such that e1 is associated with (x0, x1), e2 is associated with (x1, x2),
and so on, with en associated with (xn−1, xn), where x0 = u and xn = v.
• When there are no multiple edges in the directed graph, this path is
denoted by its vertex sequence x0, x1, x2, . . . , xn.
• 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 called simple if it does not contain the same edge
more than once.
Connectedness in Undirected Graphs
• When is there always a path between two vertices in the graph?
• An undirected graph is called connected if there is a path between every
pair of distinct vertices of the graph.
• An undirected graph that is not connected is called disconnected.
• We disconnect a graph when we remove vertices or edges, or both, to
produce a disconnected subgraph.
• Is this connected graph?

• 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.

• A vertex with no incident edges is itself a connected component.


• A graph G that is not connected has two or more connected components that
are disjoint and have G as their union.
Cut Vertices and Cut Edge
• Sometimes the removal from a graph of a vertex and all incident
edges produces a subgraph with more connected components. Such
vertices are called cut vertices (or articulation points).
• The removal of a cut vertex from a connected graph produces a
subgraph that is not connected.
• An edge whose removal produces a graph with more connected
components than in the original graph is called a cut edge or bridge.
• In a graph representing a computer network, a cut vertex and a cut
edge represent an essential router and an essential link that cannot
fail for all computers to be able to communicate.
Example
• Find the cut vertices and cut edges in the graph(G1):

• 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.

• {b,c,e} is the vertex cut of the figure


• edge cut of G: a set of edges E’ of G such that G − E’ is disconnected
K-Connected Graph
• We say that a graph is k-connected (or k-vertex-connected), if κ(G) ≥ k.
• κ(G) or vertex connectivity is the minimum number of vertices in a
vertex cut.
• The larger κ(G) is, the more connected we consider G to be.
• λ(G) (the edge connectivity of G): the size of a smallest edge cut of G
Find the vertex connectivity for each of the graphs

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

• Both G and H have six vertices and eight edges.


• Each has four vertices of degree three, and two vertices of
degree two.
• However, H has a simple circuit of length three, namely, v1,
v2, v6, v1, whereas G has no simple circuit of length three.
• So, G and H are not isomorphic.
Counting Paths Between Vertices
• Let G be a graph with adjacency matrix A with respect to the ordering
v1, v2, . . . , vn of the vertices of the graph (with directed or undirected
edges, with multiple edges and loops allowed).
• The number of different paths of length r from vi to vj , where r is a
positive integer, equals the (i, j )th entry of Ar .
• How many paths of length four are there from a to d in the simple
graph in Figure?
• The adjacency matrix of G (ordering the vertices as a, b, c, d) is
Euler Circuit and Path
• 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 of G.
Which of the undirected graphs in Figure have an Euler circuit? Of those that do
not, which have an Euler path?

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?

The graph H2 has an Euler circuit, for example, a, g, c, b, g, e, d, f, a.


Neither H1 nor H3 has an Euler circuit .
H3 has an Euler path, namely, c, a, b, c, d, b, but H1 does not .
Euler Circuit(in multigraph)
• A connected multigraph with at least two vertices has an Euler circuit
if and only if each of its vertices has even degree.
• A connected multigraph has an Euler path but not an Euler circuit if
and only if it has exactly two vertices of odd degree.
Which graphs shown in Figure 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?

G1 has a Hamilton circuit: a, b, c, d, e, a.


No Hamilton circuit in G2 (this can be seen by noting that any circuit containing every vertex must
contain the edge {a, b} twice),
G2 does have a Hamilton path, namely, a, b, c, d.
G3 has neither a Hamilton circuit nor a Hamilton path, because any path containing all vertices must
contain one of the edges {a, b}, {e, f }, and {c, d} more than once.
Some points
• A graph with a vertex of degree one cannot have a Hamilton circuit,
because in a Hamilton circuit, each vertex is incident with two edges
in the circuit.
• If a vertex in the graph has degree two, then both edges that are
incident with this vertex must be part of any Hamilton circuit.
• Show that neither graph displayed in Figure has a Hamilton circuit

• There is no Hamilton circuit in G because G has a vertex of degree one, namely, e.


• In H, the degrees of the vertices a, b, d, and e are all two, every edge incident with these vertices must
be part of any Hamilton circuit and no Hamilton circuit can exist in H, for any Hamilton circuit would
have to contain four edges incident with c, which is impossible.
Theorems
• DIRAC’S 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.

• ORE’S THEOREM If G is a simple graph with n vertices with n ≥ 3 such


that deg(u) + deg(v) ≥ n for every pair of nonadjacent vertices u and v
in G, then G has a Hamilton circuit.
Planar Graphs
• Consider the problem of joining three houses to each of three
separate utilities, as shown in Figure. Is it possible to join these
houses and utilities so that none of the connections cross?
Contd..
• A graph is called planar if it can be drawn in the plane without any
edges crossing (where a crossing of edges is the intersection of the
lines or arcs representing them at a point other than their common
endpoint).
• Such a drawing is called a planar representation of the graph.
• Example
Example
• Is the graph, shown in Figure , planar?

Yes

Is following graph , planar?

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

• Let G be a connected planar simple graph with e edges and v vertices.


Let r be the number of regions in a planar representation of G.
Then r = e − v + 2.
Example
• Suppose that a connected planar simple graph has 20 vertices, each
of degree 3. Into how many regions does a representation of this
planar graph split the plane?
Ans: 12
COROLLARY
• If G is a connected planar simple graph with e edges and v vertices,
where v ≥ 3, then e ≤ 3v − 6.
• If G is a connected planar simple graph, then G has a vertex of degree
not exceeding five.
• If a connected planar simple graph has e edges and v vertices with v ≥
3 and no circuits of length three, then e ≤ 2v − 4.
Graph Coloring
• Consider the problem of determining the least number of colors that can
be used to color a map so that adjacent regions never have the same color.

• A coloring of a simple graph is the assignment of a color to each vertex of


the graph so that no two adjacent vertices are assigned the same color.
• The chromatic number of a graph is the least number of colors needed for
a coloring of this graph. The chromatic number of a graph G is denoted by
χ(G).
• THE FOUR COLOR THEOREM: The chromatic number of a planar graph is
no greater than four.
Example
• What are the chromatic numbers of the graphs G and H shown in
Figure

3 4
• What is the chromatic number of Kn?
• Ans: n

You might also like