Modify your Digraph class from the previous exercise to make a MultiDigraph class that allows parallel edges.

Question:

Modify your Digraph class from the previous exercise to make a MultiDigraph class that allows parallel edges. For a test client, run a random- surfer simulation that matches RandomSurfer (Program 1.6.2).

Data from in previous exercise

Implement a Digraph data type that represents directed graphs, where the direction of edges is significant: \(\operatorname{addEdge}(v, w)\) means to add an edge from \(v\) to \(w\) but not from \(w\) to \(v\). Replace adjacentTo () with two methods: one to give the set of vertices having edges directed to them from the argument vertex, and the other to give the set of vertices having edges directed from them to the argument vertex. Explain how PathFinder would need to be modified to find shortest paths in directed graphs.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: