I’ve been assigned the following problem, but am having issues figuring it out. I know what I’d like to accomplish, but given the skeleton code he’s outlined for us, I’m not sure where to start…I drew a pic to illustrate what I’d like to accomplish (I think…)
http://i802.photobucket.com/albums/yy304/Growler2009/Transposing-1.jpg
This is what I need to do:
Consider a directed graph G(V;A). The transpose of G written GT (V;AT ) is nothing more than
G where all the arcs have been transposed, i.e., the origin of the arc becomes the end and the end
becomes the origin. In a sense, GT is the \backward” version of G. For this question you must
implement an algorithm which, given a directed graph, produces its transpose. The API of the
algorithm is given by the following interface:
public interface Transpose<VT,AT> {
public DIGraph<VT,AT> doIt(DIGraph<VT,AT> src);
}
Implement the transpose algorithm given above. You have no restrictions on how to do this (except
that it must operate on a graph represented as an adjacency list and it cannot modify the original
graph. Report (in the comments) the space and time complexities in big O notation and brie
y
justify. (i.e., how long does it take and how much space does it uses to transpose a graph with n
vertices and m arcs).
Any help you can offer to get me started would be great.
Thanks!
in pseudolanguagecode:
Space complexity: no requirements
Time complexity: O(num. of edges)