Class DiGraphs

java.lang.Object
it.unimi.di.prog2.h24.digraph.DiGraphs

public class DiGraphs extends Object
A collection of utilities related to DiGraphs.

This class provides a few utility methods, mainly related to Graphviz.

  • Constructor Details

    • DiGraphs

      private DiGraphs()
      .
  • Method Details

    • fromAdjacencyMap

      public static <T> void fromAdjacencyMap(Map<T,Collection<T>> adjacency, DiGraph<T> graph)
      Fills the given graph with the arcs described by the given adjacency map.
      Type Parameters:
      T - the type of the graph nodes.
      Parameters:
      adjacency - the adjacency map.
      graph - the mutable graph to fill.
      Throws:
      NullPointerException - if adjacency is or contains null or graph is null.
      UnsupportedOperationException - if graph is immutable.
    • toDot

      public static <T> String toDot(DiGraph<T> graph)
      Returns the dot representation of the given graph.
      Type Parameters:
      T - the type of the graph nodes.
      Parameters:
      graph - the graph.
      Returns:
      the dot representation of the given graph.
      Throws:
      NullPointerException - if graph is null.
    • toDot

      public static <T> String toDot(DiGraph<T> graph, String extra)
      Returns the dot representation of the given graph.
      Type Parameters:
      T - the type of the graph nodes.
      Parameters:
      graph - the graph.
      extra - extra configuration to be added to the dot source, may be null.
      Returns:
      the dot representation of the given graph.
      Throws:
      NullPointerException - if graph is null.
    • dotToPdf

      public static void dotToPdf(String dot, String path)
      Renders a dot source to a PDF file (invoking an external command).
      Parameters:
      dot - the dot source
      path - path of the PDF to create.
      Throws:
      NullPointerException - if dot or path is null.