Mathematics

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

Mathematics | Graph Theory Basics – Set 1

A graph is a data structure that is defined by two components :


1. A node or a vertex.
2. An edge E or ordered pair is a connection between two nodes u,v that is
identified by unique pair(u,v). The pair (u,v) is ordered because (u,v) is not
same as (v,u) in case of directed graph.The edge may have a weight or is
set to one in case of unweighted graph.
Consider the given below graph,

To know about “Graph representation” click here

Applications:
Graph is a data structure which is used extensively in our real-life.
1. Social Network: Each user is represented as a node and all their
activities,suggestion and friend list are represented as an edge between the
nodes.
2. Google Maps: Various locations are represented as vertices or nodes and
the roads are represented as edges and graph theory is used to find
shortest path between two nodes.
3. Recommendations on e-commerce websites: The “Recommendations for
you” section on various e-commerce websites uses graph theory to
recommend items of similar type to user’s choice.
4. Graph theory is also used to study molecules in chemistry and physics.
For more applications click here

More on graphs:
Characteristics of graphs:
1. Adjacent node: A node ‘v’ is said to be adjacent node of node ‘u’ if and only
if there exists an edge between ‘u’ and ‘v’.
2. Degree of a node: In an undirected graph the number of nodes incident on a
node is the degree of the node.
In case of directed graph ,Indegree of the node is the number of arriving
edges to a node.
Outdegree of the node is the number of departing edges to a node.

3. Path: A path of length ‘n’ from node ‘u’ to node ‘v’ is defined as sequence
of n+1 nodes.
P(u,v)=(v0,v1,v2,v3…….vn)
A path is simple if all the nodes are distinct,exception is source and
destination are same.
4. Isolated node: A node with degree 0 is known as isolated node.Isolated
node can be found by Breadth first search(BFS). It finds its application
in LAN network in finding whether a system is connected or not.
Types of graphs:

1. Directed graph:
A graph in which the direction of the edge is defined to a particular node is a
directed graph.
 Directed Acyclic graph: It is a directed graph with no cycle.For a vertex
‘v’ in DAG there is no directed edge starting and ending with vertex ‘v’.
a) Application :Critical game analysis,expression tree evaluation,game
evaluation.
 Tree: A tree is just a restricted form of graph.That is, it is a DAG with a
restriction that a child can have only one parent.
2. Undirected graph:
A graph in which the direction of the edge is not defined.So if an edge exists
between node ‘u’ and ‘v’,then there is a path from node ‘u’ to ‘v’ and vice
versa.
 Connected graph: A graph is connected when there is a path between
every pair of vertices.In a connected graph there is no unreachable
node.
 Complete graph: A graph in which each pair of graph vertices is
connected by an edge.In other words,every node ‘u’ is adjacent to
every other node ‘v’ in graph ‘G’.A complete graph would have n(n-1)/2
edges.See below for proof.
 Biconnected graph: A connected graph which cannot be broken down
into any further pieces by deletion of any vertex.It is a graph with no
articulation point.

Proof for complete graph:


1. Consider a complete graph with n nodes. Each node is connected to other
n-1 nodes. Thus it becomes n * (n-1) edges. But this counts each edge
twice because this is a undirected graph so divide it by 2.
2. Thus it becomes n(n-1)/2.
Consider the given graph,
//Omit the repetitive edges
Edges on node A = (A,B),(A,C),(A,E),(A,C).
Edges on node B = (B,C),(B,D),(B,E).
Edges on node C = (C,D),(C,E).
Edges on node D = (D,E).
Edges on node E = EMPTY.https://en.wikipedia.org/wiki/Graph_theory
Total edges = 4+3+2+1+0=10 edges.
Number of node = 5.
Thus n(n-1)/2=10 edges.
Thus proven.

nother important concept in graph theory is the path, which is any route along
the edges of a graph. A path may follow a single edge directly between two
vertices, or it may follow multiple edges through multiple vertices. If there is a
path linking any two vertices in a graph, that graph is said to be connected. A
path that begins and ends at the same vertex without traversing any edge more
than once is called a circuit, or a closed path. A circuit that follows each edge
exactly once while visiting every vertex is known as an Eulerian circuit, and the
graph is called an Eulerian graph. An Eulerian graph is connected and, in
addition, all its vertices have even degree.

A graph is a collection of vertices, or nodes, and edges between some or all of the vertices. When there
exists a path that traverses each edge exactly once such that the path begins and ends at the same vertex, the
path is known as an Eulerian circuit, and the graph is known as an Eulerian graph. Eulerian refers to the
Swiss mathematician Leonhard Euler, who invented graph theory in the 18th century. Encyclopædia
Britannica, Inc.

In 1857 the Irish mathematician William Rowan Hamilton invented a puzzle


(the Icosian Game) that he later sold to a game manufacturer for £25. The
puzzle involved finding a special type of path, later known as a Hamiltonian
circuit, along the edges of a dodecahedron (a Platonic solid consisting of 12
pentagonal faces) that begins and ends at the same corner while passing
through each corner exactly once. The knight’s tour (see number game:
Chessboard problems) is another example of a recreational problem involving a
Hamiltonian circuit. Hamiltonian graphs have been more challenging to
characterize than Eulerian graphs, since the necessary and sufficient conditions
for the existence of a Hamiltonian circuit in a connected graph are still
unknown.

Hamiltonian circuitA directed graph in which the path begins and ends on the same vertex (a closed loop)
such that each vertex is visited exactly once is known as a Hamiltonian circuit. The 19th-century Irish
mathematician William Rowan Hamilton began the systematic mathematical study of such
graphs.Encyclopædia Britannica, Inc.

The histories of graph theory and topology are closely related, and the two
areas share many common problems and techniques. Euler referred to his work
on the Königsberg bridge problem as an example of geometria situs—the
“geometry of position”—while the development of topological ideas during the
second half of the 19th century became known as analysis situs—the “analysis
of position.” In 1750 Euler discovered the polyhedral formula V – E + F = 2
relating the number of vertices (V), edges (E), and faces (F) of a polyhedron (a
solid, like the dodecahedron mentioned above, whose faces are polygons). The
vertices and edges of a polyhedron form a graph on its surface, and this notion
led to consideration of graphs on other surfaces such as a torus (the surface of a
solid doughnut) and how they divide the surface into disklike faces. Euler’s
formula was soon generalized to surfaces as V – E + F = 2 – 2g,
where g denotes the genus, or number of “doughnut holes,” of the surface
(see Euler characteristic). Having considered a surface divided into polygons
by an embedded graph, mathematicians began to study ways of constructing
surfaces, and later more general spaces, by pasting polygons together. This was
the beginning of the field of combinatorial topology, which later, through the
work of the French mathematician Henri Poincaré and others, grew into what is
known as algebraic topology.
The connection between graph theory and topology led to a subfield
called topological graph theory. An important problem in this area
concerns planar graphs. These are graphs that can be drawn as dot-and-line
diagrams on a plane (or, equivalently, on a sphere) without any edges crossing
except at the vertices where they meet. Complete graphs with four or fewer
vertices are planar, but complete graphs with five vertices (K5) or more are not.
Nonplanar graphs cannot be drawn on a plane or on the surface of a sphere
without edges intersecting each other between the vertices. The use of diagrams
of dots and lines to represent graphs actually grew out of 19th-
century chemistry, where lettered vertices denoted individual atoms and
connecting lines denoted chemical bonds (with degree corresponding
to valence), in which planarity had important chemical consequences. The first
use, in this context, of the word graph is attributed to the 19th-century
Englishman James Sylvester, one of several mathematicians interested in
counting special types of diagrams representing molecules.

K5 is not a planar graph, because there does not exist any way to connect every vertex to every other vertex
with edges in the plane such that no edges intersect.Encyclopædia Britannica, Inc.
planar graph; nonplanar graphWith fewer than five vertices in a two-dimensional plane, a collection of
paths between vertices can be drawn in the plane such that no paths intersect. With five or more vertices in
a two-dimensional plane, a collection of nonintersecting paths between vertices cannot be drawn without
the use of a third dimension.Encyclopædia Britannica, Inc.

Another class of graphs is the collection of the complete bipartite graphs Km, n,
which consist of the simple graphs that can be partitioned into two independent
sets of m and n vertices such that there are no edges between vertices within
each set and every vertex in one set is connected by an edge to every vertex in
the other set. Like K5, the bipartite graph K3, 3 is not planar, disproving a claim
made in 1913 by the English recreational problemist Henry Dudeney to a
solution to the “gas-water-electricity” problem. In 1930 the Polish
mathematician Kazimierz Kuratowski proved that any nonplanar graph must
contain a certain type of copy of K5 or K3, 3. While K5 and K3, 3 cannot be
embedded in a sphere, they can be embedded in a torus. The graph-embedding
problem concerns the determination of surfaces in which a graph can be
embedded and thereby generalizes the planarity problem. It was not until the
late 1960s that the embedding problem for the complete graphs Kn was solved
for all n.


A bipartite map, such as K3, 3, consists of two sets of points in the two-dimensional plane such that every
vertex in one set (the set of red vertices) can be connected to every vertex in the other set (the set of blue
vertices) without any of the paths intersecting.Encyclopædia Britannica, Inc.
Dudeney puzzleThe English recreational problemist Henry Dudeney claimed to have a solution to a
problem that he posed in 1913 that required each of three houses to be connected to three separate utilities
such that no utility service pipes intersected. Dudeney's solution involved running a pipe through one of the
houses, which would not be considered a valid solution in graph theory. In a two-dimensional plane, a
collection of six vertices (shown here as the vertices in the homes and utilities) that can be split into two
completely separate sets of three vertices (that is, the vertices in the three homes and the vertices in the
three utilities) is designated a K3, 3 bipartite graph. The two parts of such graphs cannot be interconnected
within the two-dimensional plane without intersecting some paths.Encyclopædia Britannica, Inc.

Another problem of topological graph theory is the map-colouring problem.


This problem is an outgrowth of the well-known four-colour map problem,
which asks whether the countries on every map can be coloured by using just
four colours in such a way that countries sharing an edge have different
colours. Asked originally in the 1850s by Francis Guthrie, then a student at
University College London, this problem has a rich history filled with incorrect
attempts at its solution. In an equivalent graph-theoretic form, one may
translate this problem to ask whether the vertices of a planar graph can always
be coloured by using just four colours in such a way that vertices joined by an
edge have different colours. The result was finally proved in 1976 by using
computerized checking of nearly 2,000 special configurations. Interestingly, the
corresponding colouring problem concerning the number of colours required to
colour maps on surfaces of higher genus was completely solved a few years
earlier; for example, maps on a torus may require as many as seven colours.
This work confirmed that a formula of the English mathematician Percy
Heawood from 1890 correctly gives these colouring numbers for all surfaces
except the one-sided surface known as the Klein bottle, for which the correct
colouring number had been determined in 1934.
Among the current interests in graph theory are problems concerning
efficient algorithms for finding optimal paths (depending on different criteria)
in graphs. Two well-known examples are the Chinese postman problem (the
shortest path that visits each edge at least once), which was solved in the 1960s,
and the traveling salesman problem (the shortest path that begins and ends at
the same vertex and visits each edge exactly once), which continues to attract
the attention of many researchers because of its applications in routing data,
products, and people. Work on such problems is related to the field of linear
programming, which was founded in the mid-20th century by the American
mathematician George Dantzig.
Stephan C. Carlson

Prerequisite – Graph Theory Basics – Set 1


A graph is a structure amounting to a set of objects in which some pairs of the
objects are in some sense “related”. The objects of the graph correspond
to vertices and the relations between them correspond to edges. A graph is
depicted diagrammatically as a set of dots depicting vertices connected by lines
or curves depicting edges.
Formally,
“A graph consists of , a non-empty set of vertices (or
nodes) and , a set of edges. Each edge has either one or two vertices
associated with it, called its endpoints.”
Types of graph :There are several types of graphs distinguished on the basis of
edges, their direction, their weight etc.

1. 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. For example, Consider the following graph –
The above graph is a simple graph, since no vertex has a self-loop and no two
vertices have more than one edge connecting them.
The edges are denoted by the vertices that they connect- is the edge
connecting vertices and .
2. Multigraph – A graph in which multiple edges may connect the same pair of
vertices is called a multigraph.
Since there can be multiple edges between the same pair of vertices,
the multiplicity of edge tells the number of edges between two vertices.

The above graph is a multigraph since there are multiple edges between
and . The multiplicity of the edge is 2.
In some graphs, unlike the one’s shown above, the edges are directed. This
means that the relation between the objects is one-way only and not two-way.
The direction of the edges may be important in some applications.
Based on whether the edges are directed or not we can have directed
graphs and undirected graphs. This property can be extended to simple graphs
and multigraphs to get simple directed or undirected simple graphs and directed
or undirected multigraphs.
Basic graph Terminology :
In the above discussion some terms regarding graphs have already been
explained such as vertices, edges, directed and undirected edges etc. There are
more terms which describe properties of vertices and edges.
 Adjacency – In a graph two vertices and are said to be adjacent if
they are the endpoints of an edge. The edge is said to be
incident with the vertices.
In case the edge is directed, is said to be adjacent to and is said to
be adjacent from . Here, is said to be the intitial vertex and is said
to the terminal vertex.
 Degree – The degree of a vertex is the number of edges incident with it,
except the self-loop which contributes twice to the degree of the vertex.
Degree of a vertex is denoted as .
In case of directed graphs, the degree is further classified as in-
degree and out-degree. The in-degree of a vertex is the number of edges
with the given vertex as the terminal vertex. The out-degree of a vertex is
the number of edges with the given vertex as the initial vertex. In-degree is

denoted as and out-degree is denoted as .


For example in the directed graph shown above depicting flights between
cities, the in-degree of the vertex “Delhi” is 3 and its out-degree is also 3.
Note: If a vertex has zero degree, it is called isolated. If the degree is one then
it’s called pendant.
Handshaking Theorem :
What would one get if the degrees of all the vertices of a graph are added. In
case of an undirected graph, each edge contributes twice, once for its initial
vertex and second for its terminal vertex. So the sum of degrees is equal to twice
the number of edges. This fact is stated in the Handshaking Theorem.

Let be an undirected graph with edges. Then

In case G is a directed graph,

The handshaking theorem, for undirected graphs, has an interesting result –

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

Proof : Let and be the sets of vertices of even and odd degrees
respectively.
We know by the handshaking theorem that,
So,

The sum of degrees of vertices with even degrees is even. The LHS is also even,
which means that the sum of degrees of vertices with odd degrees must be even.
Thus, the number of vertices with odd degree is even.
Some special Simple Graphs :
1. Complete Graphs – A simple graph of vertices having exactly one edge
between each pair of vertices is called a complete graph. A complete graph of
vertices is denoted by . Total number of edges are n*(n-1)/2 with n vertices
in complete graph.

2. Cycles – Cycles are simple graphs with vertices and


edges . Cycle with
vertices is denoted as . Total number of edges are n with n vertices in cycle
graph.

3. Wheels – A wheel is just like a cycle, with one additional vertex which is
connected to every other vertex. Wheels of vertices with 1 addition vertex are
denoted by . Total number of edges are 2*(n-1) with n vertices in wheel
graph.

4. Hypercube – The Hypercube or n-cube is a graph with vertices each


represented by a n-bit string. The vertices which differ by at most 1-bit are
connected by edges. A hypercube of vertices is denoted by . Total
number of edges are n* with vertices in cube graph.

5. Bipartite Graphs – A simple graph is said to be bipartite if its vertex set


can be divided into two disjoint sets such that every edge in has its initial
vertex in the first set and the terminal vertex in the second set. Total number of
edges are (n*m) with (n+m) vertices in bipartite graph.

Theorem – 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 are assigned
the
same color.
A bipartite graph with and vertices in its two disjoint subsets is said to be
complete if there is an edge from every vertex in the first set to every vertex in
the second set, for a total of edges. A complete bipartite graph with
vertices in the first set and vertices in the second set is denoted as .
GATE CS Corner Questions
Practicing the following questions will help you test your knowledge. All questions
have been asked in GATE in previous years or in GATE Mock Tests. It is highly
recommended that you practice them.
1. GATE CS 2013, Question 25
2. GATE CS 2014 Set-1, Question 61
3. GATE CS 2006, Question 71
4. GATE CS 2002, Question 25
5. GATE CS 2004, Question 37
6. GATE CS 2014 Set-2, Question 13

Euler’s formula, Either of two important mathematical theorems of Leonhard


Euler. The first is a topological invariance (see topology) relating the number
of faces, vertices, and edges of any polyhedron. It is written F + V = E + 2,
where F is the number of faces, V the number of vertices, and E the number of
edges. A cube, for example, has 6 faces, 8 vertices, and 12 edges, and satisfies
this formula. The second formula, used in trigonometry, says eix =
cos x + isin x where e is the base of the natural logarithm and i is the square
root of −1 (see irrational number). When x is equal to π or 2π, the formula
yields two elegant expressions relating π, e, and i: eiπ = −1 and e2iπ = 1.

Graph Theory - Coloring


Advertisements

Previous Page

Next Page

Graph coloring is nothing but a simple way of labelling graph components such
as vertices, edges, and regions under some constraints. In a graph, no two
adjacent vertices, adjacent edges, or adjacent regions are colored with minimum
number of colors. This number is called the chromatic number and the graph is
called a properly colored graph.
While graph coloring, the constraints that are set on the graph are colors, order
of coloring, the way of assigning color, etc. A coloring is given to a vertex or a
particular region. Thus, the vertices or regions having same colors form
independent sets.

Vertex Coloring
Vertex coloring is an assignment of colors to the vertices of a graph ‘G’ such
that no two adjacent vertices have the same color. Simply put, no two vertices of
an edge should be of the same color.

Chromatic Number
The minimum number of colors required for vertex coloring of graph ‘G’ is called
as the chromatic number of G, denoted by X(G).
χ(G) = 1 if and only if 'G' is a null graph. If 'G' is not a null graph, then
χ(G) ≥ 2
Example

Note − A graph ‘G’ is said to be n-coverable if there is a vertex coloring that


uses at most n colors, i.e., X(G) ≤ n.
Region Coloring
Region coloring is an assignment of colors to the regions of a planar graph such
that no two adjacent regions have the same color. Two regions are said to be
adjacent if they have a common edge.
Example
Take a look at the following graph. The regions ‘aeb’ and ‘befc’ are adjacent, as
there is a common edge ‘be’ between those two regions.

Similarly the other regions are also coloured based on the adjacency. This
graph is coloured as follows −

Example
The chromatic number of Kn is
a) n
b) n–1
c) ⌊n 2 ⌋
d) ⌈n 2 ⌉
Consider this example with K4.

In the complete graph, each vertex is adjacent to remaining (n – 1) vertices.


Hence, each vertex requires a new color. Hence the chromatic number of K n = n.

Applications of Graph Coloring


Graph coloring is one of the most important concepts in graph theory. It is used
in many real-time applications of computer science such as −

 Clustering
 Data mining
 Image capturing
 Image segmentation
 Networking
 Resource allocation
 Processes scheduling

You might also like