Package dsa
Class DFSOrders
java.lang.Object
dsa.DFSOrders
An immutable data type to determine depth-first orders (pre, post, and reverse post) for a digraph.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Unit tests the data type.post()
Returns the vertices in post-order.int
post
(int v) Returns the post-order number of vertex v.pre()
Returns the vertices in pre-order.int
pre
(int v) Returns the pre-order number of vertex v.Returns the vertices in reverse post-order.
-
Constructor Details
-
DFSOrders
Determines depth-first orders (pre, post, and reverse post) for the digraph G.- Parameters:
G
- the digraph.
-
-
Method Details
-
pre
public int pre(int v) Returns the pre-order number of vertex v.- Parameters:
v
- the vertex.- Returns:
- the pre-order number of vertex v.
-
post
public int post(int v) Returns the post-order number of vertex v.- Parameters:
v
- the vertex.- Returns:
- the post-order number of vertex v.
-
pre
Returns the vertices in pre-order.- Returns:
- the vertices in pre-order.
-
post
Returns the vertices in post-order.- Returns:
- the vertices in post-order.
-
reversePost
Returns the vertices in reverse post-order.- Returns:
- the vertices in reverse post-order.
-
main
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-