Algorithm DirectedDFSG v Label v as active Every vertex is i

Algorithm DirectedDFS(G, v): Label v as active Every vertex is initially unexplored for each outgoing edge, e, that is incident to v in G do if e is unexplored then Let w be the destination vertex for e if w is unexplored and not active then Label e as a discovery edge DirectedDFSCG, w) else if w is active then Label e as a back edge else Label e as a forward/cross edge Label v as explored

Solution

As we know forward edges are one where v is ancestor of w, and cross edges are one where no-one is ancestor of other.
We can modify DirectedDFS to keep array of edges with their position/level in grpah to tells us about the ancestor information.
If level of v is lesser than level of v then forward edge otherwise cross edge.

 Algorithm DirectedDFS(G, v): Label v as active Every vertex is initially unexplored for each outgoing edge, e, that is incident to v in G do if e is unexplored

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site