Chapter Questions
Find the adjacency matrix and adjacency relation for the graph in the figure.SHEET 78 +1
Rework Example 3 of Chapter 2 using the theorem on Euler paths.
Decide by trial and error whether Hamiltonian circuits exist for the graphs of the given exercise.
Exercise 6
Use the accompanying graph. Apply algorithm ShortestPath (Dijkstra's algorithm) for the pairs of nodes given; show the values for $p$ and $I N$ and the $d$-values and $s$-values for each pass through the while loop. Write out the nodes in the shortest path and its distance.
From 2 to 5
Write the nodes in a depth-first search of the following graph, beginning with the node specified.(GRAPH CANT COPY)
$a$
Draw the depth-first search trees, where node $a$ is the starting node of the depth-first search. Identify the back arcs.
(GRAPH CANT COPY)
Find the adjacency matrix and adjacency relation for the graph in the figure.(FIG CANT COPY)
Determine whether the specified graph has an Euler path by using the theorem on Euler paths.
(FIG CANT COPY)
Recall that $K_n$ denotes the simple, complete graph of order $n$.a. For what values of $n$ does an Euler path exist in $K_n$ ?b. For what values of $n$ does a Hamiltonian circuit exist in $K_n$ ?
From 3 to 6
$c$
Find the corresponding directed graph and adjacency relation for the following adjacency matrix.
$$\mathbf{A}=\left[\begin{array}{lllll}0 & 0 & 0 & 1 & 0 \\0 & 0 & 0 & 0 & 1 \\0 & 0 & 0 & 0 & 0 \\0 & 1 & 0 & 0 & 0 \\0 & 0 & 1 & 1 & 0\end{array}\right]$$
From 1 to 5
$d$
$$\mathbf{A}=\left[\begin{array}{lllll}0 & 0 & 0 & 0 & 0 \\1 & 0 & 0 & 0 & 1 \\0 & 1 & 0 & 1 & 0 \\0 & 1 & 0 & 0 & 0 \\0 & 0 & 0 & 1 & 0\end{array}\right]$$
From 4 to 7
$g$
Given the adjacency relation $\rho=\{(1,4),(1,5),(1,6),(6,2),(6,3),(6,5)\}$ on the set $N=\{1,2,3,4,5,6\}$, find the corresponding directed graph and adjacency matrix.
Use the accompanying graph. Apply algorithm ShortestPath (Dijkstra's algorithm) for the pairs of nodes given; show the values for $p$ and $I N$ and the $d$-values and $s$-values for each pass through the while loop. Write out the nodes in the shortest path and its distance.(FIG CANT COPY)
From $a$ to $e$
$e$
Given the adjacency relation $\rho=\{(2,1),(3,2),(3,3),(3,4),(4,5),(6,3),(6,6)\}$ on the set $N=\{1,2,3,4,5,6\}$, find the corresponding directed graph and adjacency matrix.
From $d$ to $a$
$h$
Describe a property of a directed graph whose adjacency matrix is symmetric.
Use the following directed graph. Apply algorithm ShortestPath (Dijkstra's algorithm) to the nodes given; show the values for $p$ and $I N$ and the $d$-values and $s$-values for each pass through the while loop. Write out the nodes in the shortest path and its distance.
From 1 to 7
Use algorithm ArtPoint to find the articulation points. Label the tree number and back number for each node, both as first assigned and as changed. Draw the biconnected components of the graph
Describe the directed graph whose adjacency matrix has all $1 \mathrm{~s}$ in row 1 and column 1 , and 0 s elsewhere.
From 3 to 1
$e $
Describe the directed graph whose adjacency matrix has $1 \mathrm{~s}$ in positions $(i, i+1)$ for $1 \leq i \leq n-1$, a 1 in position $(n, 1)$, and 0 s elsewhere.
a. Modify algorithm ShortestPath so that it finds the shortest paths from $x$ to all other nodes in the graph.b. Does this change the worst-case order of magnitude of the algorithm?
$f$
Describe a property of a directed graph whose adjacency relation is irreflexive (see Exercise 19, Section 4.1).
Give an example to show that algorithm ShortestPath does not work when negative weights are allowed.
Describe a property of the adjacency matrix of a graph whose adjacency relation is antisymmetric.
Draw the adjacency matrix for the graph of Exercise 2. In applying algorithm EulerPath, what is the value of total after the second pass through the while loop?
Use algorithm AnotherShortestPath (the Bellman-Ford algorithm) to find the shortest path from the source node to any other node. Show the successive $d$-values and $s$-values.
Graph for Exercises 1-4, source node $=2$ (compare your answer to Exercise 1)
Write the nodes in a breadth-first search of the graph in the figure for Exercises 1-6, beginning with the node specified.
Adjacency relations $\rho$ and $\sigma$ have the following associated adjacency matrices $\mathbf{R}$ and $\mathbf{S}$. Find the adjacency matrices associated with the relations $\rho \cup \sigma$ and $\rho \cap \sigma$.$$\mathbf{R}=\left[\begin{array}{llll}0 & 1 & 1 & 0 \\0 & 0 & 0 & 1 \\1 & 1 & 0 & 0 \\1 & 0 & 0 & 1\end{array}\right] \quad \mathbf{S}=\left[\begin{array}{llll}0 & 1 & 0 & 0 \\0 & 0 & 1 & 0 \\1 & 0 & 0 & 1 \\1 & 0 & 0 & 0\end{array}\right]$$
Draw the adjacency matrix for the graph of Exercise 4. In applying algorithm EulerPath, what is the value of total after the fourth pass through the while loop?
Graph for Exercises 1-4, source node $=1$ (compare your answer to Exercise 3)
The two directed graphs that follow have adjacency relations $\rho$ and $\sigma$. Draw the graphs associated with the relations $\rho \cup \sigma$ and $\rho \cap \sigma$.
Draw the adjacency matrix for the graph of Exercise 6. In applying algorithm EulerPath, what is the value of $i$ after the while loop is exited?
Graph for Exercises 7 and 8, source node $=1$ (compare your answer to Exercise 7)
The following directed graph represents a binary relation $\rho$ on the nodes. Draw the directed graph that would represent the transitive closure of $\rho$.(FIG CANT COPY)
Draw the adjacency matrix for the graph of Exercise 7. In applying algorithm EulerPath, what is the value of $i$ after the while loop is exited?
Accompanying graph, source node $=1$ (compare your answer to Exercise 10)
Let $\mathbf{A}$ be the matrix$$\mathbf{A}=\left[\begin{array}{llll}1 & 1 & 0 & 1 \\0 & 0 & 1 & 0 \\1 & 0 & 0 & 1 \\1 & 0 & 1 & 0\end{array}\right]$$$$\text { Find the products } \mathbf{A}^2 \text { and } \mathbf{A}^{(2)} \text {. }$$
Exercise 2
Use algorithm AllPairsShortestPath (Floyd's algorithm) to find the distances for all the shortest paths. Show the successive values of the A matrix for each pass through the outer loop.
Figure 6.10
The definition of a connected graph can be extended to directed graphs. Describe the reachability matrix $\mathbf{R}$ for a connected, directed graph.
Exercise 3
Graph for Exercises 1-4
For the following graph, write the reachability matrix $\mathbf{R}$ by simply inspecting the graph.(FIG CANT COPY)
Exercise 4
Use Prim's algorithm to find a minimal spanning tree for the graph in the specified figure.
Write the nodes in a breadth-first search of the graph in the figure for Exercises 7-10, beginning with the node specified.
Exercise 5
Compute the reachability matrix $\mathbf{R}$ by using the formula $\mathbf{R}=$ $\mathbf{A} \vee \mathbf{A}^{(2)} \vee \cdots \vee \mathbf{A}^{(n)}$
Exercise 1
Exercise 7
Exercise 8
Use algorithm AnotherMST (Kruskal's algorithm) to find the minimal spanning tree.
Exercise 9
Graph for Exercise 18
Find an example of an unconnected graph that has an Euler path.
Graph for Exercise 19
Prove that any graph with a Hamiltonian circuit is connected.
Graph for Exercise 20
Write the nodes in a breadth-first search of the graph in the figure for Exercises 21-23, beginning with the node specified.
Compute the reachability matrix $\mathbf{R}$ by using Warshall's algorithm.
Consider a simple, complete graph with $n$ nodes. Testing for a Hamiltonian circuit by trial and error could be done by selecting a fixed starting node and then generating all possible paths from that node of length $n$.a. How many paths of length $n$ are there if repetition of arcs and nodes is allowed?b. How many paths of length $n$ are there if repetition of arcs and nodes is allowed but an arc may not be used twice in succession?c. How many paths of length $n$ are there if nodes and arcs cannot be repeated except for the starting node? (These are the Hamiltonian circuits.)
Give an example to show that adding the node closest to $I N$ at each step, as is done in Prim's minimal spanning tree algorithm, will not guarantee a shortest path.
Is it possible to walk in and out of each room in the house shown in the following figure so that each door of the house is used exactly once? Why or why not?
Let $a$ be the arc of lowest weight in a weighted graph. Show that $a$ must be an arc in any minimal spanning tree.
A city plans to lay out bike paths connecting various city parks. A map with the distances between the parks is shown in the figure. (Some direct connections would have to cross major highways, so these distances are not shown in the map.) Find which paths to pave so that all parks are connected but the cost is minimal.(GRAPH CANT COPY)
In the computer network in the accompanying figure, the same message is to be broadcast from node $C$ to nodes $A, E, F$, and $G$. One way to do this is to find the shortest path from $C$ to each of these nodes and send out multiple copies of the same message. A more efficient approach is to send one copy out from $C$ along a spanning tree for the subgraph containing the nodes involved. Use the depth-first search algorithm to find a spanning tree for the subgraph.
Recall that $K_{m, n}$ denotes a bipartite, complete graph with $m+n$ nodes.a. For what values of $m$ and $n$ does an Euler path exist in $K_{m, n}$ ?b. For what values of $m$ and $n$ does a Hamiltonian circuit exist in $K_{m, n}$ ?
Assume that arc weights represent distance. Then adding new nodes and arcs to a graph may result in a spanning tree for the new graph that has less weight than a spanning tree for the original graph. (The new spanning tree could represent a minimal-cost network for communications between a group of cities obtained by adding a switch in a location outside any of the cities.)a. Find a spanning tree of minimum weight for the following labeled graph. What is its weight?
(GRAPH CANT COPY)b. Put a node in the center of the square. Add new arcs from the center to the corners. Find a spanning tree for the new graph, and compute its (approximate) weight.
Use the depth-first search algorithm to do a topological sort on the following graph. Indicate the counting numbers on the graph. Also state the starting node or nodes for the search.
Consider a connected graph with $2 n$ odd vertices, $n \geq 2$. By the theorem on Euler paths, an Euler path does not exist for this graph.a. What is the minimum number of disjoint Euler paths, each traveling some of the arcs of the graph, necessary to travel each arc exactly once?b. Show that the minimum number is sufficient.
At the beginning of this chapter, you received the following assignment:You realize that you can represent the network as a weighted graph, where the arcs are the connections between nodes and the weights of the arcs represent traffic on the connections.
Prove that a Hamiltonian circuit always exists in a connected graph where every node has degree 2 .
Find a way to traverse a tree in level order, that is, so that all nodes at the same depth are listed from left to right for increasing depth. (Hint: We already have a way to do this.)
Use regular matrix multiplication to obtain information about a graph.
Let $G$ be a directed graph, possibly with parallel arcs, and let $\mathbf{A}$ be its adjacency matrix. Then A may not be a Boolean matrix. Prove that the $i, j$ entry of matrix $\mathbf{A}^2$ is the number of paths of length 2 from node $i$ to node $j$.
Ore's theorem (Oystein Ore, 1960) states that a Hamiltonian circuit exists in any graph $G$ with the following properties:1. $G$ is a simple graph with $n$ nodes, $n \geq 3$.2. For any two nonadjacent nodes $x$ and $y$, degree $(x)+\operatorname{degree}(y) \geq n$.Ore's theorem is proved by contradiction in the following steps.a. Assume that a graph $G$ with properties 1 and 2 above does not have a Hamiltonian circuit. Beginning with $G$, add new edges to produce a simple graph $H$ that does not have a Hamiltonian circuit but would have such a circuit with the addition of any single new arc. Describe a process for creating $H$.b. Prove that $H$ has a Hamiltonian path, that is, a path that visits each node exactly once.c. Denote the nodes on the Hamiltonian path by $p=x_1, x_2, x_3, \ldots, x_{n-1}, x_n=q$. Prove that for any node $x_i, 2 \leq i \leq n-1$, if $x_i-p$ is an arc in $H$, then $x_{i-1}-q$ is not an $\operatorname{arc}$ in $H$.d. Using the result from part (c), prove that in graph $H$, degree $(p)+$ degree $(q)<n$.e. Prove that in graph $G$, degree $(p)+$ degree $(q)<n$.f. Conclude from part (e) that $G$ has a Hamiltonian circuit.
Let $\mathbf{A}$ be the adjacency matrix of a directed graph $G$, possibly with parallel arcs. Prove that the $i, j$ entry of matrix $\mathbf{A}^n$ gives the number of paths of length $n$ from node $i$ to node $j$.
Ore's theorem (Exercise 31) gives a sufficient condition for a Hamiltonian circuit to exist, but it is not a necessary condition. Find a simple graph $G$ with $n$ nodes, $n \geq 3$, that has a Hamiltonian circuit but for which condition (2) does not hold.
For the following graph $G$, count the number of paths of length 2 from node 1 to node 3 . Check by computing $\mathbf{A}^2$.(FIG CANT COPY)
For the following graph $G$, count the number of paths of length 4 from node 1 to node 5 . Check by computing $\mathbf{A}^4$.(FIG CANT COPY)
Let $\rho$ be a binary relation defined on the set $\{0, \pm 1, \pm 2, \pm 4, \pm 16\}$ by $x \rho y \leftrightarrow y=x^2$. Draw the associated directed graph.