Class DotGenerator


  • public class DotGenerator
    extends java.lang.Object
    This class contains utility methods to generate dot representations for Graph instances.
    Since:
    2.3
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <V> java.lang.String generateDot​(Graph<V> graph)
      Generates the dot representation for the given graph.
      static <V> java.lang.String generateDot​(Graph<V> graph, boolean colorSCCs, java.util.function.Function<V,​java.lang.String> nameFunction, java.util.function.Function<V,​java.lang.String> colorFunction, java.util.function.Function<V,​java.util.function.Function<V,​java.lang.String>> edgeFunction)
      Generates the dot representation for the given graph.
      static <V> java.util.function.Function<V,​java.lang.String> getNameShortener​(int maxLength)
      Returns a simple name shortener function that can be used in the graphviz visualization to help with readability.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • generateDot

        public static <V> java.lang.String generateDot​(Graph<V> graph,
                                                       boolean colorSCCs,
                                                       java.util.function.Function<V,​java.lang.String> nameFunction,
                                                       java.util.function.Function<V,​java.lang.String> colorFunction,
                                                       java.util.function.Function<V,​java.util.function.Function<V,​java.lang.String>> edgeFunction)
        Generates the dot representation for the given graph.
        Parameters:
        graph - the graph
        colorSCCs - specifies if the strongly connected components with size greater than shall be colored
        nameFunction - use this function to provide custom names to nodes, null if the default toString shall be used
        colorFunction - use this function to provide custom color to nodes, null if the default white color shall be used
        edgeFunction - use this function to provide custom edge labels, null if no edge label shall be printed
        Returns:
        the dot representation as a string
      • generateDot

        public static <V> java.lang.String generateDot​(Graph<V> graph)
        Generates the dot representation for the given graph. No special pretty printing customization will be applied.
        Parameters:
        graph - the graph
        Returns:
        the dot representation as a string
      • getNameShortener

        public static <V> java.util.function.Function<V,​java.lang.String> getNameShortener​(int maxLength)
        Returns a simple name shortener function that can be used in the graphviz visualization to help with readability. WARNING: if you shorten the name of the Nodes too much, the visualization may become incorrect because grahpviz will treat different nodes as the same if their shortened names are the same.
        Parameters:
        maxLength - the maximum length of the text that is kept from the toString of the objects in the graph
        Returns:
        the shrunk toString value