Package dsa

Class DFSOrders

java.lang.Object
dsa.DFSOrders

public class DFSOrders extends Object
An immutable data type to determine depth-first orders (pre, post, and reverse post) for a digraph.
  • Constructor Details

    • DFSOrders

      public DFSOrders(DiGraph G)
      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

      public Iterable<Integer> pre()
      Returns the vertices in pre-order.
      Returns:
      the vertices in pre-order.
    • post

      public Iterable<Integer> post()
      Returns the vertices in post-order.
      Returns:
      the vertices in post-order.
    • reversePost

      public Iterable<Integer> reversePost()
      Returns the vertices in reverse post-order.
      Returns:
      the vertices in reverse post-order.
    • main

      public static void main(String[] args)
      Unit tests the data type.
      Parameters:
      args - the command-line arguments.