Graph Algorithm Homework Solutions
Algorithm Design Instructions
Note, write out your algorithm in words – no pseudocode.
And make sure to state (and briefly
explain) the running time of your algorithm.
Computopia [DPV] Problem 3
The directed graph
is constructed by having a vertex for each intersection
and a directed edge for each one-way street.
We run the SCC algorithm on
. We then check if the graph is strongly connected by checking
if there is exactly 1 SCC. If
is strongly connected then it is possible to drive from any intersection
to any other intersection. If there are multiple SCCs then it is not possible to do so.
The SCC algorithm takes
time so the total run time of our algorithm is also
We need to check if the town-hall is in a sink SCC. We do this by checking that the
vertices in the SCC containing the town-hall do not have any edges out of this SCC. (OK to just
say check that the town-hall’s SCC is a sink SCC.) If the town-hall is in a sink SCC then no matter
where you can reach starting from the town-hall then you can get back to town-hall. If it is not in
a sink SCC then you cannot always get back to the town-hall.
The running time of this part is also
due to the SCC algorithm taking this time.