chap22-solutions - Selected Solutions for Chapter 22:...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Selected Solutions for Chapter 22: Elementary Graph Algorithms Solution to Exercise 22.1-7 BB T .i; j / D X e 2 E b ie b T ej D X e 2 E b ie b je ± If i D j , then b ie b je D 1 (it is 1 ± 1 or . N 1/ ± . N 1/ ) whenever e enters or leaves vertex i , and 0 otherwise. ± If i ¤ j , then b ie b je D N 1 when e D .i; j / or e D .j; i/ , and 0 otherwise. Thus, BB T .i; j / D ( degree of i D in-degree C out-degree if i D j ; N . # of edges connecting i and j / if i ¤ j : Solution to Exercise 22.2-5 The correctness proof for the BFS algorithm shows that u: d D ı.s; u/ , and the algorithm doesn’t assume that the adjacency lists are in any particular order. In Figure 22.3, if t precedes x in Adj Œw± , we can get the breadth-first tree shown in the figure. But if x precedes t in Adj Œw± and u precedes y in Adj Œx± , we can get edge .x; u/ in the breadth-first tree. Solution to Exercise 22.3-12 The following pseudocode modifies the DFS and DFS-VISIT procedures to assign values to the cc attributes of vertices.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
22-2 Selected Solutions for Chapter 22: Elementary Graph Algorithms DFS .G/ for each vertex u 2 G: V u: color D WHITE u:± D NIL time D 0 counter D 0 for each vertex u 2 G: V if u: color == WHITE counter D counter C 1 DFS-VISIT .G; u; counter / DFS-VISIT .G; u;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

chap22-solutions - Selected Solutions for Chapter 22:...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online