Directed Graphs Help Center

Learn more

Warning: The hard deadline has passed. You can attempt it, but you will not get credit for it. You are welcome to try it as a learning exercise.

To specify an array or sequence of values in an answer, separate the values in
the sequence by whitespace. For example, if the question asks for the first
ten powers of two (starting at 1), then the following answer is acceptable:

1 2 4 8 16 32 64 128 256 512

If you wish to discuss a particular question and answer in the forums, please
post the entire question and answer, including the seed (which can be used by
the course staff to uniquely identify the question) and the explanation (which
contains the correct answer).

Question 1

(seed = 188315)
Consider the adjacency-lists representation of a digraph with 8 vertices and 13 edges:

A: B
B: F C
C: D
D: H
E: A F
F: G C A
G: H C
H: C


Here is a graphical representation of the same digraph:

(A)------------>(B)------------>(C)------------>(D)
^^ | ^^^ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \ | / | \ |
| \v/ | \v
(E)------------>(F)------------>(G)------------>(H)



Run breadth-first search (using the adjacency-lists representation), starting from vertex A.
Give the sequence in which the vertices are dequeued from the FIFO queue.
Your answer should be a sequence of uppercase letters, starting with A.

Question 2

(seed = 53033)
Consider the adjacency-lists representation of a DAG with 8 vertices and 13 edges:

A:
B: A C F
C: H D
D:
E: B F A
F: C
G: F C H
H: D


Here is a graphical representation of the same DAG:

(A)<------------(B)------------>(C)------------>(D)
^ ^| ^^\ ^
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
| / | / | \ |
|/ v/ | v|
(E)------------>(F)<------------(G)------------>(H)



Give the topological order of the vertices that results from the DFS-based
topological sort algorithm. As usual, perform the first DFS from vertex A.
Your answer should be a sequence of 8 uppercase letters.

Question 3

(seed = 628194)
Consider the adjacency-lists representation of a digraph G with 10 vertices and 17 edges:

A: F
B: C A
C:
D: C I H
E: D J
F: G
G: B A H
H: B C
I: H E
J: I


Here is a graphical representation of the same digraph G:

(A)<------------(B)------------>(C)<------------(D)<------------(E)
|^ ^^ ^ /| ^|
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
| \ | \ | / | / |
v \| \|v v/ v
(F)------------>(G)------------>(H)<------------(I)<------------(J)



Compute the strongly-connected components of the digraph using the Kosaraju-Sharir algorithm.
Assume that the first depth-first search of Kosaraju-Sharir computes the reverse postorder of G^R:

C A B H I D J E G F

Give the sequence of the 10 integers in the id[] array for the vertices A through J.

v A B C D E F G H I J
------------------------------------
id[v]
    
You cannot submit your work until you agree to the Honor Code. Thanks!