Access Denied Your Page Is Blocked Due To A KIET IT Security Policy That Prohibits Access To Category Default

You might also like

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

Graph Theory

A graph is a formal mathematical representation of a network ("a collection of objects


connected in some fashion").
Each object in a graph is called a node (or vertex). Corresponding to the connections (or lack
thereof) in a network are edges (or links) in a graph. Each edge in a graph joins two distinct
nodes.
More formally, we define a graph G as an ordered pair G = (V,E) where
V is a set of nodes (vertices).
E is a set of edges (links).
Each edge is a pair of vertices. In other words, each element of E is a pair of elements of
V.
Example: The picture below represents the following graph:
I = {1,2,S,4,S,6]
E = {{1,2], {1,S], {2,S], {2,S], {S,4], {4,S], {4,6]]
0 = (I, E)


Neighborhood and Degree
Two vertices are called adjacent if they share a common edge, in which case the common edge
is said to join the two vertices. An edge and a vertex on that edge are called incident.
The 6-node graph in the figure shows examples of
adjacent and incident:
Nodes 4 and 6 are adjacent (as well as many other
pairs of nodes)
Nodes 1 and 3 are not adjacent (as well as many
other pairs of nodes)
Edge {2,5} is incident to node 2 and node 5.


The neighborhood of a vertex v in a graph G is the set of vertices adjacent to v. The
neighborhood is denoted N(v). The neighborhood does not include v itself. For example, in the
graph given above N(S) = {4,2,1] onJ N(6) = {4].
The degree of a vertex is the total number of vertices adjacent to the vertex. The degree of a
vertex v is denoted deg(v). We can equivalently define the degree of a vertex as the cardinality of
its neighborhood and say that for any vertex v, deg(v) = |N(v)|.
Each vertex in the graph given below has the following degree:
Vertex Degree

1 2
2 3
3 2
4 3
5 3
6 1

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.
Loops. An edge with identical endpoints is a loop:

Parallel edges. Two distinct edges that are associated with the same pair of vertices.

Undirected and Directed Graphs
Undirected graph: The edges of a graph are assumed to be unordered pairs of nodes.
Sometimes we say undirected graph to emphasize this point. In an undirected graph, we write
edges using curly braces to denote unordered pairs. For example, an undirected edge {2,3} from
vertex 2 to vertex 3 is the same thing as an undirected edge {3,2} from vertex 3 to vertex 2.
Types of undirected graphs:
1. Simple Graphs are graphs with no loops and where each edge connects two different
vertices and no two edges connect the same pair of vertices.

2. Multigraphs are graphs with no loops and have multiple edges connecting the same
vertices.

3. Pseudographs are graphs that include loops, and possibly multiple edges connecting the
same pair of vertices

Directed graph: In a directed graph, the two directions are counted as being distinct directed
edges. In an directed graph, we write edges using parentheses to denote ordered pairs. For
example, edge (2,3) is directed from 2 to 3 , which is different than the directed edge (3,2) from
3 to 2. Directed graphs are drawn with arrowheads on the links, as shown below:
Types of directed graphs:
1. Simple Graphs are graphs with no loops and where each directed edge connects two
different vertices and no two edges connect the same pair of vertices.

2. Directed Multigraphs are graphs that have multiple directed edges from a vertex to a
second (possibly the same) vertex.
In a directed graph it is important to distinguish between indegree (Jcg
-
(:)) and outdegree
(Jcg
+
(:)). Note that any directed edge has two distinct ends: a head (the end with an
arrowhead) and a tail. Each end is counted separately. The sum of head endpoints count toward
the indegree of a vertex and the sum of tail endpoints count toward the outdegree of a vertex.
The directed graph at right has the following degrees, indegrees, and outdegrees:

Vertex Degree Jcg
-
(:) Jcg
+
(:)
1 2 0 2
2 2 2 0
3 3 2 2
4 1 1 1



Mixed Graph: A graph with both directed and undirected edges.

The table below summarizes the different types of graphs and their properties.



Paths
A path in a graph represents a way to get from an origin to a
destination by traversing edges in the graph. For example, in the
undirected graph 0 = (I, E) drawn on the right, there are many
paths from node 6 to node 1. One such path is highlighted with red:
We write a path P as an ordered list of directed edges:
P = ((:
1
, :
2
), (:
2
, :
3
), . . . , (:
k
, :
k+1
)). The first vertex of the first
edge of a path is the origin and the second vertex of the last edge is
the destination. Both origin and destination are called endpoints of
the path.
Examples:
The red path above is ((6,4), (4,S), (S,2), (2,S), (S,1)); it is
a path in G from node 6 to node 1
The blue path on the right is ((6,4), (4,S), (S,1)); it is also a
path in G from node 6 to node 1
1
2
3
4
Paths in Undirected Graphs
Even in an undirected graph (such as the 6-node drawing above), we define a path as an ordered
list of directed edges: P = ((:
1
, :
2
), (:
2
, :
3
), . . . , (:
k
, :
k+1
)). The strict ordering of nodes in the
definition of a path corresponds to the order in which nodes and edges are traversed to get from
the origin to the destination.
Let us suppose we have an undirected graph 0 = (I, E) and an ordered list of directed edges
P = (c
1
, c
2
, . . . , c
k
). P is a path in 0 only if the following are true of every directed edge
c

= (:

, :
+1
) in P:
Directed edge c

in P corresponds to an undirected edge in E. In other words, {:

, :
+1
]
E.
If directed edge c

is not the last edge in P, then let c


+1
be the next edge in P. Directed
edge c
+1
starts with a tail node identical to the head node of c

. In other words, c

=
(:

, :
+1
) and c
+1
= (:
+1
, :
+2
).
The final requirement for P to be a path in 0 is that P cannot revisit any nodes. An ordered list of
directed edges that meets the above two requirements and that does revisit nodes is called a
walk.
Examples of walks that are not paths, based on the 6-node graph drawn above:
w = ((6,4), (4,S), (S,2), (2,S), (S,4), (4,S), (S,2), (2,S), (S,1)) is a walk from node 6 to
node 1
W = ((6,4), (4,6), (6,4), (4,5), (5,1), (1,5), (5,1)) is a walk from node 6 to node 1
A walk does not have to revisit nodes. Therefore, any path by definition is also a walk.

Paths in Directed graphs
A directed path is a path in a directed graph where the directions of
edges in the path match the directions of edges in the directed graph.
For example, suppose we consider this directed graph:
The blue lines highlight P = ((6,4), (4,S), (S,1)) which is a directed
path from 6 to 1 in directed graph 0.
As a counter-example, consider the same directed graph with a
different ordered list of edges that is not a directed path:
In this case, the red lines highlight
P = ((6,4), (4,S), (S,2), (2,S), (S,1)); the 4
th
edge of P goes the
"wrong way"; and so P is not a directed path in G. We instead refer to P as an undirected path
in a directed graph.

Length
The length of a path is the number of edges that it uses.
Examples: Consider the graph in the right
The length of the red path is 5
The length of the blue path is 3

When the edges of a graph are labeled with numbers, it is called a Weighted Graph and the
length of its path is the sum of the weights of the edges.



Distance
Given a graph 0, The distance J(x, y) between two vertices x and y is the length of the shortest
path from x to y, considering all possible paths in 0 from x to y.
The distance between any node and itself is 0. If there is no path from x to y then J(x, y) is
infinity.

Example. Find the distance between b to c.

Theorems on Degrees of Vertices

Theorem 1: The Handshaking Theorem

Let 0 = (I, E) be an undirected graph with c edges. Then

2c = Jcg(:)
v
.

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 2c = 6u.
Therefore, c = Su.



Theorem2: An undirected graph has an even number of vertices of odd degree.

Proof: Let I
1
and I
2
be the set of vertices of even degree and the set of vertices of odd degree,
respectively, in an undirected graph 0 = (I, E). Then

2c = Jcg(:)
v
= Jcg(:)
v
1
+ Jcg(:)
v
2


Because Jcg(:) is even for : I
1
, the first term in the right-hand side of the last equality is
even. Furthermore, the sum of the two terms on the right-hand side of the last equality is even,
because this sum is 2c. Hence, the second term in the sum is also even. Because all the terms in
this sum are odd, there must be an even number of such terms. Thus, there are an even number of
vertices of odd degree.


Theorem3: Let 0 = (I , E) be a graph with directed edges. Then

Jcg
-
(:)
v
= Jcg
+
(:)
v
= |E|

Example.


Special Graphs

1. Complete Graphs. The complete graph on n vertices, denoted by K
n
, is the simple graph
that contains exactly one edge between each pair of distinct vertices. The graphs K
n
, for
n = 1, 2, S, 4, S , 6, are displayed in the figure below.



2. Cycles. The cycle C
n
, n S , consists of n vertices :
1
, :
2
, . . . , :
n
and edges {:
1
, :
2
],
{:
2
, :
3
],, {:
n-1
, :
n
], and {:
n
, :
1
]. The cycles C
3
, C
4
, C
5
, and C
6
are displayed in the
figure below.


3. Wheels. We obtain the wheel w
n
when we add an additional vertex to the cycle
C
n
, n S, and connect this new vertex to each of the n vertices C
n
, by new edges. The
wheels w
3
, w
4
, w
5
, onJ w
6
are displayed in the figure below.


4. n-Cubes. The n-dimensional hypercube, or n-cube, denoted by
n
, is the graph that has
vertices representing the 2
n
bit strings of length n . Two vertices are adjacent if and only
if the bit strings that they represent differ in exactly one bit position.

5. A simple graph 0 is called bipartite if its vertex set I can be partitioned into two disjoint
sets I
1
and I
2
such that every edge in the graph connects a vertex in I
1
and a vertex in
I
2
(so that no edge in 0 connects either two vertices in I
1
or two vertices in I
2
). When
this condition holds, we call the pair (I
1
, I
2
) a bipartition of the vertex set I of 0.

C
6
is bipartite because its vertex set can be
partitioned into the two sets
I
1
= {I
1
, I
3
, I
5
} and I
2
= {I
2
, I
4
, I
6
},
and every edge of C
6
connects a vertex in
I
1
and a vertex in I
2
.




The graph K
3
is not bipartite. To verify this, note that if we divide
the vertex set of K
3
into two disjoint sets, one of the two sets must
contain two vertices. If the graph were bipartite, these two vertices
could not be connected by an edge, but in K
3
each vertex is
connected to every other vertex by an edge.



Exercise. Are the graphs G and H displayed in Figure below bipartite?


Subgraph

A subgraph of a graph 0 = (I, E) is a graph E = (w, F), where w H I and F H E . A
subgraph E of 0 is a proper subgraph of 0 if E = 0.




Union

The union of two simple graphs 0
1
= (I
1
, E
1
) and 0
2
= (I
2
, E
2
) is the simple graph with
vertex set I
1
I
2
, and edge set E
1
E
2
. The union of 0
1
and 0
2
is denoted by 0
1
0
2
.

Example. Find the union of the graphs 0
1
and 0
2
shown in (a) below.

Solution: The vertex set of the union 0
1
0
2
is the union of the two vertex sets, namely,
{o , b , c , J, c , ]. The edge set of the union is the union of the two edge sets. The union is
displayed in (b) below.

You might also like