Package dsa

Class Topological

java.lang.Object
dsa.Topological

public class Topological extends Object
An immutable data type to determine whether a digraph has a topological order and, if so, find such an order.
  • Constructor Details

    • Topological

      public Topological(DiGraph G)
      Determines whether the digraph G has a topological order and, if so, finds such an order.
      Parameters:
      G - the digraph.
  • Method Details

    • hasOrder

      public boolean hasOrder()
      Returns true if there exists a topological order, and false otherwise.
      Returns:
      true if there exists a topological order, and false otherwise.
    • order

      public Iterable<Integer> order()
      Returns a topological order, or null.
      Returns:
      a topological order, or null.
    • main

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