Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

4. Graph Theory

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

4.

Graph Theory

Mr. Shubham Bakal


Graph
● 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 connected its
endpoints.
Basic Terminology
1. 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
(Terminology that describes the said to connect u and v.
vertices and edges of undirected 2. The set of all neighbors of a vertex v of G = (V,E),
graphs.) 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) = Uv∈AN(v).
3. 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).

What are the degrees and what are the neighborhoods of the
vertices in the graph G?
Soln :- In G, deg(a) = 2, deg(b) = deg(c) = deg(f ) = 4, deg(d) = 1,
deg(e) = 3, and deg(g) = 0.
The neighborhoods of these vertices are N(a)={b,f}, N(b)={a,c,e,f},
N(c)={b,d,e,f}, N(d)={c}, N(e)={b,c,f}, N(f)={a,b,c,e}, and N(g)=∅.

Find the Degrees and neighborhood of the vertices in the graph H


displayed at the left side of the side.
A vertex of degree zero is called isolated. It follows that an isolated vertex is not adjacent to any vertex. Vertex g in graph
G in Example 1 is isolated. A vertex is pendant if and only if it has degree one. Consequently, a pendant vertex is adjacent
to exactly one other vertex. Vertex d in graph G in Example 1 is pendant.

Example :- How many edges are there in a graph with 10 vertices each of degree six?

Solution: 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.

Defn :- 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.
Because the edges in graphs with directed edges Q. Find the in-degree and out-degree of each vertex in the graph
are ordered pairs, the definition of the degree of a G with directed edges shown in Figure 2.
vertex can be refined to reflect the number of edges
with this vertex as the initial vertex and as the Solution: The in-degrees in G are deg−(a) = 2, deg−(b) = 2, deg−
terminal vertex. (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.

Note :- Because each edge has an initial vertex and a terminal


vertex, the sum of the in-degrees and the sum of the
out-degrees of all vertices in a graph with directed edges are
the same. Both of these sums are the number of edges in the
graph.
Types of graphs
1. A graph with an infinite vertex set is called an
infinite Graph.
2. A graph with an finite vertex set is called an
finite Graph.
3. A graph in which each edge connects two
1. Infinite Graph. different vertices and where no two edges
connect the same pair of vertices is called a
2. Finite Graph. simple graph. Note that in a simple graph, each
edge is associated to an unordered pair of
3. Simple Graph. vertices, and no other edge is associated to this
same edge.
4. Multigraphs. 4. Graphs that may have multiple edges
connecting the same vertices are called
5. pseudographs. 5.
multigraphs.
Graphs that may include loops, and possibly
multiple edges connecting the same pair of
vertices or a vertex to itself, are sometimes
called pseudographs.
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.
That is, we can think of this set of edges as m
different copies of an edge {u,v}.
Refer Fig. 2 So far the graphs we have introduced
are undirected graphs.
1. 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.
2. When a directed graph has no loops and has
no multiple directed edges, it is called a
simple directed graph.
3. Directed graphs that may have multiple
directed edges from a vertex to a second
(possibly the same) vertex such graphs are
called as directed multigraphs.
When there are m directed edges, each
associated to an ordered pair of vertices (u,v),
we say that (u,v) is an edge of multiplicity m.
4. A graph with both directed and undirected
edges is called a mixed graph.
Refer Fig. 5 and Table 1
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
Representation adjacency lists, which specify the vertices that are
adjacent to each vertex of the graph.
E.g. Use adjacency lists to describe the simple graph
given in Figure 1.

E.g. 2 Represent the directed graph shown in Figure 2


by listing all the vertices that are the terminal vertices
of edges starting at each vertex of the graph.

←Ans
Use an adjacency matrix to represent the graph shown
in Figure 3.

Adjacency Matrices

Solution:We order the vertices as a,b,c,d.

E.g. Use an adjacency matrix to represent the


pseudograph shown in Figure 5.
Solution : - The adjacency matrix using the ordering of
vertices a,b,c,d
Incidence Matrices
Let G= (V,E)be an undirected graph.Suppose that
v1,v2,...,vn are the vertices and e1,e2,...,em 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],

E.g. Represent the graph shown in Figure 6 with an


incidence matrix.
When edges and vertices are removed from a graph,
without removing endpoints of any remaining edges, a

Sub graphs smaller graph is obtained. Such a graph is called a


subgraph of the original graph.

Defn : - 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≠ G.

Defn : - Let G = (V,E) be a simple graph.The subgraph


induced by a subset W of the vertex set V is the graph
(W,F), where the edge set F contains an edge in E if and
only if both endpoints of this edge are in W.

The graph G shown in Figure 15 is a subgraph of K5. If


we add the edge connecting c and e to G, we obtain
the subgraph induced by W ={a,b,c,e}.
Given a graph G = (V, E) and an edge e ∈ E, we can produce a
subgraph of G by removing the edge e. The resulting subgraph,
denoted by G−e, has the same vertex set V as G. Its edge set is E −e.
REMOVING Hence,
G−e = (V, E − {e}).
OR Similarly, if E’ is a subset of E , we can produce a subgraph of G by
ADDING removing the edges in E’ from the graph. The resulting subgraph has
the same vertex set V as G. Its edge set is E − E’.
EDGES OF A We can also add an edge e to a graph to produce a new larger graph

GRAPH. when this edge connects two vertices already in G.We denote by G +
e the new graph produced by adding a new edge e, connecting two
previously non incident vertices, to the graph G Hence,

G+e = (V, E ∪ {e}).


The vertex set of G +e is the same as the vertex set of G and the
edge set is the union of the edge set of G and the set {e}.
EDGE
Sometimes when we remove an edge from a graph,
we do not want to retain the endpoints of this edge as

CONTRACTIONS separate vertices in the resulting subgraph. In such a


case we perform an edge contraction which removes
an edge e with endpoints u and v and merges u and w
into a new single vertex w, and for each edge with u or
v as an endpoint replaces the edge with one with w as
endpoint in place of u or v and with the same second
endpoint.

REMOVING VERTICES FROM A GRAPH

When we remove a vertex v and all edges incident to it


from G = (V,E), we produce a subgraph, denoted by
G−v. Observe that G−v=(V −v , E), where E is the set of
edges of G not incident to v.
Two or more graphs can be combined in various ways.The new
graph that contains all the vertices and edges of these graphs
is called the union of the graphs.
GRAPH UNIONS Find the union of the graphs G1 and G2 shown in Figure 16(a).

Sol. :- The vertex set of the union G1 ∪ G2 is the union of the


two vertex sets, namely, {a,b,c,d,e,f}. The edge set of the union
is the union of the two edge sets. The union is displayed in
Figure 16(b).
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.As the path travels along its edges, it
Paths visits the vertices along this path, that is, the endpoints of
these edges.
Remark: There is considerable variation of terminology concerning the concepts defined in Definition 1. For instance, in
some books, the term walk is used instead of path, where a walk is defined to be an alternating sequence of vertices and
edges of a graph, v0,e1,v1,e2,...,vn−1,en,vn, where vi−1 and vi are the endpoints of ei for i = 1,2,...,n. When this terminology
is used, closed walk is used instead of circuit to indicate a walk that begins and ends at the same vertex, and trail is used
to denote a walk that has no repeated edge (replacing the term simple path). When this terminology is used, the
terminology path is often used for a trail with no repeated vertices, conflicting with the terminology in Definition 1. Because
of this variation in terminology, you will need to make sure which set of definitions are used in a particular book or article
when you read about traversing edges of a graph.
Connectedness in An undirected graph is called
Undirected Graphs 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 say that we
disconnect a graph when we
remove vertices or edges, or both,
to produce a disconnected
subgraph.
CONNECTED
A connected component of a graph G is a
connected subgraph of G that is not a proper
subgraph of another connected subgraph of
G.That is, a connected component of a graph G

COMPONENTS is a maximal connected subgraph of G. A


graph G that is not connected has two or more
connected components that are disjoint and
have G as their union.
Sometimes the removal from a graph of a Find the cut vertices and cut edges in the graph G1
vertex and all incident edges produces a shown in Figure 4.
subgraph with more connected
components. Such vertices are called cut
vertices(or articulation points). The
removal of a cut vertex from a connected Solution: The cut vertices of G1 are b, c, and e. The
graph produces a subgraph that is not removal of one of these vertices (and its adjacent
connected. Analogously, an edge whose edges) disconnects the graph. The cut edges are {a,b}
removal produces a graph with more
and {c,e}. Removing either one of these edges
connected components than in the original
graph is called a cut edge or bridge. disconnects G1.
In other words, when two simple graphs are isomorphic, there is a
one-to-one correspondence between vertices of the two graphs that
preserves the adjacency relationship. Isomorphism of simple graphs

Isomorphism of is an equivalence relation.

Graphs
Q. Show that the graphs G = (V,E) and H = (W,F), displayed in Figure 8,
are isomorphic.

Solution: 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. To see
that this correspondence preserves adjacency, 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.
Determining
1. Isomorphic simple graphs must have the same
number of vertices, because there is a

whether Two one-to-one correspondence between the sets of


vertices of the graphs.

Simple Graphs are 2. Isomorphic simple graphs also must have the
same number of edges, because the one-to-one
Isomorphic correspondence between vertices establishes a
one-to-one correspondence between edges.
3. In addition, the degrees of the vertices in
isomorphic simple graphs must be the same.
That is, a vertex v of degree d in G must
correspond to a vertex f(v) of degree d in H,
because a vertex w in G is adjacent to v if and
only if f(v) and f(w) are adjacent in H.
Q. Show that the graphs displayed in Figure Solution: Both G and H have five vertices and six
9 are not isomorphic. 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.

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.

Note :- However, when these invariants are the same,


it does not necessarily mean that the two graphs are
isomorphic. There are no useful sets of invariants
currently known that can be used to determine
whether simple graphs are isomorphic.
E.g. 1 Which of the undirected graphs in Figure 3 have an Euler
circuit? Of those that do not, which have an Euler path?

Euler Paths and Solution: The graph G1 has an Euler circuit, for example,
a,e,c,d,e,b,a. Neither of the graphs G2 or G3 has an Euler circuit.
Circuits However, G3 has an Euler path, namely, a,c,d,e,b,d,a,b. G2 does
not have an Euler path.
Euler Paths and
E.g. 2 Which of the directed graphs in Figure 4 have an
Euler circuit? Of those that do not, which have an Euler

Circuits path?

Solution: 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.
Hamilton Paths and
Q. Which of the simple graphs in Figure 10 have a Hamilton
circuit or, if not, a Hamilton path?

Circuits

Solution: G1 has a Hamilton circuit: a,b,c,d,e,a.There is no


Hamilton circuit in G2 (this can be seen by noting that any
circuit containing every vertex must contain the edge {a,b}
twice), but 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.
Planar Graphs
Note : - A graph may be planar even if it is usually drawn with
crossings, because it may be possible to draw it in a different
way without crossings.

Q. Is K4( shown in Figure 2 with two edges crossing) planar?

Solution: K4 is planar because it can be drawn without


crossings, as shown in Figure 3.
Is Q3, shown in Figure 4, planar?

Solution: Q3 is planar, because it can be drawn without any


Planar Graphs edges crossing, as shown in Figure 5.

APPLICATIONS OF PLANAR GRAPHS

1. Planarity of graphs plays an important role in the design


of electronic circuits. We can model a circuit with a graph
by representing components of the circuit by vertices and
connections between them by edges. We can print a
circuit on a single board with no connections crossing if
the graph representing the circuit is planar. When this
graph is not planar, we must turn to more expensive
options.
2. The planarity of graphs is also useful in the design of
road networks. Suppose we want to connect a group of
cities by roads. We can model a road network connecting
these cities using a simple graph with vertices
representing the cities and edges representing the
highways connecting them. We can built this road
network without using underpasses or overpasses if the
resulting graph is planar.

You might also like