Lecture 11
Lecture 11
Graph Theory
Lecture - 11
06/15/2025
• a, b, c, b, d is a walk,
• a, b, d is a path,
• d , c, b, c, b, d is a closed walk, and
• b, d , c, b is a cycle.
• Note that b, c, b is also a cycle. This is a cycle of
length 2. Such cycles are not possible with undirected
graphs.
• A path or cycle in a directed graph is said to be
Hamiltonian if it visits every node in the graph. For
example, a, b, d , c is the only Hamiltonian path.
• A walk in a directed graph is said to be Eulerian if it
contains every edge. 6
Adjacency Matrix
06/15/2025
• Directedgraphs have adjacency matrices just like
undirected graphs. In the case of a directed graph
G =(V,E), the adjacency matrix AG = {aij} is
defined so that:
v u w
u
v 0 1 0
u 0 0 1
v w
w 1 0 0
06/15/2025
Incidence matrices
• Theincidence matrix of the directed graph has one
column for each node of the graph and one row for
each edge of the graph:
• If
an edge runs from node a to node b, the row
corresponding to that edge has -1 in column a and 1
in column b; all other entries in that row are 0.
06/15/2025
Example
Orientations and Tournaments
06/15/2025
• If
G is any graph, it can be converted to a
digraph by assigning a direction to each edge.
This process is called orientation .
• An oriented graph is a digraph that can be
obtained by orienting a graph; in other words, it
is a digraph that never contains both arcs xy
and yx for any pair of vertices x and y.
• If G has e edges, it can be oriented in 2e ways.
• An important practical problem is to orient
edges so that the resulting digraph is strongly
connected. Such an orientation will be called
strong. 11
06/15/2025
• A tournament is an orientation of a complete graph K n.
• Suppose that n players compete in a round-robin tournament
and that for every pair of players u and v, either u beats v or v
beats u.
• The results of a round-robin tournament can be represented with
a tournament graph. This is a directed graph in which the
vertices represent players, and the edges indicate the outcomes
of games. In particular, an edge from u to v indicates that player
u defeated player v. In a round-robin tournament, every pair of
players has a match. Thus, in a tournament graph there is either
an edge from u to v or an edge from v to u (but not both) for
every pair of distinct vertices u and v.
12
Finding a Hamiltonian Path
06/15/2025
in a Tournament Graph
• Inevery round-robin tournament, there exists a
ranking of the players such that each player lost to
the player one position higher. For example, in the
tournament corresponding to Figure in previous
slide, the ranking a > b > d > e > c
satisfies this criterion, because b lost to a, d lost to
b, e lost to d , and c lost to e.
• In
graph terms, proving the existence of such a
ranking amounts to proving that every tournament
graph has a Hamiltonian path.
13
Hamilton Cycles in K4
06/15/2025
• Edges in K4 = (N)(N - 1)/2
• Degree = N -1
• The number of Hamilton circuits in K N is
(N - 1) × (N - 2) ×zx ... × 3 × 2 × 1 = (N - 1)!
14
06/15/2025
Euler Circuit
An Euler circuit is a circuit that uses every edge
of a graph exactly once.
06/15/2025
Euler Circuit
• The graph of Figure (a) has an Euler path but no Euler circuit.
Note that two vertices A and B are of odd degrees 1 and 3
respectively. That means AB can be used to either arrive at
vertex A or leave vertex A but not for both. Thus an Euler
path can be found if we start either from vertex A or from B.
ABCDEB and BCDEBA are two Euler paths. Starting from any
vertex no Euler circuit can be found.
• The graph of Figure (b) has both Euler circuit and Euler path.
ABDEGFDCA is an Euler path and circuit. Note that all
vertices of even degree.
• Euler path but no circuit is possible in Figure (c). Note that all
vertices are not even degree and only two vertices are of odd
degree. The existence of Euler path and circuit depends on
the degree of vertices.
06/15/2025
Euler Circuit
• Show that the graph shown in Figure has no Eulerian circuit
but has a Eulerian trail.
• Eulerian Trail
between u and v.
06/15/2025
Euler Circuit
• Here deg (u) = deg (v) = 3 and deg (w) = 4, deg (x) = 4.
• Since u and v have only two vertices of odd degree, the
graph shown in Figure, does not contain Eulerian circuit, but
the path.
• b – a – c – d – g – f – e is an Eulerian path.
Example
06/15/2025
• Showthat the graphs in Figure below contain no
Eulerian circuit.
Example
06/15/2025
• Whichof the directed graphs in Figure have an
Euler circuit ? Of those that do not, which have an
Euler path ?
Hamiltonian Circuit
06/15/2025
•AHamiltonian circuit is a circuit that visits every
vertex once with no repeats.
• Whichof the graphs given in Figure below is
Hamiltonian circuit. Give the circuits on the graphs
that contain them.
Example
06/15/2025
• Give an example of a graph which is Hamiltonian but not
Eulerian and vice versa.
• Sol. The following graph shown in Figure below is
Hamiltonian but non-Eulerian.
•
The graph contains a Hamiltonian circuit
v1e 1v2e 2v3e 3v4e 4v5e 5v6e 6v1.
Since the degree of each vertex is not n even the graph is
non-Eulerian.
Example
06/15/2025
• Give an example of a graph which is Hamiltonian but not
Eulerian and vice versa.
• Sol. The graph shown in Figure below is Eulerian but not
Hamiltonian.
06/15/2025
• In building a barn one must first build the frame. The
outside walls must be erected before painting, and also
before any inside fittings are installed. The roof must also
be in place before the inside fittings are done. Let us
denote the tasks by:
a: build frame
b: build walls
c: fit roof
d: paint
e: do inside fittings.
• Answer: Then we have:
a must precede b, c, d, e;
b must precede d, e;
c must precede e.
• The unique source a serves as a start; a finish t has been 24
06/15/2025
Critical Paths
• It means a walk (in the directed sense) that covers
each arc exactly once.
Activity Digraph
• We shall set up a digraph, called an activity digraph, to
represent the precedence requirements of a compound
activity. The various tasks are represented by vertices.
• The digraph contains a path in which vertex a precedes
vertex b if and only if task a must
be completed before task b is started.
• For example, in Figure, tasks b and c
must precede task d, but tasks b and c are independent.
25
06/15/2025
• In constructing an activity digraph, it is not always
clear that there is a "starting point" s and an
"endpoint" or "finish" t; so, for convenience, we
formalize the following rules to ensure that the
digraph represents a task with a well-defined start
and finish:
If the digraph contains more than one source,
define a new vertex s; and add an arc sx to the
digraph whenever x is a source;
If the digraph contains more than one sink, define a
new vertex t: and add an arc xt to the digraph
whenever x is a sink.
We refer to this process as initializing the digraph.
26
Critical Path Analysis
06/15/2025
• A major consideration in scheduling a project is the
time needed to perform the various tasks.
• To represent this we associate with each vertex x a
weight w(x).
• Vertex weights are defined similarly to edge weights,
so that w is a mapping from the vertices of a digraph
to the nonnegative real numbers.
• w(x) is called the duration of x, and represents the
time needed to complete the task x.
• A digraph with a weight on the vertices or the arcs is
often called a network, and the network formed by
attaching a weight to an order requirement digraph
is called an activity network. 27
06/15/2025
• Now, critical path analysis, is defined for minimizing the total
time taken to carry out a project.
• We illustrate the technique using an example. Suppose there
are five tasks, called a, b, c, d and e. Task a must precede c;
c must precede e; b must precede d. The durations of the
task are:
a takes 13 minutes.
b takes 25 minutes.
c takes 15 minutes.
d takes 22 minutes.
e takes 27 minutes.
06/15/2025
In particular, there is a path sacet from s to t, with
every arc a heavy line. If any task or transition along
this path is delayed, the whole project will be held
up. Such a path is called a critical path.
30
06/15/2025
Example
• To paint a door. The tasks are as follows (time is shown in minutes):
• j. Remove old paint (75).
• k. Sand the door (30).
• l. Open can and stir paint (4).
• m. Prepare brushes (5).
• n. Clean up paint scrapings (4).
• p . Paint the door (30).
• q. Clean equipment and put brushes away (15).
• j must precede k. j and k must precede n. l, m and n must precede
p. p must precede q . A suitable digraph is shown in Figure
31
Example
06/15/2025