SlideShare a Scribd company logo
1 of 144
TRAILS, PATHS, AND CIRCUITS
One can begin to reason only when a clear picture has
been formed in the imagination.
โ€”W. W. Sawyer, Mathematicianโ€™s Delight, 1943
DEFINITION
The town of Kรถnigsberg in Prussia (now Kaliningrad in Russia)
was built at a point where two branches of the Pregel River
came together. It consisted of an island and some land along
the river banks.
Is it possible for a person to take a walk around town, starting
and ending at the same location and crossing each of the
seven bridges exactly once?
THE SEVEN BRIDGES OF Kร–NIGSBERG
THE SEVEN BRIDGES OF Kร–NIGSBERG
In terms of this graph, the question becomes the following:
Is it possible to find a route through the graph that starts and
ends at some vertex, one of A, B, C, or D, and traverses each
edge exactly once?
Equivalently:
Is it possible to trace this entire graph, starting and ending at
the same point, without either ever lifting your pencil from the
paper or crossing an edge more than once?
THE SEVEN BRIDGES OF Kร–NIGSBERG
DEFINITION
The town of Kรถnigsberg in Prussia (now Kaliningrad in Russia)
was built at a point where two branches of the Pregel River
came together. It consisted of an island and some land along
the river banks.
Is it possible for a person to take a walk around town, starting
and ending at the same location and crossing each of the
seven bridges exactly once?
DEFINITION
Travel in a graph is accomplished by moving from one
vertex to another along a sequence of adjacent edges.
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
DEFINITION
Travel in a graph is accomplished by moving from one
vertex to another along a sequence of adjacent edges.
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
Vertices
Nodes
DEFINITION
Travel in a graph is accomplished by moving from one
vertex to another along a sequence of adjacent edges.
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
Edges
Arcs
DEFINITION
In the graph, for
instance, you can go
from u1 to u4 by
taking f1 to u2 and
then f7 to u4. This is
represented by
writing
u1f1u2f7u4
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
DEFINITION
In the graph, for
instance, you can go
from u1 to u4 by
taking f1 to u2 and
then f7 to u4. This is
represented by
writing
u1f1u2f7u4
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
DEFINITION
In the graph, for
instance, you can go
from u1 to u4 by
taking f1 to u2 and
then f7 to u4. This is
represented by
writing
u1f1u2f7u4
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
DEFINITION
In the graph, for
instance, you can go
from u1 to u4 by
taking f1 to u2 and
then f7 to u4. This is
represented by
writing
u1f1u2f7u4
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
DEFINITION
In the graph, for
instance, you can go
from u1 to u4 by
taking f1 to u2 and
then f7 to u4. This is
represented by
writing
u1f1u2f7u4
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
DEFINITION
In the graph, for
instance, you can go
from u1 to u4 by
taking f1 to u2 and
then f7 to u4. This is
represented by
writing
u1f1u2f7u4
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
DEFINITION
Or you could take
the roundabout
route
u1
u5
u2
u3
u4
f1
f2
f3
f4
f5
f7
f6
u1f1u2f3u3f5u4f6u4f7u2f3u3f5u4
DEFINITION
Let G be a graph, and let v and w be vertices in G.
A walk from v to w is a finite alternating sequence of
adjacent vertices and edges of G. Thus a walk has the
form
v0e1v1e2โ€ฆvn-1envn
where the vโ€™s represent the vertices, the eโ€™s represent
edges,
DEFINITION
The trivial walk from v to v consists of the single vertex
v.
A trail from v to w is a walk from v to w that does not
contain a repeated edge.
A path from v to w is a trail that does not contain a
repeated vertex.
A closed walk is a walk that starts and ends at the same
DEFINITION
A circuit is a closed walk that contains at least one edge
and does not contain a repeated edge.
A simple circuit is a circuit that does not have any other
repeated vertex except the first and last.
SUMMARY
EXAMPLE 1
EXAMPLE 2
EXAMPLE 3
SUBGRAPHS
One can begin to reason only when a clear picture has
been formed in the imagination.
โ€”W. W. Sawyer, Mathematicianโ€™s Delight, 1943
DEFINITION
A graph H is said to be a subgraph of a graph G if, and
only if, every vertex in H is also a vertex in G, every edge
in H is also an edge in G, and every edge in H has the
same endpoints as it has in G.
EXAMPLE
List all subgraphs of the graph G with vertex set {v1, v2}
and edge set {e1, e2, e3}, where the endpoints of e1 are v1
and v2, the endpoints of e2 are v1 and v2, and e3 is a loop
at v1.
EXAMPLE
SUBGRAPHS
CONNECTEDNESS
One can begin to reason only when a clear picture has
been formed in the imagination.
โ€”W. W. Sawyer, Mathematicianโ€™s Delight, 1943
DEFINITION
Let G be a graph. Two vertices v and w of G are connected
if, and only if, there is a walk from v to w. The graph G is
connected if, and only if, given any two vertices v and w in
G, there is a walk from v to w. Symbolically:
G is connected โ‡” โˆ€ vertices v and w in G, โˆƒ a walk from v
to w
DEFINITION
A graph G is not connected if, and only if, there exist two
vertices of G that are not connected by any walk.
EXAMPLE
Which of the following graphs are connected?
SOME THEOREMS
Let G be a graph.
a) If G is connected, then any two distinct vertices of G can be
connected by a path.
b) If vertices v and w are part of a circuit in G and one edge is
removed from the circuit, then there still exists a trail from
v to w in G.
c) If G is connected and G contains a circuit, then an edge of
the circuit can be removed without disconnecting G.
DEFINITION
A graph H is a connected component of a graph G if,
and only if,
1. H is subgraph of G;
2. H is connected; and
3. no connected subgraph of G has H as a subgraph and
contains vertices or edges that are not in H.
EXAMPLE
Find all connected components of the following graph G.
EULER CIRCUITS
We are not very pleased when we are forced to accept a mathematical truth by virtue
of a complicated chain of formal conclusions and computations, which we traverse
blindly, link by link, feeling our way by touch. We want first an overview of the aim
and of the road; we want to understand the idea of the proof, the deeper context.
โ€”Hermann Weyl, 1885โ€“1955
DEFINITION
Let G be a graph. An Euler circuit for G is a circuit that contains every
vertex and every edge of G.
That is, an Euler circuit for G is a sequence of adjacent vertices and edges
in G that has at least
1. one edge,
2. starts and ends at the same vertex,
3. uses every vertex of G at least once, and
4. uses every edge of G exactly once.
THEOREM 1
If a graph has an Euler circuit, then every vertex of the
graph has positive even degree.
If some vertex of a graph has odd degree, then the graph
does not have an Euler circuit. (Contrapositive ver.)
EXAMPLE 1
Show that the graph below does not have an Euler circuit.
EXAMPLE 2
Show that the graph below does not have an Euler circuit.
THEOREM 2
If a graph G is connected and the degree of every vertex
of G is a positive even integer, then G has an Euler circuit.
PROOF (ALGORITHM)
Suppose that G is any connected graph and suppose that every
vertex of G is a positive even integer. [We must find an Euler
circuit for G.] Construct a circuit C by the following algorithm:
Step 1:
Pick any vertex v of G at which to start.
[This step can be accomplished because the vertex set of G is
nonempty by assumption.]
PROOF (ALGORITHM)
Step 2:
Pick any sequence of adjacent vertices and edges, starting
and ending at v and never repeating an edge. Call the
resulting circuit C.
PROOF (ALGORITHM)
Step 3:
Check whether C contains every edge and vertex of G. If
so, C is an Euler circuit, and we are finished. If not,
perform the following steps.
PROOF (ALGORITHM)
Step 3a:
Remove all edges of C from G and also any vertices that
become isolated when the edges of C are removed. Call
the resulting subgraph Gโ€™.
PROOF (ALGORITHM)
Step 3b:
Pick any vertex w common to both C and Gโ€™.
PROOF (ALGORITHM)
Step 3c:
Pick any sequence of adjacent vertices and edges of Gโ€™,
starting and ending at w and never repeating an edge.
Call the resulting circuit C,.
PROOF (ALGORITHM)
Step 3d:
Patch C and Cโ€™ together to create a new circuit Cโ€ as
follows: Start at v and follow C all the way to w. Then
follow Cโ€™ all the way back to w. After that, continue along
the untraveled portion of C to return to v.
PROOF (ALGORITHM)
Step 3e:
Let C = Cโ€ and go back to step 3.
EXAMPLE 3
Use Theorem to check that the graph below has an Euler
circuit. Then use the algorithm from the proof of the
theorem to find an Euler circuit for the graph.
THEOREM 3
A graph G has an Euler circuit if, and only if, G is
connected and every vertex of G has positive even
degree.
DEFINITION
Let G be a graph, and let v and w be two distinct vertices
of G. An Euler trail from v to w is a sequence of adjacent
edges and vertices that starts at v, ends at w, passes
through every vertex of G at least once, and traverses
every edge of G exactly once.
DEFINITION
Let G be a graph, and let v and w be two distinct vertices
of G. There is an Euler trail from v to w if, and only if, G
is connected, v and w have odd degree, and all other
vertices of G have positive even degree.
EXAMPLE 4
The floor plan shown below is for a house that is open for public
viewing. Is it possible to find a trail that starts in room A, ends in
room B, and passes through every interior doorway of the house
exactly once? If so, find such a trail.
QUIZ
If the graph does not
have an euler circuit,
explain why not. If it
does have an euler
circuit, describe one.
HAMILTONIAN CIRCUITS
We are not very pleased when we are forced to accept a mathematical truth by virtue
of a complicated chain of formal conclusions and computations, which we traverse
blindly, link by link, feeling our way by touch. We want first an overview of the aim
and of the road; we want to understand the idea of the proof, the deeper context.
โ€”Hermann Weyl, 1885โ€“1955
PROBLEM
PROBLEM
DEFINITION
Given a graph G, a Hamiltonian circuit for G is a simple
circuit that includes every vertex of G.
That is, a Hamiltonian circuit for G is a sequence of
adjacent vertices and distinct edges in which every vertex
of G appears exactly once, except for the first and the last,
which are the same.
DEFINITION
Suppose a graph G with at least two vertices has a
Hamiltonian circuit C, given concretely as
C: v0e1v1e2 โ€ฆ vn-1envn ( = v0).
DEFINITION
Hamiltonian circuit, every vertex of G is a vertex of H, and
H is connected since any two of its vertices lie on a circuit.
DEFINITION
If a graph G has a Hamiltonian circuit, then G has a
subgraph H with the following properties:
1. H contains every vertex of G.
2. H is connected.
3. H has the same number of edges as vertices.
4. Every vertex of H has degree 2.
EXAMPLE 1
Prove that the graph G shown below does not
have a Hamiltonian circuit
a
e
c
d
b
EXAMPLE 2
Imagine that the drawing below is a map showing four cities and the distances
in kilometers between them. Suppose that a salesman must travel to each city
exactly once, starting and ending in city A. Which route from city to city will
minimize the total distance that must be traveled?
A
C
D
B
30 25
30
40
50 35
TREES
We are not very pleased when we are forced to accept a mathematical truth by virtue
of a complicated chain of formal conclusions and computations, which we traverse
blindly, link by link, feeling our way by touch. We want first an overview of the aim
and of the road; we want to understand the idea of the proof, the deeper context.
โ€”Hermann Weyl, 1885โ€“1955
DEFINITION OF TERMS
โ€ขA graph is said to be circuit-free if, and only if, it has no
circuits.
โ€ขA graph is called a tree if, and only if, it is circuit-free and
connected.
โ€ขA trivial tree is a graph that consists of a single vertex.
โ€ขA graph is called a forest if, and only if, it is circuit-free
and not connected.
EXAMPLES OF TREES
TRIVIAL TREE
EXAMPLES OF NON-TREES
EXAMPLES OF FOREST
CIRCUIT-FREE
NOT CONNECTED
EXAMPLE 1 โ€“ DECISION TREE
During orientation week, a
college administers a
mathematics placement exam to
all entering students. The exam
consists of two parts, and
placement recommendations are
made as indicated by the tree
shown in Figure.
Read the tree from left to right
to decide what course should be
recommended for a student who
scored 9 on part I and 7 on part
II.
EXAMPLE 2 โ€“ A PARSE TREE
In the last 30 years, Noam Chomsky and others have
developed new ways to describe the syntax (or
grammatical structure) of natural languages such as
English. This work has proved useful in constructing
compilers for high-level computer languages.
In the study of grammars, trees are often used to show
the derivation of grammatically correct sentences from
certain basic rules. Such trees are called syntactic
derivation trees or parse trees.
EXAMPLE 2 โ€“ A PARSE TREE
A very small subset of English grammar, for example, specifies that
1. a sentence can be produced by writing first a noun phrase and then a
verb phrase;
2. a noun phrase can be produced by writing an article and then a noun;
3. a noun phrase can also be produced by writing an article, then an
adjective, and then a noun;
4. a verb phrase can be produced by writing a verb and then a noun phrase;
5. one article is โ€œtheโ€;
6. one adjective is โ€œyoungโ€;
7. one verb is โ€œcaughtโ€;
8. one noun is โ€œmanโ€;
9. one (other) noun is โ€œball.
EXAMPLE 2 โ€“ A PARSE TREE
The rules of a grammar are called productions. It
is customary to express them using the shorthand
notation illustrated below. This notation,
introduced by John Backus in 1959 and modified
by Peter Naur in 1960, was used to describe the
computer language Algol and is called the
Backusโ€“Naur notation. In the notation, the
symbol | represents the word or, and angle
brackets are used to enclose terms to be
BACKUSโ€“NAUR NOTATION
| - or
- used to enclose terms to be defined
โ€œThe young man caught the ballโ€
EXAMPLE 2 โ€“ A PARSE TREE
โ€œThe young man caught the ballโ€
1. ๐‘ ๐‘’๐‘›๐‘ก๐‘’๐‘›๐‘๐‘’ โ†’ ๐‘›๐‘œ๐‘ข๐‘› ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ ๐‘ฃ๐‘’๐‘Ÿ๐‘ ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’
2. ๐‘›๐‘œ๐‘ข๐‘› ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ โ†’ ๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘๐‘™๐‘’ ๐‘›๐‘œ๐‘ข๐‘›
3. ๐‘›๐‘œ๐‘ข๐‘› ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ โ†’ ๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘๐‘™๐‘’ ๐‘Ž๐‘‘๐‘—๐‘’๐‘๐‘ก๐‘–๐‘ฃ๐‘’ ๐‘›๐‘œ๐‘ข๐‘›
4. ๐‘ฃ๐‘’๐‘Ÿ๐‘ ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ โ†’ ๐‘ฃ๐‘’๐‘Ÿ๐‘ ๐‘›๐‘œ๐‘ข๐‘› ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’
5. ๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘๐‘™๐‘’ โ†’ ๐‘กโ„Ž๐‘’
6. ๐‘Ž๐‘‘๐‘—๐‘’๐‘๐‘ก๐‘–๐‘ฃ๐‘’ โ†’ ๐‘ฆ๐‘œ๐‘ข๐‘›๐‘”
7. ๐‘ฃ๐‘’๐‘Ÿ๐‘ โ†’ ๐‘๐‘Ž๐‘ข๐‘”โ„Ž๐‘ก
8. ๐‘›๐‘œ๐‘ข๐‘› โ†’ ๐‘š๐‘Ž๐‘›
9. ๐‘›๐‘œ๐‘ข๐‘› โ†’ ๐‘๐‘Ž๐‘™๐‘™
EXAMPLE 2 โ€“ A PARSE TREE
The derivation of the sentence โ€œThe young man caught the ballโ€ from the
above rules is described by the tree shown below
EXAMPLE 2 โ€“ A PARSE TREE
In the study of linguistics, syntax refers to the
grammatical structure of sentences, and
semantics refers to the meanings of words and
their interrelations.
EXAMPLE 2 โ€“ A PARSE TREE
A sentence can be syntactically correct but
semantically incorrect, as in the nonsensical
sentence
โ€œThe young ball caught the man,โ€
which can be derived from the rules given in
the previous slide.
EXAMPLE 2 โ€“ A PARSE TREE
Or a sentence can contain syntactic errors but
not semantic ones, as, for instance, when a
two-year-old child says,
โ€œMe hungry!โ€
CHARACTERISTICS OF A TREE
RICO
LEMME
If n is a positive integer, then any tree with n vertices (no
matter what its shape) has n โ€“ 1 edges.
Any tree that has more than one vertex has at least
one vertex of degree 1.
LEMME
LEMME (PROOF)
Let T be a particular but arbitrarily chosen tree that
has more than one vertex, and consider the
following algorithm:
Step 1: Pick a vertex v of T and let e be an edge
incident on v.
LEMME (PROOF)
Step 2: While deg(v) > 1, repeat steps 2a, 2b, and
2c:
Step 2a: Choose eโ€™ to be an edge incident on v
such that eโ€™ โ‰  e.
[Such an edge exists because deg(v) > 1
LEMME (PROOF)
Step 2b: Let vโ€™ be the vertex at the other end of eโ€™
from v.
[Since T is a tree, eโ€™ cannot be a loop and
therefore eโ€™ has two distinct endpoints.]
LEMME (PROOF)
Step 2c: Let e = eโ€™ and v = vโ€™.
[This is just a renaming process in
preparation for repeating step 2.]
The algorithm just described must eventually terminate
because the set of vertices of the tree T is finite and T is
circuit-free. When it does, a vertex v of degree 1 will
have been found.
LEMME (PROOF)
DEFINITION
Let T be a tree. If T has at least two vertices, then
a vertex of degree 1 in T is called a leaf (or a terminal vertex),
and
a vertex of degree greater than 1 in T is called an internal
vertex (or a branch vertex).
The unique vertex in a trivial tree is also called a leaf or
EXAMPLE
Find all leaves (or terminal vertices) and all internal (or branch)
vertices in the following tree:
THEOREM 1 (MAIN)
For any positive integer n, any tree with n
vertices has n โ€“ 1 edges.
THEOREM 1 (MAIN)
For any positive integer n, any tree with n
vertices has n โ€“ 1 edges.
EXAMPLE
A graph G has ten vertices and twelve edges. Is
it a tree?
What if it has nine edges. Is it now a tree?
LEMME
If G is any connected graph, C is any circuit
in G, and any one of the edges of C is
removed from G, then the graph that
remains is connected.
THEOREM 2 (MAIN)
For any positive integer n, if G is a
connected graph with n vertices and n โ€“ 1
edges, then G is a tree.
EXAMPLE
Give an example of a graph with five vertices
and four edges that is not a tree.
EXAMPLE
Although it is true that every connected graph with n
vertices and n - 1 edges (where n is a positive integer) is a
tree, it is not true that every graph with n vertices and n โ€“
1 edges is a tree.
THEOREM 2 (COL..)
If G is any graph with i vertices and m
edges, where m and n are positive integers
and m โ‰ฅ n, then G has a circuit.
ROOTED TREES
Let us grant that the pursuit of mathematics is a divine
madness of the human spirit, a refuge from the goading
urgency of contingent happenings.
โ€”Alfred North Whitehead, 1861โ€“1947
DEFINITION
A rooted tree is a tree in which there is one vertex that
is distinguished from the others and is called the root.
The level of a vertex is the number of edges along the
unique path between it and the root.
The height of a rooted tree is the maximum level of
any vertex of the tree.
DEFINITION
Given the root or any internal vertex v of a
rooted tree, the children of v are all those
vertices that are adjacent to v and are one level
farther away from the root than v.
If w is a child of v, then v is called the parent of
w, and two distinct vertices that are both
children of the same parent are called siblings.
DEFINITION
Given two distinct vertices v and w, if v lies
on the unique path between w and the
root, then v is an ancestor of w and w is a
descendant of v.
DEFINITION
EXAMPLE 1
Consider the tree with root v0.
a. What is the level of v5?
b. What is the level of v0?
c. What is the height of this rooted tree?
d. What are the children of v3?
e. What is the parent of v2?
f. What are the siblings of v8?
g. What are the descendants of v3?
h. How many leaves (terminal vertices) are on the tree?
EXAMPLE 2
The root is v0, v1 has level 1,
v1 is the child of v0, and
both v0 and v1 are leaves
(terminal vertices).
v0
v
1
BINARY TREES
Let us grant that the pursuit of mathematics is a divine
madness of the human spirit, a refuge from the goading
urgency of contingent happenings.
โ€”Alfred North Whitehead, 1861โ€“1947
DEFINITION
A binary tree is a rooted tree in which every parent has at
most two children.
Each child in a binary tree is designated either a left child or
a right child (but not both), and every parent has at most
one left child and one right child.
A full binary tree is a binary tree in which each parent has
exactly two children.
DEFINITION
Given any parent v in a binary tree T, if v has a left
child, then the left subtree of v is the binary tree
whose root is the left child of v, whose vertices
consist of the left child of v and all its descendants,
and whose edges consist of all those edges of T
that connect the vertices of the left subtree.
The right subtree of v is defined analogously.
DEFINITION
EXAMPLE 1
Draw a binary tree to represent the
expression
๐‘Ž โˆ’ ๐‘ ร— ๐‘ +
๐‘‘
๐‘’
.
EXAMPLE
+
x
-
a b
c
/
d e
THEOREM 1
If k is a positive integer and T is a full
binary tree with k internal vertices, then
(1) T has a total of 2k + 1 vertices, and
(2) T has k + 1 leaves.
EXAMPLE 2
Is there a full binary tree that has 10
internal vertices and 13 terminal vertices?
THEOREM 2
For every integer h โ‰ฅ 0, if T is any binary
tree with height h and t leaves, then
t โ‰ค 2h
Equivalently:
log2 t โ‰ค h
EXAMPLE 3
Is there a binary tree that has height 5 and
38 leaves?
BINARY SEARCH TREES
Let us grant that the pursuit of mathematics is a divine
madness of the human spirit, a refuge from the goading
urgency of contingent happenings.
โ€”Alfred North Whitehead, 1861โ€“1947
DEFINITION
A binary search tree is a kind of binary tree
in which data records, such as customer
information, can be stored, searched, and
processed very efficiently.
PROPERTY
For every internal vertex v, all the keys in
the left subtree of v are less than the key in
v, and all the keys in the right subtree of v
are greater than the key in v.
MATRIX REPRESENTATIONS OF
GRAPHS
Order and simplification are the first steps toward the
mastery of a subject.
โ€”Thomas Mann, The Magic Mountain, 1924
DEFINITION
Matrices are two-dimensional analogues of
sequences. They are also called two-dimensional
arrays.
DEFINITION
An m x n (read โ€œm by nโ€) matrix A over a set S is a
rectangular array of elements of S arranged into m
rows and n columns:
DEFINITION
๐ด =
๐‘Ž11 ๐‘Ž12 โ‹ฏ
๐‘Ž21 ๐‘Ž22 โ‹ฏ
โ‹ฎ โ‹ฎ
๐‘Ž1๐‘— โ‹ฏ ๐‘Ž1๐‘›
๐‘Ž2๐‘— โ‹ฏ ๐‘Ž2๐‘›
โ‹ฎ โ‹ฎ
๐‘Ž๐‘–1 ๐‘Ž๐‘–2 โ‹ฏ
โ‹ฎ โ‹ฎ
๐‘Ž๐‘š1 ๐‘Ž๐‘š2 โ‹ฏ
๐‘Ž๐‘–๐‘— โ‹ฏ ๐‘Ž๐‘–๐‘›
โ‹ฎ โ‹ฎ
๐‘Ž๐‘š๐‘— โ‹ฏ ๐‘Ž๐‘š๐‘›
ith row of
A
jth column of A
DEFINITION
The ith row of A is
๐‘Ž๐‘–1 ๐‘Ž๐‘–2 โ‹ฏ ๐‘Ž๐‘–๐‘›
and the jth column of A is
๐‘Ž1๐‘—
๐‘Ž2๐‘—
โ‹ฎ
๐‘Ž๐‘š๐‘—
DEFINITION
The entry aij in the ith row and jth column
of A is called the ijth entry of A.
An m x n matrix is said to have size m x n.
DEFINITION
If A and B are matrices, then A = B if, and only
if, A and B have the same size and the
corresponding entries of A and B are all equal;
that is,
a = b for every i = 1, 2, . . . , m and j = 1, 2, . . .
DEFINITION
A matrix for which the numbers of rows and
columns are equal is called a square matrix.
If A is a square matrix of size n x n, then the
main diagonal of A consists of all the entries
a11, a22, . . . , ann.
DEFINITION
๐‘Ž11 ๐‘Ž12 โ‹ฏ
๐‘Ž21 ๐‘Ž22 โ‹ฏ
โ‹ฎ โ‹ฎ
๐‘Ž1๐‘— โ‹ฏ ๐‘Ž1๐‘›
๐‘Ž2๐‘— โ‹ฏ ๐‘Ž2๐‘›
โ‹ฎ โ‹ฎ
๐‘Ž๐‘–1 ๐‘Ž๐‘–2 โ‹ฏ
โ‹ฎ โ‹ฎ
๐‘Ž๐‘›1 ๐‘Ž๐‘›2 โ‹ฏ
๐‘Ž๐‘–๐‘– โ‹ฏ ๐‘Ž๐‘–๐‘›
โ‹ฎ โ‹ฎ
๐‘Ž๐‘›๐‘– โ‹ฏ ๐‘Ž๐‘›๐‘›
main diagonal of
A
EXAMPLE 1
The following is a 3 x 3 matrix over the set of integers
๐ด =
1 0 โˆ’3
4 โˆ’1 5
โˆ’2 2 0
a. What is a23, the entry in row 2, column 3?
b. What is the second column of A?
c. What are the entries in the main diagonal of A?
MATRICES AND DIRECTED GRAPHS
MATRICES AND DIRECTED GRAPHS
A is called the adjacency matrix of the
directed graph.
MATRICES AND DIRECTED GRAPHS
Let G be a directed graph with ordered vertices v1, v2, . . . ,
vn. The adjacency matrix of G is the n x n matrix A = (aij)
over the set of nonnegative integers such that
aij = the number of arrows from vi to vj for all i, j = 1, 2, . . .
, n
EXAMPLE 2
The two directed graphs shown below differ
only in the ordering of their vertices. Find their
adjacency matrices.
EXAMPLE 2 (ANS)
The two directed graphs shown below differ
only in the ordering of their vertices. Find their
adjacency matrices.
๐ด๐‘Ž =
0 0 0
0 1 1
2 1 0
EXAMPLE 2 (ANS)
The two directed graphs shown below differ
only in the ordering of their vertices. Find their
adjacency matrices.
๐ด๐‘ =
1 1 0
1 0 2
0 0 0
EXAMPLE 3
Let ๐ด =
0 1
1 1
1 0
0 2
0 0
2 1
1 1
0 0
Draw a directed graph that has A as its
adjacency matrix
EXAMPLE 3 (ANS)
๐ด =
๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 ๐‘ฃ4
๐‘ฃ1
๐‘ฃ2
๐‘ฃ3
๐‘ฃ4
0 1
1 1
1 0
0 2
0 0
2 1
1 1
0 0
MATRICES AND UNDIRECTED GRAPHS
Let G be an undirected graph with ordered vertices v1, v2, .
. . , vn.The adjacency matrix of G is the n x n matrix A = (aij)
over the set of nonnegative integers such that
aij = the number of edges connecting vi and vj
for every i and j = 1, 2, . . . , n.
EXAMPLE 4
Find the adjacency
matrix for the graph G.
EXAMPLE 4 (ANS)
๐ด =
๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 ๐‘ฃ4
๐‘ฃ1
๐‘ฃ2
๐‘ฃ3
๐‘ฃ4
0 1
1 1
0 1
2 1
0 2
1 1
0 0
0 1
MATRICES AND CONNECTED COMPONENTS
Consider a graph G, as shown below, that
consists of several connected components.
EXAMPLE 5
Consider a graph G, as shown below, that
consists of several connected components.
EXAMPLE 5 (ANS)
Let G be a graph with connected components G1, G2, . . . , Gk. If
there are ni vertices in each connected component Gi and these
vertices are numbered consecutively, then the adjacency matrix
of G has the form
๐ด1 O O
O ๐ด2 O
โ‹ฏ O O
โ‹ฏ O O
O O ๐ด3
โ‹ฎ
O
โ‹ฎ
O
โ‹ฎ
O
โ‹ฏ O O
โ‹ฏ
โ‹ฎ
O
โ‹ฎ
๐ด๐‘˜
where each Ai is the ni x ni adjacency matrix of Gi , for every i =
1, 2, . . . , k, and the Oโ€™s represent matrices whose entries are all
ฮฝ
ฮฒ
ฮด
ฯ€
ฯ
ฯƒ
ฯ„
ฮฑ
ฮต
ฮผ
ฮพ
ฮท
ฮธ
ฮน
ฮบ
ฯ…
ฮป
ฯ†

More Related Content

Similar to Final-term Coverage.pptx. ..............

Lecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptxLecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptxChandanGiri21
ย 
koningsbergproblem-140215072342-phpapp02 (1).pptx
koningsbergproblem-140215072342-phpapp02 (1).pptxkoningsbergproblem-140215072342-phpapp02 (1).pptx
koningsbergproblem-140215072342-phpapp02 (1).pptxAlpa Rajput
ย 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxmiki304759
ย 
Graph theory
Graph theoryGraph theory
Graph theorymanikanta361
ย 
358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13sumitbardhan
ย 
FCS (graphs).pptx
FCS (graphs).pptxFCS (graphs).pptx
FCS (graphs).pptxShubhamBatwani
ย 
Magtibay buk bind#2
Magtibay buk bind#2Magtibay buk bind#2
Magtibay buk bind#2Sofia Palawan
ย 
Mithfh lecturenotes 9
Mithfh lecturenotes 9Mithfh lecturenotes 9
Mithfh lecturenotes 9Praveen Kumar
ย 
Ds lec 5_chap4
Ds lec 5_chap4Ds lec 5_chap4
Ds lec 5_chap4Self-Employed
ย 
Graph Theory_part 2.pptx
Graph Theory_part 2.pptxGraph Theory_part 2.pptx
Graph Theory_part 2.pptxssuser039bf6
ย 
Cs6702 graph theory and applications 2 marks questions and answers
Cs6702 graph theory and applications 2 marks questions and answersCs6702 graph theory and applications 2 marks questions and answers
Cs6702 graph theory and applications 2 marks questions and answersappasami
ย 
Eurler_Hamilton_Path_Circuit.pdf
Eurler_Hamilton_Path_Circuit.pdfEurler_Hamilton_Path_Circuit.pdf
Eurler_Hamilton_Path_Circuit.pdfRydaS1
ย 
Graph theory
Graph theoryGraph theory
Graph theorybibinjose31
ย 
Ass. (3)graph d.m
Ass. (3)graph d.mAss. (3)graph d.m
Ass. (3)graph d.mSyed Umair
ย 
ISOMORFISME, CONNECTIVITY EULER HAMILTON.pdf
ISOMORFISME, CONNECTIVITY EULER HAMILTON.pdfISOMORFISME, CONNECTIVITY EULER HAMILTON.pdf
ISOMORFISME, CONNECTIVITY EULER HAMILTON.pdfmurniatimurni9
ย 
euler paths and circuit theorem.pptx
euler paths and circuit theorem.pptxeuler paths and circuit theorem.pptx
euler paths and circuit theorem.pptxMArunyNandinikkutty
ย 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptxSwarndeviKm
ย 

Similar to Final-term Coverage.pptx. .............. (20)

Lecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptxLecture 1--Graph Algorithms -- Basics.pptx
Lecture 1--Graph Algorithms -- Basics.pptx
ย 
koningsbergproblem-140215072342-phpapp02 (1).pptx
koningsbergproblem-140215072342-phpapp02 (1).pptxkoningsbergproblem-140215072342-phpapp02 (1).pptx
koningsbergproblem-140215072342-phpapp02 (1).pptx
ย 
Elements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptxElements of Graph Theory for IS.pptx
Elements of Graph Theory for IS.pptx
ย 
Graph theory
Graph theoryGraph theory
Graph theory
ย 
Presentation on graphs
Presentation on graphsPresentation on graphs
Presentation on graphs
ย 
358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13
ย 
FCS (graphs).pptx
FCS (graphs).pptxFCS (graphs).pptx
FCS (graphs).pptx
ย 
Magtibay buk bind#2
Magtibay buk bind#2Magtibay buk bind#2
Magtibay buk bind#2
ย 
Mithfh lecturenotes 9
Mithfh lecturenotes 9Mithfh lecturenotes 9
Mithfh lecturenotes 9
ย 
Ds lec 5_chap4
Ds lec 5_chap4Ds lec 5_chap4
Ds lec 5_chap4
ย 
Graph Theory_part 2.pptx
Graph Theory_part 2.pptxGraph Theory_part 2.pptx
Graph Theory_part 2.pptx
ย 
Cs6702 graph theory and applications 2 marks questions and answers
Cs6702 graph theory and applications 2 marks questions and answersCs6702 graph theory and applications 2 marks questions and answers
Cs6702 graph theory and applications 2 marks questions and answers
ย 
Eurler_Hamilton_Path_Circuit.pdf
Eurler_Hamilton_Path_Circuit.pdfEurler_Hamilton_Path_Circuit.pdf
Eurler_Hamilton_Path_Circuit.pdf
ย 
Graph algorithm
Graph algorithmGraph algorithm
Graph algorithm
ย 
Graph theory
Graph theoryGraph theory
Graph theory
ย 
Ass. (3)graph d.m
Ass. (3)graph d.mAss. (3)graph d.m
Ass. (3)graph d.m
ย 
Unit V - ppt.pptx
Unit V - ppt.pptxUnit V - ppt.pptx
Unit V - ppt.pptx
ย 
ISOMORFISME, CONNECTIVITY EULER HAMILTON.pdf
ISOMORFISME, CONNECTIVITY EULER HAMILTON.pdfISOMORFISME, CONNECTIVITY EULER HAMILTON.pdf
ISOMORFISME, CONNECTIVITY EULER HAMILTON.pdf
ย 
euler paths and circuit theorem.pptx
euler paths and circuit theorem.pptxeuler paths and circuit theorem.pptx
euler paths and circuit theorem.pptx
ย 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
ย 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
ย 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
ย 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
ย 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
ย 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
ย 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
ย 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
ย 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
ย 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
ย 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
ย 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
ย 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
ย 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
ย 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
ย 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
ย 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
ย 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
ย 

Recently uploaded (20)

Model Call Girl in Bikash Puri Delhi reach out to us at ๐Ÿ”9953056974๐Ÿ”
Model Call Girl in Bikash Puri  Delhi reach out to us at ๐Ÿ”9953056974๐Ÿ”Model Call Girl in Bikash Puri  Delhi reach out to us at ๐Ÿ”9953056974๐Ÿ”
Model Call Girl in Bikash Puri Delhi reach out to us at ๐Ÿ”9953056974๐Ÿ”
ย 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
ย 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
ย 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
ย 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
ย 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
ย 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
ย 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
ย 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
ย 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
ย 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
ย 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
ย 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
ย 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
ย 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
ย 
Model Call Girl in Tilak Nagar Delhi reach out to us at ๐Ÿ”9953056974๐Ÿ”
Model Call Girl in Tilak Nagar Delhi reach out to us at ๐Ÿ”9953056974๐Ÿ”Model Call Girl in Tilak Nagar Delhi reach out to us at ๐Ÿ”9953056974๐Ÿ”
Model Call Girl in Tilak Nagar Delhi reach out to us at ๐Ÿ”9953056974๐Ÿ”
ย 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
ย 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
ย 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
ย 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
ย 

Final-term Coverage.pptx. ..............

  • 1. TRAILS, PATHS, AND CIRCUITS One can begin to reason only when a clear picture has been formed in the imagination. โ€”W. W. Sawyer, Mathematicianโ€™s Delight, 1943
  • 2. DEFINITION The town of Kรถnigsberg in Prussia (now Kaliningrad in Russia) was built at a point where two branches of the Pregel River came together. It consisted of an island and some land along the river banks. Is it possible for a person to take a walk around town, starting and ending at the same location and crossing each of the seven bridges exactly once?
  • 3. THE SEVEN BRIDGES OF Kร–NIGSBERG
  • 4. THE SEVEN BRIDGES OF Kร–NIGSBERG In terms of this graph, the question becomes the following: Is it possible to find a route through the graph that starts and ends at some vertex, one of A, B, C, or D, and traverses each edge exactly once? Equivalently: Is it possible to trace this entire graph, starting and ending at the same point, without either ever lifting your pencil from the paper or crossing an edge more than once?
  • 5. THE SEVEN BRIDGES OF Kร–NIGSBERG
  • 6. DEFINITION The town of Kรถnigsberg in Prussia (now Kaliningrad in Russia) was built at a point where two branches of the Pregel River came together. It consisted of an island and some land along the river banks. Is it possible for a person to take a walk around town, starting and ending at the same location and crossing each of the seven bridges exactly once?
  • 7. DEFINITION Travel in a graph is accomplished by moving from one vertex to another along a sequence of adjacent edges. u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6
  • 8. DEFINITION Travel in a graph is accomplished by moving from one vertex to another along a sequence of adjacent edges. u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6 Vertices Nodes
  • 9. DEFINITION Travel in a graph is accomplished by moving from one vertex to another along a sequence of adjacent edges. u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6 Edges Arcs
  • 10. DEFINITION In the graph, for instance, you can go from u1 to u4 by taking f1 to u2 and then f7 to u4. This is represented by writing u1f1u2f7u4 u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6
  • 11. DEFINITION In the graph, for instance, you can go from u1 to u4 by taking f1 to u2 and then f7 to u4. This is represented by writing u1f1u2f7u4 u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6
  • 12. DEFINITION In the graph, for instance, you can go from u1 to u4 by taking f1 to u2 and then f7 to u4. This is represented by writing u1f1u2f7u4 u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6
  • 13. DEFINITION In the graph, for instance, you can go from u1 to u4 by taking f1 to u2 and then f7 to u4. This is represented by writing u1f1u2f7u4 u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6
  • 14. DEFINITION In the graph, for instance, you can go from u1 to u4 by taking f1 to u2 and then f7 to u4. This is represented by writing u1f1u2f7u4 u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6
  • 15. DEFINITION In the graph, for instance, you can go from u1 to u4 by taking f1 to u2 and then f7 to u4. This is represented by writing u1f1u2f7u4 u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6
  • 16. DEFINITION Or you could take the roundabout route u1 u5 u2 u3 u4 f1 f2 f3 f4 f5 f7 f6 u1f1u2f3u3f5u4f6u4f7u2f3u3f5u4
  • 17. DEFINITION Let G be a graph, and let v and w be vertices in G. A walk from v to w is a finite alternating sequence of adjacent vertices and edges of G. Thus a walk has the form v0e1v1e2โ€ฆvn-1envn where the vโ€™s represent the vertices, the eโ€™s represent edges,
  • 18. DEFINITION The trivial walk from v to v consists of the single vertex v. A trail from v to w is a walk from v to w that does not contain a repeated edge. A path from v to w is a trail that does not contain a repeated vertex. A closed walk is a walk that starts and ends at the same
  • 19. DEFINITION A circuit is a closed walk that contains at least one edge and does not contain a repeated edge. A simple circuit is a circuit that does not have any other repeated vertex except the first and last.
  • 24. SUBGRAPHS One can begin to reason only when a clear picture has been formed in the imagination. โ€”W. W. Sawyer, Mathematicianโ€™s Delight, 1943
  • 25. DEFINITION A graph H is said to be a subgraph of a graph G if, and only if, every vertex in H is also a vertex in G, every edge in H is also an edge in G, and every edge in H has the same endpoints as it has in G.
  • 26. EXAMPLE List all subgraphs of the graph G with vertex set {v1, v2} and edge set {e1, e2, e3}, where the endpoints of e1 are v1 and v2, the endpoints of e2 are v1 and v2, and e3 is a loop at v1.
  • 29. CONNECTEDNESS One can begin to reason only when a clear picture has been formed in the imagination. โ€”W. W. Sawyer, Mathematicianโ€™s Delight, 1943
  • 30. DEFINITION Let G be a graph. Two vertices v and w of G are connected if, and only if, there is a walk from v to w. The graph G is connected if, and only if, given any two vertices v and w in G, there is a walk from v to w. Symbolically: G is connected โ‡” โˆ€ vertices v and w in G, โˆƒ a walk from v to w
  • 31. DEFINITION A graph G is not connected if, and only if, there exist two vertices of G that are not connected by any walk.
  • 32. EXAMPLE Which of the following graphs are connected?
  • 33. SOME THEOREMS Let G be a graph. a) If G is connected, then any two distinct vertices of G can be connected by a path. b) If vertices v and w are part of a circuit in G and one edge is removed from the circuit, then there still exists a trail from v to w in G. c) If G is connected and G contains a circuit, then an edge of the circuit can be removed without disconnecting G.
  • 34. DEFINITION A graph H is a connected component of a graph G if, and only if, 1. H is subgraph of G; 2. H is connected; and 3. no connected subgraph of G has H as a subgraph and contains vertices or edges that are not in H.
  • 35. EXAMPLE Find all connected components of the following graph G.
  • 36. EULER CIRCUITS We are not very pleased when we are forced to accept a mathematical truth by virtue of a complicated chain of formal conclusions and computations, which we traverse blindly, link by link, feeling our way by touch. We want first an overview of the aim and of the road; we want to understand the idea of the proof, the deeper context. โ€”Hermann Weyl, 1885โ€“1955
  • 37. DEFINITION Let G be a graph. An Euler circuit for G is a circuit that contains every vertex and every edge of G. That is, an Euler circuit for G is a sequence of adjacent vertices and edges in G that has at least 1. one edge, 2. starts and ends at the same vertex, 3. uses every vertex of G at least once, and 4. uses every edge of G exactly once.
  • 38. THEOREM 1 If a graph has an Euler circuit, then every vertex of the graph has positive even degree. If some vertex of a graph has odd degree, then the graph does not have an Euler circuit. (Contrapositive ver.)
  • 39. EXAMPLE 1 Show that the graph below does not have an Euler circuit.
  • 40. EXAMPLE 2 Show that the graph below does not have an Euler circuit.
  • 41. THEOREM 2 If a graph G is connected and the degree of every vertex of G is a positive even integer, then G has an Euler circuit.
  • 42. PROOF (ALGORITHM) Suppose that G is any connected graph and suppose that every vertex of G is a positive even integer. [We must find an Euler circuit for G.] Construct a circuit C by the following algorithm: Step 1: Pick any vertex v of G at which to start. [This step can be accomplished because the vertex set of G is nonempty by assumption.]
  • 43. PROOF (ALGORITHM) Step 2: Pick any sequence of adjacent vertices and edges, starting and ending at v and never repeating an edge. Call the resulting circuit C.
  • 44. PROOF (ALGORITHM) Step 3: Check whether C contains every edge and vertex of G. If so, C is an Euler circuit, and we are finished. If not, perform the following steps.
  • 45. PROOF (ALGORITHM) Step 3a: Remove all edges of C from G and also any vertices that become isolated when the edges of C are removed. Call the resulting subgraph Gโ€™.
  • 46. PROOF (ALGORITHM) Step 3b: Pick any vertex w common to both C and Gโ€™.
  • 47. PROOF (ALGORITHM) Step 3c: Pick any sequence of adjacent vertices and edges of Gโ€™, starting and ending at w and never repeating an edge. Call the resulting circuit C,.
  • 48. PROOF (ALGORITHM) Step 3d: Patch C and Cโ€™ together to create a new circuit Cโ€ as follows: Start at v and follow C all the way to w. Then follow Cโ€™ all the way back to w. After that, continue along the untraveled portion of C to return to v.
  • 49. PROOF (ALGORITHM) Step 3e: Let C = Cโ€ and go back to step 3.
  • 50. EXAMPLE 3 Use Theorem to check that the graph below has an Euler circuit. Then use the algorithm from the proof of the theorem to find an Euler circuit for the graph.
  • 51. THEOREM 3 A graph G has an Euler circuit if, and only if, G is connected and every vertex of G has positive even degree.
  • 52. DEFINITION Let G be a graph, and let v and w be two distinct vertices of G. An Euler trail from v to w is a sequence of adjacent edges and vertices that starts at v, ends at w, passes through every vertex of G at least once, and traverses every edge of G exactly once.
  • 53. DEFINITION Let G be a graph, and let v and w be two distinct vertices of G. There is an Euler trail from v to w if, and only if, G is connected, v and w have odd degree, and all other vertices of G have positive even degree.
  • 54. EXAMPLE 4 The floor plan shown below is for a house that is open for public viewing. Is it possible to find a trail that starts in room A, ends in room B, and passes through every interior doorway of the house exactly once? If so, find such a trail.
  • 55. QUIZ If the graph does not have an euler circuit, explain why not. If it does have an euler circuit, describe one.
  • 56. HAMILTONIAN CIRCUITS We are not very pleased when we are forced to accept a mathematical truth by virtue of a complicated chain of formal conclusions and computations, which we traverse blindly, link by link, feeling our way by touch. We want first an overview of the aim and of the road; we want to understand the idea of the proof, the deeper context. โ€”Hermann Weyl, 1885โ€“1955
  • 59. DEFINITION Given a graph G, a Hamiltonian circuit for G is a simple circuit that includes every vertex of G. That is, a Hamiltonian circuit for G is a sequence of adjacent vertices and distinct edges in which every vertex of G appears exactly once, except for the first and the last, which are the same.
  • 60. DEFINITION Suppose a graph G with at least two vertices has a Hamiltonian circuit C, given concretely as C: v0e1v1e2 โ€ฆ vn-1envn ( = v0).
  • 61. DEFINITION Hamiltonian circuit, every vertex of G is a vertex of H, and H is connected since any two of its vertices lie on a circuit.
  • 62. DEFINITION If a graph G has a Hamiltonian circuit, then G has a subgraph H with the following properties: 1. H contains every vertex of G. 2. H is connected. 3. H has the same number of edges as vertices. 4. Every vertex of H has degree 2.
  • 63. EXAMPLE 1 Prove that the graph G shown below does not have a Hamiltonian circuit a e c d b
  • 64. EXAMPLE 2 Imagine that the drawing below is a map showing four cities and the distances in kilometers between them. Suppose that a salesman must travel to each city exactly once, starting and ending in city A. Which route from city to city will minimize the total distance that must be traveled? A C D B 30 25 30 40 50 35
  • 65. TREES We are not very pleased when we are forced to accept a mathematical truth by virtue of a complicated chain of formal conclusions and computations, which we traverse blindly, link by link, feeling our way by touch. We want first an overview of the aim and of the road; we want to understand the idea of the proof, the deeper context. โ€”Hermann Weyl, 1885โ€“1955
  • 66. DEFINITION OF TERMS โ€ขA graph is said to be circuit-free if, and only if, it has no circuits. โ€ขA graph is called a tree if, and only if, it is circuit-free and connected. โ€ขA trivial tree is a graph that consists of a single vertex. โ€ขA graph is called a forest if, and only if, it is circuit-free and not connected.
  • 70. EXAMPLE 1 โ€“ DECISION TREE During orientation week, a college administers a mathematics placement exam to all entering students. The exam consists of two parts, and placement recommendations are made as indicated by the tree shown in Figure. Read the tree from left to right to decide what course should be recommended for a student who scored 9 on part I and 7 on part II.
  • 71. EXAMPLE 2 โ€“ A PARSE TREE In the last 30 years, Noam Chomsky and others have developed new ways to describe the syntax (or grammatical structure) of natural languages such as English. This work has proved useful in constructing compilers for high-level computer languages. In the study of grammars, trees are often used to show the derivation of grammatically correct sentences from certain basic rules. Such trees are called syntactic derivation trees or parse trees.
  • 72. EXAMPLE 2 โ€“ A PARSE TREE A very small subset of English grammar, for example, specifies that 1. a sentence can be produced by writing first a noun phrase and then a verb phrase; 2. a noun phrase can be produced by writing an article and then a noun; 3. a noun phrase can also be produced by writing an article, then an adjective, and then a noun; 4. a verb phrase can be produced by writing a verb and then a noun phrase; 5. one article is โ€œtheโ€; 6. one adjective is โ€œyoungโ€; 7. one verb is โ€œcaughtโ€; 8. one noun is โ€œmanโ€; 9. one (other) noun is โ€œball.
  • 73. EXAMPLE 2 โ€“ A PARSE TREE The rules of a grammar are called productions. It is customary to express them using the shorthand notation illustrated below. This notation, introduced by John Backus in 1959 and modified by Peter Naur in 1960, was used to describe the computer language Algol and is called the Backusโ€“Naur notation. In the notation, the symbol | represents the word or, and angle brackets are used to enclose terms to be
  • 74. BACKUSโ€“NAUR NOTATION | - or - used to enclose terms to be defined โ€œThe young man caught the ballโ€
  • 75. EXAMPLE 2 โ€“ A PARSE TREE โ€œThe young man caught the ballโ€ 1. ๐‘ ๐‘’๐‘›๐‘ก๐‘’๐‘›๐‘๐‘’ โ†’ ๐‘›๐‘œ๐‘ข๐‘› ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ ๐‘ฃ๐‘’๐‘Ÿ๐‘ ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ 2. ๐‘›๐‘œ๐‘ข๐‘› ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ โ†’ ๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘๐‘™๐‘’ ๐‘›๐‘œ๐‘ข๐‘› 3. ๐‘›๐‘œ๐‘ข๐‘› ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ โ†’ ๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘๐‘™๐‘’ ๐‘Ž๐‘‘๐‘—๐‘’๐‘๐‘ก๐‘–๐‘ฃ๐‘’ ๐‘›๐‘œ๐‘ข๐‘› 4. ๐‘ฃ๐‘’๐‘Ÿ๐‘ ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ โ†’ ๐‘ฃ๐‘’๐‘Ÿ๐‘ ๐‘›๐‘œ๐‘ข๐‘› ๐‘โ„Ž๐‘Ÿ๐‘Ž๐‘ ๐‘’ 5. ๐‘Ž๐‘Ÿ๐‘ก๐‘–๐‘๐‘™๐‘’ โ†’ ๐‘กโ„Ž๐‘’ 6. ๐‘Ž๐‘‘๐‘—๐‘’๐‘๐‘ก๐‘–๐‘ฃ๐‘’ โ†’ ๐‘ฆ๐‘œ๐‘ข๐‘›๐‘” 7. ๐‘ฃ๐‘’๐‘Ÿ๐‘ โ†’ ๐‘๐‘Ž๐‘ข๐‘”โ„Ž๐‘ก 8. ๐‘›๐‘œ๐‘ข๐‘› โ†’ ๐‘š๐‘Ž๐‘› 9. ๐‘›๐‘œ๐‘ข๐‘› โ†’ ๐‘๐‘Ž๐‘™๐‘™
  • 76. EXAMPLE 2 โ€“ A PARSE TREE The derivation of the sentence โ€œThe young man caught the ballโ€ from the above rules is described by the tree shown below
  • 77. EXAMPLE 2 โ€“ A PARSE TREE In the study of linguistics, syntax refers to the grammatical structure of sentences, and semantics refers to the meanings of words and their interrelations.
  • 78. EXAMPLE 2 โ€“ A PARSE TREE A sentence can be syntactically correct but semantically incorrect, as in the nonsensical sentence โ€œThe young ball caught the man,โ€ which can be derived from the rules given in the previous slide.
  • 79. EXAMPLE 2 โ€“ A PARSE TREE Or a sentence can contain syntactic errors but not semantic ones, as, for instance, when a two-year-old child says, โ€œMe hungry!โ€
  • 80. CHARACTERISTICS OF A TREE RICO
  • 81. LEMME If n is a positive integer, then any tree with n vertices (no matter what its shape) has n โ€“ 1 edges. Any tree that has more than one vertex has at least one vertex of degree 1.
  • 82. LEMME
  • 83. LEMME (PROOF) Let T be a particular but arbitrarily chosen tree that has more than one vertex, and consider the following algorithm: Step 1: Pick a vertex v of T and let e be an edge incident on v.
  • 84. LEMME (PROOF) Step 2: While deg(v) > 1, repeat steps 2a, 2b, and 2c: Step 2a: Choose eโ€™ to be an edge incident on v such that eโ€™ โ‰  e. [Such an edge exists because deg(v) > 1
  • 85. LEMME (PROOF) Step 2b: Let vโ€™ be the vertex at the other end of eโ€™ from v. [Since T is a tree, eโ€™ cannot be a loop and therefore eโ€™ has two distinct endpoints.]
  • 86. LEMME (PROOF) Step 2c: Let e = eโ€™ and v = vโ€™. [This is just a renaming process in preparation for repeating step 2.] The algorithm just described must eventually terminate because the set of vertices of the tree T is finite and T is circuit-free. When it does, a vertex v of degree 1 will have been found.
  • 88. DEFINITION Let T be a tree. If T has at least two vertices, then a vertex of degree 1 in T is called a leaf (or a terminal vertex), and a vertex of degree greater than 1 in T is called an internal vertex (or a branch vertex). The unique vertex in a trivial tree is also called a leaf or
  • 89. EXAMPLE Find all leaves (or terminal vertices) and all internal (or branch) vertices in the following tree:
  • 90. THEOREM 1 (MAIN) For any positive integer n, any tree with n vertices has n โ€“ 1 edges.
  • 91. THEOREM 1 (MAIN) For any positive integer n, any tree with n vertices has n โ€“ 1 edges.
  • 92. EXAMPLE A graph G has ten vertices and twelve edges. Is it a tree? What if it has nine edges. Is it now a tree?
  • 93. LEMME If G is any connected graph, C is any circuit in G, and any one of the edges of C is removed from G, then the graph that remains is connected.
  • 94. THEOREM 2 (MAIN) For any positive integer n, if G is a connected graph with n vertices and n โ€“ 1 edges, then G is a tree.
  • 95. EXAMPLE Give an example of a graph with five vertices and four edges that is not a tree.
  • 96. EXAMPLE Although it is true that every connected graph with n vertices and n - 1 edges (where n is a positive integer) is a tree, it is not true that every graph with n vertices and n โ€“ 1 edges is a tree.
  • 97. THEOREM 2 (COL..) If G is any graph with i vertices and m edges, where m and n are positive integers and m โ‰ฅ n, then G has a circuit.
  • 98. ROOTED TREES Let us grant that the pursuit of mathematics is a divine madness of the human spirit, a refuge from the goading urgency of contingent happenings. โ€”Alfred North Whitehead, 1861โ€“1947
  • 99. DEFINITION A rooted tree is a tree in which there is one vertex that is distinguished from the others and is called the root. The level of a vertex is the number of edges along the unique path between it and the root. The height of a rooted tree is the maximum level of any vertex of the tree.
  • 100. DEFINITION Given the root or any internal vertex v of a rooted tree, the children of v are all those vertices that are adjacent to v and are one level farther away from the root than v. If w is a child of v, then v is called the parent of w, and two distinct vertices that are both children of the same parent are called siblings.
  • 101. DEFINITION Given two distinct vertices v and w, if v lies on the unique path between w and the root, then v is an ancestor of w and w is a descendant of v.
  • 103. EXAMPLE 1 Consider the tree with root v0. a. What is the level of v5? b. What is the level of v0? c. What is the height of this rooted tree? d. What are the children of v3? e. What is the parent of v2? f. What are the siblings of v8? g. What are the descendants of v3? h. How many leaves (terminal vertices) are on the tree?
  • 104. EXAMPLE 2 The root is v0, v1 has level 1, v1 is the child of v0, and both v0 and v1 are leaves (terminal vertices). v0 v 1
  • 105. BINARY TREES Let us grant that the pursuit of mathematics is a divine madness of the human spirit, a refuge from the goading urgency of contingent happenings. โ€”Alfred North Whitehead, 1861โ€“1947
  • 106. DEFINITION A binary tree is a rooted tree in which every parent has at most two children. Each child in a binary tree is designated either a left child or a right child (but not both), and every parent has at most one left child and one right child. A full binary tree is a binary tree in which each parent has exactly two children.
  • 107. DEFINITION Given any parent v in a binary tree T, if v has a left child, then the left subtree of v is the binary tree whose root is the left child of v, whose vertices consist of the left child of v and all its descendants, and whose edges consist of all those edges of T that connect the vertices of the left subtree. The right subtree of v is defined analogously.
  • 109. EXAMPLE 1 Draw a binary tree to represent the expression ๐‘Ž โˆ’ ๐‘ ร— ๐‘ + ๐‘‘ ๐‘’ .
  • 111. THEOREM 1 If k is a positive integer and T is a full binary tree with k internal vertices, then (1) T has a total of 2k + 1 vertices, and (2) T has k + 1 leaves.
  • 112. EXAMPLE 2 Is there a full binary tree that has 10 internal vertices and 13 terminal vertices?
  • 113. THEOREM 2 For every integer h โ‰ฅ 0, if T is any binary tree with height h and t leaves, then t โ‰ค 2h Equivalently: log2 t โ‰ค h
  • 114. EXAMPLE 3 Is there a binary tree that has height 5 and 38 leaves?
  • 115. BINARY SEARCH TREES Let us grant that the pursuit of mathematics is a divine madness of the human spirit, a refuge from the goading urgency of contingent happenings. โ€”Alfred North Whitehead, 1861โ€“1947
  • 116. DEFINITION A binary search tree is a kind of binary tree in which data records, such as customer information, can be stored, searched, and processed very efficiently.
  • 117. PROPERTY For every internal vertex v, all the keys in the left subtree of v are less than the key in v, and all the keys in the right subtree of v are greater than the key in v.
  • 118. MATRIX REPRESENTATIONS OF GRAPHS Order and simplification are the first steps toward the mastery of a subject. โ€”Thomas Mann, The Magic Mountain, 1924
  • 119. DEFINITION Matrices are two-dimensional analogues of sequences. They are also called two-dimensional arrays.
  • 120. DEFINITION An m x n (read โ€œm by nโ€) matrix A over a set S is a rectangular array of elements of S arranged into m rows and n columns:
  • 121. DEFINITION ๐ด = ๐‘Ž11 ๐‘Ž12 โ‹ฏ ๐‘Ž21 ๐‘Ž22 โ‹ฏ โ‹ฎ โ‹ฎ ๐‘Ž1๐‘— โ‹ฏ ๐‘Ž1๐‘› ๐‘Ž2๐‘— โ‹ฏ ๐‘Ž2๐‘› โ‹ฎ โ‹ฎ ๐‘Ž๐‘–1 ๐‘Ž๐‘–2 โ‹ฏ โ‹ฎ โ‹ฎ ๐‘Ž๐‘š1 ๐‘Ž๐‘š2 โ‹ฏ ๐‘Ž๐‘–๐‘— โ‹ฏ ๐‘Ž๐‘–๐‘› โ‹ฎ โ‹ฎ ๐‘Ž๐‘š๐‘— โ‹ฏ ๐‘Ž๐‘š๐‘› ith row of A jth column of A
  • 122. DEFINITION The ith row of A is ๐‘Ž๐‘–1 ๐‘Ž๐‘–2 โ‹ฏ ๐‘Ž๐‘–๐‘› and the jth column of A is ๐‘Ž1๐‘— ๐‘Ž2๐‘— โ‹ฎ ๐‘Ž๐‘š๐‘—
  • 123. DEFINITION The entry aij in the ith row and jth column of A is called the ijth entry of A. An m x n matrix is said to have size m x n.
  • 124. DEFINITION If A and B are matrices, then A = B if, and only if, A and B have the same size and the corresponding entries of A and B are all equal; that is, a = b for every i = 1, 2, . . . , m and j = 1, 2, . . .
  • 125. DEFINITION A matrix for which the numbers of rows and columns are equal is called a square matrix. If A is a square matrix of size n x n, then the main diagonal of A consists of all the entries a11, a22, . . . , ann.
  • 126. DEFINITION ๐‘Ž11 ๐‘Ž12 โ‹ฏ ๐‘Ž21 ๐‘Ž22 โ‹ฏ โ‹ฎ โ‹ฎ ๐‘Ž1๐‘— โ‹ฏ ๐‘Ž1๐‘› ๐‘Ž2๐‘— โ‹ฏ ๐‘Ž2๐‘› โ‹ฎ โ‹ฎ ๐‘Ž๐‘–1 ๐‘Ž๐‘–2 โ‹ฏ โ‹ฎ โ‹ฎ ๐‘Ž๐‘›1 ๐‘Ž๐‘›2 โ‹ฏ ๐‘Ž๐‘–๐‘– โ‹ฏ ๐‘Ž๐‘–๐‘› โ‹ฎ โ‹ฎ ๐‘Ž๐‘›๐‘– โ‹ฏ ๐‘Ž๐‘›๐‘› main diagonal of A
  • 127. EXAMPLE 1 The following is a 3 x 3 matrix over the set of integers ๐ด = 1 0 โˆ’3 4 โˆ’1 5 โˆ’2 2 0 a. What is a23, the entry in row 2, column 3? b. What is the second column of A? c. What are the entries in the main diagonal of A?
  • 129. MATRICES AND DIRECTED GRAPHS A is called the adjacency matrix of the directed graph.
  • 130. MATRICES AND DIRECTED GRAPHS Let G be a directed graph with ordered vertices v1, v2, . . . , vn. The adjacency matrix of G is the n x n matrix A = (aij) over the set of nonnegative integers such that aij = the number of arrows from vi to vj for all i, j = 1, 2, . . . , n
  • 131. EXAMPLE 2 The two directed graphs shown below differ only in the ordering of their vertices. Find their adjacency matrices.
  • 132. EXAMPLE 2 (ANS) The two directed graphs shown below differ only in the ordering of their vertices. Find their adjacency matrices. ๐ด๐‘Ž = 0 0 0 0 1 1 2 1 0
  • 133. EXAMPLE 2 (ANS) The two directed graphs shown below differ only in the ordering of their vertices. Find their adjacency matrices. ๐ด๐‘ = 1 1 0 1 0 2 0 0 0
  • 134. EXAMPLE 3 Let ๐ด = 0 1 1 1 1 0 0 2 0 0 2 1 1 1 0 0 Draw a directed graph that has A as its adjacency matrix
  • 135. EXAMPLE 3 (ANS) ๐ด = ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 ๐‘ฃ4 ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 ๐‘ฃ4 0 1 1 1 1 0 0 2 0 0 2 1 1 1 0 0
  • 136. MATRICES AND UNDIRECTED GRAPHS Let G be an undirected graph with ordered vertices v1, v2, . . . , vn.The adjacency matrix of G is the n x n matrix A = (aij) over the set of nonnegative integers such that aij = the number of edges connecting vi and vj for every i and j = 1, 2, . . . , n.
  • 137. EXAMPLE 4 Find the adjacency matrix for the graph G.
  • 138. EXAMPLE 4 (ANS) ๐ด = ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 ๐‘ฃ4 ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 ๐‘ฃ4 0 1 1 1 0 1 2 1 0 2 1 1 0 0 0 1
  • 139. MATRICES AND CONNECTED COMPONENTS Consider a graph G, as shown below, that consists of several connected components.
  • 140. EXAMPLE 5 Consider a graph G, as shown below, that consists of several connected components.
  • 141. EXAMPLE 5 (ANS) Let G be a graph with connected components G1, G2, . . . , Gk. If there are ni vertices in each connected component Gi and these vertices are numbered consecutively, then the adjacency matrix of G has the form ๐ด1 O O O ๐ด2 O โ‹ฏ O O โ‹ฏ O O O O ๐ด3 โ‹ฎ O โ‹ฎ O โ‹ฎ O โ‹ฏ O O โ‹ฏ โ‹ฎ O โ‹ฎ ๐ด๐‘˜ where each Ai is the ni x ni adjacency matrix of Gi , for every i = 1, 2, . . . , k, and the Oโ€™s represent matrices whose entries are all
  • 142.
  • 143.

Editor's Notes

  1. The subject of graph theory began in the year 1736 when the great mathematician Leonhard Euler published a paper giving the solution to the following puzzle: The town of Kรถnigsberg in Prussia (now Kaliningrad in Russia) was built at a point where two branches of the Pregel River came together. It consisted of an island and some land along the river banks. These were connected by seven bridges as shown in Figure 10.1.1. The question is this: Is it possible for a person to take a walk around town, starting and ending at the same location and crossing each of the seven bridges exactly once? *In his original paper, Euler did not require the walk to start and end at the same point. The analysis of the problem is simplified, however, by adding this condition. Later in the section we discuss walks that start and end at different points.
  2. *In his original paper, Euler did not require the walk to start and end at the same point. The analysis of the problem is simplified, however, by adding this condition.
  3. To solve this puzzle, Euler translated it into a graph theory problem. He noticed that all points of a given land mass can be identified with each other since a person can travel from any one point to any other point of the same land mass without crossing a bridge.
  4. Thus for the purpose of solving the puzzle, the map of Kรถnigsberg can be identified with the graph shown in Figure, in which the vertices A, B, C, and D represent land masses and the seven edges represent the seven bridges. So, if it is possible to find a route that uses all the edges of the graph and starts and ends at A, then the total number of arrivals and departures from each vertex B, C, and D must be a multiple of 2. Or, in other words, the degrees of the vertices B, C, and D must be even. But they are not: deg(B) 5 5, deg(C) 5 3, and deg(D) 5 3. Hence there is no route that solves the puzzle by starting and ending at A. Similar reasoning can be used to show that there are no routes that solve the puzzle by starting and ending at B, C, or D. Therefore, it is impossible to travel all around the city crossing each bridge exactly once.
  5. So, if it is possible to find a route that uses all the edges of the graph and starts and ends at A, then the total number of arrivals and departures from each vertex B, C, and D must be a multiple of 2. Or, in other words, the degrees of the vertices B, C, and D must be even. But they are not: deg(B) = 5, deg(C) = 3, and deg(D) = 3. Hence there is no route that solves the puzzle by starting and ending at A. Similar reasoning can be used to show that there are no routes that solve the puzzle by starting and ending at B, C, or D. Therefore, it is impossible to travel all around the city crossing each bridge exactly once.
  6. *In his original paper, Euler did not require the walk to start and end at the same point. The analysis of the problem is simplified, however, by adding this condition.
  7. Certain types of sequences of adjacent vertices and edges are of special importance in graph theory: those that do not have a repeated edge, those that do not have a repeated vertex, and those that start and end at the same vertex
  8. Certain types of sequences of adjacent vertices and edges are of special importance in graph theory: those that do not have a repeated edge, those that do not have a repeated vertex, and those that start and end at the same vertex
  9. Certain types of sequences of adjacent vertices and edges are of special importance in graph theory: those that do not have a repeated edge, those that do not have a repeated vertex, and those that start and end at the same vertex
  10. This walk has a repeated vertex but does not have a repeated edge, so it is a trail from v1 to v4 but not a path. This is just a walk from v1 to v5. It is not a trail because it has a repeated edge. This walk starts and ends at v2, contains at least one edge, and does not have a repeated edge, so it is a circuit. Since the vertex v3 is repeated in the middle, it is not a simple circuit. This walk starts and ends at v2, contains at least one edge, does not have a repeated edge, and does not have a repeated vertex. Thus it is a simple circuit. This is just a closed walk starting and ending at v1. It is not a circuit because edge e1 is repeated. The first vertex of this walk is the same as its last vertex, but it does not contain an edge, and so it is not a circuit. It is a closed walk from v1 to v1. (It is also a trail from v1 to v1.)
  11. This walk has a repeated vertex but does not have a repeated edge, so it is a trail from v1 to v4 but not a path. This is just a walk from v1 to v5. It is not a trail because it has a repeated edge. This walk starts and ends at v2, contains at least one edge, and does not have a repeated edge, so it is a circuit. Since the vertex v3 is repeated in the middle, it is not a simple circuit. This walk starts and ends at v2, contains at least one edge, does not have a repeated edge, and does not have a repeated vertex. Thus it is a simple circuit. This is just a closed walk starting and ending at v1. It is not a circuit because edge e1 is repeated. The first vertex of this walk is the same as its last vertex, but it does not contain an edge, and so it is not a circuit. It is a closed walk from v1 to v1. (It is also a trail from v1 to v1.)
  12. The subject of graph theory began in the year 1736 when the great mathematician Leonhard Euler published a paper giving the solution to the following puzzle: The town of Kรถnigsberg in Prussia (now Kaliningrad in Russia) was built at a point where two branches of the Pregel River came together. It consisted of an island and some land along the river banks. These were connected by seven bridges as shown in Figure 10.1.1. The question is this: Is it possible for a person to take a walk around town, starting and ending at the same location and crossing each of the seven bridges exactly once? *In his original paper, Euler did not require the walk to start and end at the same point. The analysis of the problem is simplified, however, by adding this condition. Later in the section we discuss walks that start and end at different points.
  13. It is easy to understand the concept of connectedness on an intuitive level. Roughly speaking, a graph is connected if it is possible to travel from any vertex to any other vertex along a sequence of adjacent edges of the graph. The formal definition of connectedness is stated in terms of walks.
  14. Solution The graph represented in (a) is connected, whereas those of (b) and (c) are not. To understand why (c) is not connected, recall that in a drawing of a graph, two edges may cross at a point that is not a vertex. Thus the graph in (c) can be redrawn as follows: Some useful facts relating circuits and connectedness are collected in the following lemma. Proofs of (a) and (b) are left for the exercises. The proof of (c) is in Section 10.4.
  15. G has three connected components: H1, H2, and H3 with vertex sets V1, V2, and V3 and edge sets E1, E2, and E3, where V1 = {v1, v2, v3}, E1 = {e1, e2}, V2 = {v4}, E2 = NULL, V3 = {v5, v6, v7, v8}, E3 = {e3, e4, e5}.
  16. Note: If every vertex of a graph has positive even degree, it is not necessarily an Euler circuit.
  17. Ans: Vertices v1 and v3 both have degree 3, which is odd. Hence by (the contrapositive form of) Theorem, this graph does not have an Euler circuit. Try solving the 1st problem in the first part of this ppt.
  18. Note: If every vertex of a graph has positive even degree, it is not necessarily an Euler circuit. Note that the graph in the preceding drawing is not connected. It turns out that although the converse of Theorem 10.1.2 is false, a modified converse is true: If every vertex of a graph has positive even degree and if the graph is connected, then the graph has an Euler circuit. The proof of this fact is constructive: It contains an algorithm to find an Euler circuit for any connected graph in which every vertex has even degree
  19. [This step can be performed for the following reasons: Since the degree of each vertex of G is a positive even integer, as each vertex of G is entered by traveling on one edge, either the vertex is v itself and there is no other unused edge adjacent to v, or the vertex can be exited by traveling on another previously unused edge. Since the number of edges of the graph is finite (by definition of graph), the sequence of distinct edges cannot go on forever. The sequence eventually returns to v because the degree of v is a positive even integer, and so each time an edge leads out from v to another vertex, there must be a different edge that connects back in to v.]
  20. [This step can be performed for the following reasons: Since the degree of each vertex of G is a positive even integer, as each vertex of G is entered by traveling on one edge, either the vertex is v itself and there is no other unused edge adjacent to v, or the vertex can be exited by traveling on another previously unused edge. Since the number of edges of the graph is finite (by definition of graph), the sequence of distinct edges cannot go on forever. The sequence eventually returns to v because the degree of v is a positive even integer, and so each time an edge leads out from v to another vertex, there must be a different edge that connects back in to v.]
  21. [Note that Gโ€™ may not be connected (as illustrated in Figure 10.1.5), but every vertex of Gโ€™ has positive, even degree (since removing the edges of C removes an even number of edges from each vertex, the difference of two even integers is even, and isolated vertices with degree 0 were removed).]
  22. [There must be at least one such vertex since G is connected. (See exercise 50.) (In Figure 10.1.5 there are two such vertices: u and w.)
  23. [This can be done since each vertex of G9 has positive, even degree and G9 is finite. See the justification for step 2.]
  24. [The effect of executing steps 3c and 3d for the graph of Figure 10.1.5 is shown in Figure 10.1.6.
  25. Since the graph G is finite, execution of the steps outlined in this algorithm must eventually terminate. At that point an Euler circuit for G will have been constructed. (Note that because of the element of choice in steps 1, 2, 3b, and 3c, a variety of different Euler circuits can be produced by using this algorithm.)
  26. Each vertex of this graph has even degree except for A and B, each of which has degree 1. Hence by Corollary 10.1.5, there is an Euler trail from A to B. One such trail is A G H F E I H E K J D C B.
  27. In 1859 the Irish mathematician Sir William Rowan Hamilton introduced a puzzle in the shape of a dodecahedron (DOH-dek-a-HEE-dron). Each vertex was labeled with the name of a cityโ€”London, Paris, Hong Kong, New York, and so on. The problem Hamilton posed was to start at one city and tour the world by visiting each other city exactly once and returning to the starting city. One way to solve the puzzle is to imagine the surface of the dodecahedron stretched out and laid flat in the plane, as follows:
  28. One solution is the circuit A B C D E F G H I J K L M N O P Q R S T A,
  29. An Euler circuit for a graph G must include every vertex of G, it may visit some vertices more than once and hence may not be a Hamiltonian circuit. On the other hand, a Hamiltonian circuit for G does not need to include all the edges of G and hence may not be an Euler circuit.
  30. Since C is a simple circuit, all the ei are distinct and all the vj are distinct except that v0 = vn.
  31. Let H be the subgraph of G that is formed using the vertices and edges of C. An example of such an H is shown below. Note that H has the same number of edges as it has vertices since all its edges are distinct and so are its vertices. Also, by definition of Hamiltonian circuit, every vertex of G is a vertex of H, and H is connected since any two of its vertices lie on a circuit. In addition, every vertex of H has degree 2. The reason for this is that there are exactly two edges incident on any vertex. These are ei and ei11 for any vertex vj except v0 = vn, and they are e1 and en for v0 (5vn). These observations have established the truth of the following proposition in all cases where G has at least two vertices
  32. Since C is a simple circuit, all the ei are distinct and all the vj are distinct except that v0 = vn.
  33. If G has a Hamiltonian circuit, then by Proposition 10.1.6, G has a subgraph H that (1) contains every vertex of G, (2) is connected, (3) has the same number of edges as vertices, and (4) is such that every vertex has degree 2. Suppose such a subgraph H exists. In other words, suppose there is a connected subgraph H of G such that H has five vertices (a, b, c, d, e) and five edges and such that every vertex of H has degree 2. Since the degree of b in G is 4 and every vertex of H has degree 2, two edges incident on b must be removed from G to create H. Edge {a, b} cannot be removed because if it were, vertex a would have degree less than 2 in H. Similar reasoning shows that edges {e, b}, {b, a}, and {b, d} cannot be removed either. It follows that the degree of b in H must be 4, which contradicts the condition that every vertex in H has degree 2 in H. Hence no such subgraph H exists, and so G does not have a Hamiltonian circuit.
  34. This problem can be solved by writing all possible Hamiltonian circuits starting and ending at A and calculating the total distance traveled for each. Thus either route A B C D A or A D C B A gives a minimum total distance of 125ย  kilometers The general traveling salesman problem involves finding a Hamiltonian circuit to minimize the total distance traveled for an arbitrary graph with n vertices in which each edge is marked with a distance. One way to solve the general problem is to use the method of Example 10.1.10: Write down all Hamiltonian circuits starting and ending at a particular vertex, compute the total distance for each, and pick one for which this total is minimal. However, even for medium-sized values of n this method is impractical. For a complete graph with 30 vertices, it would be necessary to check (29!)/2 > 4.42 3 1030 Hamiltonian circuits that start and end at a particular vertex. Even if each circuit could be found and its total distance computed in just one nanosecond, it would require approximately 1.4 3 1014 years to finish the computation. At present, there is no known algorithm for solving the general traveling salesman problem that is more efficient. However, there are efficient algorithms that find โ€œpretty goodโ€ solutionsโ€”that is, circuits that, while not necessarily having the least possible total distances, have smaller total distances than most other Hamiltonian circuits
  35. Since the student scored 9 on part I, the score on part II is checked. Since it is greater than 6, the student should be advised to take Math 110.
  36. In the study of linguistics, syntax refers to the grammatical structure of sentences, and semantics refers to the meanings of words and their interrelations. A sentence can be syntactically correct but semantically incorrect, as in the nonsensical sentence โ€œThe young ball caught the man,โ€ which can be derived from the rules given above. Or a sentence can contain syntactic errors but not semantic ones, as, for instance, when a two-year-old child says, โ€œMe hungry!โ€
  37. There is a somewhat surprising relation between the number of vertices and the number of edges of a tree. It turns out that if n is a positive integer, then any tree with n vertices (no matter what its shape) has n-1 edges. Perhaps even more surprisingly, a partial converse to this fact is also trueโ€”namely, any connected graph with n vertices and n21 edges is a tree. It follows from these facts that if even one new edge (but no new vertex) is added to a tree, the resulting graph must contain a circuit. Also, from the fact that removing an edge from a circuit does not disconnect a graph, it can be shown that every connected graph has a subgraph that is a tree. It follows that if n is a positive integer, any graph with n vertices and fewer than n21 edges is not connected. A small but very important fact necessary to derive the first main theorem about trees is that any nontrivial tree must have at least one vertex of degree 1
  38. A constructive way to understand this lemma is to imagine being given a tree T with more than one vertex. You pick a vertex v at random and then search outward along a path from v looking for a vertex of degree 1. As you reach each new vertex, you check whether it has degree 1. If it does, you are finished. If it does not, you exit from the vertex along a different edge from the one you entered on. Because T is circuit-free, the vertices included in the path never repeat. And since the number of vertices of T is finite, the process of building a path must eventually terminate. When that happens, the final vertex vโ€™ of the path must have degree 1. This process is illustrated below.
  39. [If there were no edge incident on v, then v would be an isolated vertex. But this would contradict the assumption that T is connected (since it is a tree) and has at least two vertices.]
  40. Solution The leaves (or terminal vertices) are v0, v2, v4, v5, v7, and v8. The internal (or branch) vertices are v6, v1, and v3.
  41. The proof is by mathematical induction. In the inductive step, we assume that any tree with k vertices has k-1 edges, and our job is to show that any tree with k+1 vertices has k edges. To do this, we start with an arbitrarily chosen tree T with k+1 vertices. Then we try to find a vertex and an edge that we can remove from T to create a sub-tree Tโ€™ with k vertices. If this step is successful, we can apply the inductive hypothesis to show that Tโ€™ has k-1 edges, and when we replace the vertex and edge that we removed, we can conclude that T has k edges.
  42. In order to find the vertex and edge to remove from T, we use Lemma 10.4.1, which states that T has a vertex v of degree 1. Since T is connected, v is attached to the rest of T by a single edge e as sketched below. If e and v are removed from T, what remains is a tree Tโ€™ with (k+1)-1 = k vertices. By inductive hypothesis, then, Tโ€™ has k-1 edges. Now the original tree T has one more vertex and one more edge than Tโ€™. Hence T must have (k-1)+1 = k edges. A formal version of this argument is given below.
  43. No. By Theorem, any tree with ten vertices has nine edges, not twelve.
  44. The second major theorem about trees is a modified converse for the previous Theorem. Although it is true that every connected graph with n vertices and n21 edges (where n is a positive integer) is a tree, it is not true that every graph with n vertices and n21 edges is a tree
  45. By Theorem 2, such a graph cannot be connected. One example of such an unconnected graph
  46. By Theorem 2, such a graph cannot be connected. One example of such an unconnected graph
  47. An outdoor tree is rooted and so is the kind of family tree that shows all the descendants of one particular person. The terminology and notation of rooted trees blends the language of botanical trees and that of family trees. In mathematics, a rooted tree is a tree in which one vertex has been distinguished from the others and is designated the root. Given any other vertex v in the tree, there is a unique path from the root to v. (After all, if there were two distinct paths, a circuit could be constructed.) The number of edges in such a path is called the level of v, and the height of the tree is the length of the longest such path. It is traditional in drawing rooted trees to place the root at the top (as is done in family trees) and show the branches descending from it
  48. a. 2 b. 0 c. 3 d. v5 and v6 e. v0 f. v7 and v9 g. v5, v6, v10 h. 6
  49. When every vertex in a rooted tree has at most two children and each child is designated either the (unique) left child or the (unique) right child, the result is a binary tree.
  50. When every vertex in a rooted tree has at most two children and each child is designated either the (unique) left child or the (unique) right child, the result is a binary tree.
  51. Binary trees are used in many ways in computer science. One use is to represent algebraic expressions with arbitrary nesting of balanced parentheses. For instance, the following (labeled) binary tree represents the expression ayb: The operator is at the root and acts on the left and right children of the root in left-to-right order. More generally, the binary tree shown below represents the expression ay(c1d). In such a representation, the internal vertices are arithmetic operators, the leaves are variables, and the operator at each vertex acts on its left and right subtrees in left-to-right order
  52. An interesting theorem about binary trees says that if you know the number of internal vertices of a full binary tree, then you can calculate both the total number of vertices and the number of leaves, and conversely. More specifically, a full binary tree with k internal vertices has a total of 2k11 vertices of which k11 are leaves
  53. No. By Theorem, a full binary tree with 10 internal vertices has 10+1 = 11 leaves, not 13.
  54. No. By Theorem, any binary tree T with height 5 has at most 25 = 32 leaves, so such a tree cannot have 38 leaves.
  55. A binary search tree is a kind of binary tree in which data records, such as customer information, can be stored, searched, and processed very efficiently. To place records into a binary search tree, it must be possible to arrange them in a total order. In case they do not have a natural total order of their own, an element of a totally ordered set, such as a number or a word and called a key, may be added to each record. The keys are inserted into the vertices of the tree and provide access to the records to which they are attached
  56. A binary search tree is a kind of binary tree in which data records, such as customer information, can be stored, searched, and processed very efficiently. To place records into a binary search tree, it must be possible to arrange them in a total order. In case they do not have a natural total order of their own, an element of a totally ordered set, such as a number or a word and called a key, may be added to each record. The keys are inserted into the vertices of the tree and provide access to the records to which they are attached
  57. How can graphs be represented inside a computer? It happens that all the information needed to specify a graph can be conveyed by a structure called a matrix, and matrices (matrices is the plural of matrix) are easy to represent inside computers. This section contains some basic definitions about matrices and matrix operations, a description of the relation between graphs and matrices, and some applications
  58. a23=5 0 โˆ’1 2 1, -1, and 0
  59. Consider the directed graph shown. This graph can be represented by the matrix A = (aij ) for which aij = the number of arrows from vi to vj , for every i = 1, 2, 3 and j = 1, 2, 3. Thus a11 = 1 because there is one arrow from v1 to v1; a12 = 0 because there is no arrow from v1 to v2, a23 = 2 because there are two arrows from v2 to v3, and so forth. A is called the adjacency matrix of the directed graph. For convenient reference, the rows and columns of A are often labeled with the vertices of the graph G.
  60. Consider the directed graph shown. This graph can be represented by the matrix A = (aij ) for which aij = the number of arrows from vi to vj , for every i = 1, 2, 3 and j = 1, 2, 3. Thus a11 = 1 because there is one arrow from v1 to v1; a12 = 0 because there is no arrow from v1 to v2, a23 = 2 because there are two arrows from v2 to v3, and so forth. A is called the adjacency matrix of the directed graph. For convenient reference, the rows and columns of A are often labeled with the vertices of the graph G.
  61. Note that nonzero entries along the main diagonal of an adjacency matrix indicate the presence of loops, and off-diagonal entries larger than 1 correspond to parallel edges. Moreover, if the vertices of a directed graph are reordered, then the entries in the rows and columns of the corresponding adjacency matrix are moved around.
  62. ๐ด= ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 0 0 0 0 1 1 2 1 0 ๐ด= ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 1 1 0 1 0 2 0 0 0
  63. Since both graphs have three vertices, both adjacency matrices are 3 3 3 matrices. For (a), all entries in the first row are 0 since there are no arrows from v1 to any other vertex. For (b), the first two entries in the first row are 1 and the third entry is 0 since from v1 there are single arrows to v1 and to v2 and no arrows to v3. Continuing the analysis in this way, you obtain the following two adjacency matrices: ๐ด= ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 0 0 0 0 1 1 2 1 0 ๐ด= ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 1 1 0 1 0 2 0 0 0 If you are given a square matrix with nonnegative integer entries, you can construct a directed graph with that matrix as its adjacency matrix. However, the matrix does not tell you how to label the edges, so the directed graph is not uniquely determined.
  64. ๐ด= ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 0 0 0 0 1 1 2 1 0 ๐ด= ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 1 1 0 1 0 2 0 0 0
  65. Let G be the graph corresponding to A, and let v1, v2, v3, and v4 be the vertices of G. Label A across the top and down the left side with these vertex names, as shown below. ๐ด= ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 ๐‘ฃ4 ๐‘ฃ1 ๐‘ฃ2 ๐‘ฃ3 ๐‘ฃ4 0 1 1 1 1 0 0 2 0 0 2 1 1 1 0 0 Then, for instance, the 2 in the fourth row and the first column means that there are two arrows from v4 to v1. The 0 in the first row and the fourth column means that there is no arrow from v1 to v4. A corresponding directed graph is shown on the next page (without edge labels because the matrix does not determine those).
  66. Once you know how to associate a matrix with a directed graph, the definition of the matrix corresponding to an undirected graph should seem natural to you. As before, you must order the vertices of the graph, but in this case you simply set the i j th entry of the adjacency matrix equal to the number of edges connecting the i th and j th vertices of the graph.