0% found this document useful (0 votes)
36 views9 pages

Elements of Graph Theory

lnote

Uploaded by

seyoum shimels
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views9 pages

Elements of Graph Theory

lnote

Uploaded by

seyoum shimels
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/300461065

Elements of Graph Theory

Chapter · January 2016


DOI: 10.1007/978-1-4899-7594-2_3

CITATIONS READS

2 3,546

2 authors, including:

Terry L. Friesz
Pennsylvania State University
235 PUBLICATIONS 8,208 CITATIONS

SEE PROFILE

All content following this page was uploaded by Terry L. Friesz on 13 September 2018.

The user has requested enhancement of the downloaded file.


Chapter 9
Elements of Graph Theory

Abstract Graphs are mathematical structures used to model and visualize relations
between certain objects. One of the first formulations of a graph theory problem was
the famous Konigsberg Problem solved by Leonhard Euler. He proposed a model
which reduced the problem to a schematic diagram and then concluded that the graph
needed to satisfy some general conditions for the problem to be solved affirmatively.
His studies highlighted the importance of understanding graphs and their properties,
which later lead to the creation of Graph Theory as a distinct mathematical discipline.
In this chapter we first introduce graphs through some illustrative examples and then
describe the basic elements of graphs, as well some important graph properties.
We then present special types of graphs like trees or networks, together with some
specific techniques, problems and algorithms.

Keywords Graph elements · Trees · Networks · Adjacency matrix · Cost matrix.

9.1 Brief Theoretical Background

A graph is a mathematical structure used to model pairwise relations between objects


from a certain collection. Before exploring specific properties, two illustrative exam-
ples are presented.
Example 1: The Konigsberg Bridge Problem (Eighteenth Century) In Fig. 9.1a are
sketched seven bridges (lines) which connect four islands (nodes). The question is
whether it possible to start on one island, walk over each of the seven bridges exactly
once and then return to the starting point?
Solution: The answer is no, and was found by Euler in 1736. His idea was to represent
the problem using 4 nodes (land masses) and 7 arcs (bridges). The graph should have
had exactly zero or two nodes of odd degree for a solution to exist.

O. Bagdasar, Concise Computer Mathematics, SpringerBriefs in Computer Science, 73


DOI: 10.1007/978-3-319-01751-8_9, © The Author(s) 2013
74 9 Elements of Graph Theory

Fig. 9.1 a Konigsberg bridges diagram; b Utility problem diagram

Example 2: The utility problem (Fig. 9.1b)


We have 3 houses and 3 utility companies - say, gas, electric, and water.
Is it possible to connect each utility to each house without any crossovers ?
Solution: The answer to the puzzle posed in Fig. 9.1b is NO.
The problem asks whether the complete bipartite graph K 3,3 is planar.
Basic elements of a graph G
• vertices: (nodes) V (G): the set of points
• edges: (arcs) E(G): lines connecting two vertices (directed or not)
• loops: edge that connects a vertex to itself
• order (degree) of a node: number of ‘incident’ edges.
• trail: sequence of arcs s.t. the end node of one arc is the start of the next.
• path: trail in which no node is passed through more than once
• cycle: path with an extra arc joining the final node to the initial node.
Example:

Special Graphs
• directed: Some edges have a direction.
• connected: It is possible to reach any node from any node
• complete: Simple, undirected, arcs between all nodes (Notation: K n )
• planar: It can be drawn so that the arcs do not cross
• simple: A graph with no loops or multiple arcs
• tree: Simple graph with no cycles
9.1 Brief Theoretical Background 75

• spanning tree (for a connected, undirected graph): subgraph that is a tree and
connects all the vertices together.
• network: A graph with weighted arcs (could be distance, cost, time).
Adjacency matrix: For a graph G with n vertices this is a n × n matrix s.t.
• non-diagonal entry ai j : number of edges from vertex i to vertex j
• diagonal entry aii : number of edges from vertex i to itself taken once for directed
graphs or twice for undirected graphs
Example: For the graph depicted in the previous page we have

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

Trees: classification and basic operations


• sequence: each node has 1 predecessor (or 0) and 1 successor (or 0)
• binary tree: each node has 1 predecessor (or 0) and 2 successors (or 1, 0)
• general tree: can have any number of successors
Standard operations on binary trees
The set of all trees with vertices in set X is denoted by BT R E E(X ).
For a given tree t ∈ BT R E E(X ) the following operations are defined
• ROOT: BT R E E(X ) → X (finds root)
• LEFT: BT R E E(X ) → BT R E E(X ) (finds left branch)
• RIGHT: BT R E E(X ) → BT R E E(X ) (finds right branch)
• ISEMPTYTREE: BT R E E(X ) → B (checks if tree is empty)

For tree t in (a) below, R O O T (t) = 6, L E F T (t) is tree (b) while R I G H T (t) = 2.
For t and r trees in BT R E E(X ) and s ∈ X one can define the function:
• MAKE: BT R E E(X ) × X × BT R E E(X ) → BT R E E(X ); (t, s, r ) → u
This output u is a tree with left branch t, root s and right branch r .
76 9 Elements of Graph Theory

Network problems
Networks can be represented using diagrams or a distance matrix.

Kruskal’s algorithm (minimum spanning tree)


• List the arcs in order of increasing weight
• Choose the arc with least weight
• Build a tree by working down the list choosing arcs provided they do not form a
cycle when added to the arcs already chosen
• Stop when no more arcs can be chosen.

Example: The segments selected when using Kruskal’s algorithm are


AD = 5, C E = 5, D F = 6, AB = 7, B E = 7 (not BC = 8, F E = 8, B D = 9)
and E G = 9. Segments F G = 11 and D E = 15 do not contribute.

Prims’s algorithm (minimum spanning tree)


• Choose a node
• Build a tree by choosing the minimum weight arc joining a node not yet chosen
to one that has. Add this arc and the end node to the tree
• Repeat the tree building process until all the nodes have been chosen.

Example: The segments selected when using Prim’s algorithm are


AD = 5, D F = 6, AB = 7, B E = 7, C E = 5 and E G = 9.
Shortest path problem: Minimal cost path between two vertices in a graph.
For large networks this is solved using computers and algorithms.
Example: The shortest path between A and G is A − D − F − G of cost 22.

9.2 Essential Problems


E 9.1. Prove that the sum of degrees of vertices in any finite graph is even.
E 9.2. Draw the graphs represented by the following adjacency matrices:

E 9.3. (a) Write down the information in E 9.2. as a relation R ⊂ X × X where


X = {a, b, c, d, e} i.e. as a set of ordered pairs.
9.2 Essential Problems 77

a b c d e
a 0 1 1 0 1
(i) b 1 0 1 1 1
c 1 1 0 0 0
d 0 1 0 0 1
e 1 1 0 1 0
a b c d e
a 0 1 0 0 1
(ii) b 1 0 1 1 0
c 0 1 1 1 0
d 0 1 1 0 1
e 1 0 0 1 1
a b c d e
a 0 1 0 0 1
(iii) b 0 0 0 0 0
c 0 0 0 0 0
d 0 0 0 0 1
e 0 0 0 0 0

(b) Which if any of the graphs in E 9.2. have the following properties: con-
nected, complete, directed, undirected, contain a cycle, contain a loop, is
a tree, contains a vertex which is even, contains a vertex which is odd?

E 9.4. In a group of people John likes Mary, Brian and Emma; Brian likes Mary and
Sue; Mary likes John and Sue; Emma likes Mary, John and Brian; Sue likes nobody.
Draw a graph showing who likes who.
E 9.5. Given the trees p and q from BTREE (BIRDS) defined below

Write down the following:


(i) LEFT(RIGHT(p));
(ii) ISEMPTYTREE(RIGHT(RIGHT(q)));
(iii) ROOT(LEFT(p));
(iv) MAKE(q, gull, q);
(v) MAKE (LEFT(p), ROOT(q), RIGHT(p));
(vi) MAKE(LEFT(LEFT(q)), ROOT(p), MAKE(q, puffin, RIGHT(p))).

E 9.6. Given the tree u from BTREE(S) defined below:


78 9 Elements of Graph Theory

Evaluate each of the following:


(i) LEFT(RIGHT(LEFT(u)));
(ii) RIGHT(LEFT(RIGHT(u)));
(iii) ROOT(u) + S ROOT(LEFT(RIGHT(u)).

9.3 Supplementary Problems

S 9.1. Show that a tree with n vertices has exactly n − 1 edges.


S 9.2. Prove that a complete graph with n nodes (K n ) has n(n − 1)/2 edges.
S 9.3. Show that every simple graph has two vertices of the same degree.
S 9.4. Using standard functions of BTREE(X), describe the functions.
(i) F that inputs a vertex and a binary tree, and replaces the root of the tree by the
input vertex.
(ii) G that inputs a binary tree and exchanges left and right subtrees. Give an example
in each case to illustrate what the function does.
S 9.5. Use standard functions of BTREE(X) to give a formal description of two
functions that input a binary tree and an item from X with the actions:
(i) R E PL – replaces the root of the left subtree by the input item.
(ii) R E PR – replaces the root of the right subtree by the input item.
S 9.6. Let a network be given by the distance matrix

A B C D E F G
A – 10 5 4 3 – –
B 10 – 8 9 7 – 2
C 5 8 – – 5 – –
D 4 9 – – 10 6 4
E 3 7 5 10 – 8 9
F – – – 6 8 – 11
G – 2 – 4 9 11 –

Find the minimum spanning tree using


(a) Kruskal’s algorithm (node and arc list, start with A).
(b) Prim’s algorithm (arc list).
(c) Find the shortest path between A and G.
9.4 Problem Answers 79

9.4 Problem Answers

Essential problems
E 9.1. Each arc contributes with 2 to the sum of degrees, therefore this sum should
be twice the number of arcs.
E 9.2. Draw the vertices {a, b, c, d, e} and directed segments from x to y if (x, y) = 1
in each of the adjacency matrices.
E 9.3. We write down the directed segments corresponding to each matrix
(i) G 1 = {(a, b), (a, c), (a, e), (b, a), (b, c), (b, d), (b, e), (c, a), (c, b), (d, b),
(d, e), (e, a), (e, b), (e, d)};
(ii) G 2 = {(a, b), (a, e), (b, a), (b, c), (b, d), (c, b), (c, c), (c, d)(d, b), (d, c),
(d, e)(e, a), (e, d), (e, e)};
(iii) G 3 = {(a, b), (a, e), (d, e)}.
E 9.4. The adjacency matrix is

John Mary Brian Emma Sue


John 0 1 1 1 0
Mary 1 0 0 0 1
Brian 0 1 0 0 1
Emma 1 1 1 0 0
Sue 0 0 0 0 0

Drawing the graph is straightforward.

E 9.5. (i) swan; (ii) False; (iii) hawk;


iv) Tree whose left branch is q, root is "gull" and right branch is q;
v) Tree whose left branch is LEFT(p), root is "rook" and right branch is
RIGHT(p);
vi) Tree whose left branch is empty, root is "eagle" and right branch is another
tree; this smaller tree has left branch q, root "puffin" and right branch
RIGHT(p).

E 9.6. (i) empty; (ii) empty; (iii) "adamwitch".


Supplementary Problems
S 9.1. A tree with n vertices has to be connected, but also to have no cycles. We can
imagine that initially there is just one node. To add another node to this one, one has
80 9 Elements of Graph Theory

to draw a segment. This step is repeated with the addition of any new node and in
the end one obtains exactly n − 1 edges.
S 9.2. In a complete graph each vertex is connected to all the others. This means that
in total we have n(n − 1) edges. As using this formula
  each node was counted twice,
the total number of edges has to be n(n − 1)/2 or n2 .
S 9.3. Let G be any finite simple graph with n = 2 vertices. The maximal degree of
any vertex in G is less than equal to n − 1. Also, if our graph G is not connected,
then the maximal degree is strictly less than n − 1.
Case 1: Assume that G is connected. We can not have a vertex of degree 0 in G, so
the set of vertex degrees is a subset of S = {1, 2, , n − 1}. Since the graph G has n
vertices, by pigeon-hole principle we can find two vertices of the same degree in G.

Case 2: Assume that G is not connected. G has no vertex of degree n − 1, so the


set of vertex degrees is a subset of S0 = 0, 1, 2, , n − 2. By pigeon-hole principle
again, we can find two vertices of the same degree in G.
S 9.4. The functions are defined as:

(i) F : BT R E E(X ) × X → BT R E E(X )


 
F(T, x) = M AK E L E F T (T ), x, R I G H T (T )

(ii) G : BT R E E(X ) → BT R E E(X )


 
G(T ) = M AK E R I G H T (T ), R O O T (T ), L E F T (T ) .

S 9.5. (i) The function R E PL : BT R E E(X ) × X → BT R E E(X ) is defined as

REP L (T, x) = MAKE (M AK E (L E F T (L E F T (T )), x, R I G H T (L E F T (T ))),


R O O T (T ), R I G H T (T ))

(ii) The function R E PR : BT R E E(X ) × X → BT R E E(X ) is defined as



R E PR (T, x) = M AK E L E F T (T ), R O O T (T ),
 
M AK E L E F T (R I G H T (T )), x, R I G H T (R I G H T (T ))

S 9.6. (a) Nodes used by Kruskal’s algorithm are A − E − D − G − B − C − F.


Arcs: AE = 3, AD = 4, DG = 4, BG = 2, AC = 5 and D F = 6 with
cost 24.
(b) The arcs used by Prim’s algorithm are BG = 2, AE = 3, AD = 4,
DG = 4, AC = 5 (or C E = 5) and D F = 6 for a total of 24.
(c) The shortest path between A and G is A − D − G of length 8.

View publication stats

You might also like