Class DiGraphVisitClient

java.lang.Object
it.unimi.di.prog2.h24.DiGraphVisitClient

public class DiGraphVisitClient extends Object
Tests directed graph package with visits.
  • Constructor Details

    • DiGraphVisitClient

      private DiGraphVisitClient()
      .
  • Method Details

    • copyAs

      private static <T> DiGraph<T> copyAs(String className, DiGraph<T> graph) throws IllegalArgumentException
      Returns a copy of the given DiGraph using the specified implementation.
      Type Parameters:
      T - the type of the nodes of the graph.
      Parameters:
      className - the name of the DiGraph implementation class (e.g. AdjacencyMatrixDiGraph).
      graph - the graph to be copied.
      Returns:
      a copy of graph, as an instance of a class of the given className.
      Throws:
      IllegalArgumentException - if the class or constructor cannot be found.
    • main

      public static void main(String[] args)
      Reads a graph from the standard input and performs a visit.

      More precisely:

      • builds a graph by reading a sequence of lines, each containing two strings separated by a space corresponding to the source and destination of an arc; the first source will be the starting node of the visit;
      • then it creates a copy of the above graph using the first command line argument as the name of the class of the implementation of the graph (e.g., AdjacencyMatrixDiGraph);
      • then it performs a visit using a Queue supplier that is either a Queues.FIFOSupplier() or a Queues.LIFOSupplier()) according to the first letter of the second command line argument.
      Parameters:
      args - see the above description.