Class DotGraph<N extends Node<N,​E,​G>,​E extends Edge<N,​E,​G>,​G extends Graph<G,​N,​E>>

  • Type Parameters:
    N - the type of the Nodes in the original graph
    E - the type of the Edges in the original graph
    G - the type of the original Graphs
    Direct Known Subclasses:
    DotCFG

    public abstract class DotGraph<N extends Node<N,​E,​G>,​E extends Edge<N,​E,​G>,​G extends Graph<G,​N,​E>>
    extends java.lang.Object
    An auxiliary graph built from a Graph that can be dumped in dot format, together with a legend. Instances of this class can be read from a file through readDot(Reader).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String COLOR
      The color attribute name.
      protected static java.lang.String COLOR_BLACK
      The black color.
      protected static java.lang.String COLOR_BLUE
      The blue color.
      protected static java.lang.String COLOR_GRAY
      The gray color.
      protected static java.lang.String COLOR_RED
      The red color.
      protected static java.lang.String CONDITIONAL_EDGE_STYLE
      The style of conditional edges.
      protected static java.lang.String EXIT_NODE_EXTRA_ATTR
      The name of the extra attribute identifying exit nodes.
      protected static java.lang.String EXIT_NODE_EXTRA_VALUE
      The value of the extra attribute identifying exit nodes.
      protected static java.lang.String LABEL
      The label attribute name.
      protected static java.lang.String NODE_SHAPE
      The default shape of a node.
      protected static java.lang.String NORMAL_NODE_COLOR
      The color of a normal node.
      protected static java.lang.String SHAPE
      The shape attribute name.
      protected static java.lang.String SPECIAL_NODE_COLOR
      The color of a special node (entry or exit).
      protected static java.lang.String STYLE
      The style attribute name.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected DotGraph​(java.lang.String title, org.graphstream.graph.Graph legend)
      Builds a graph.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addEdge​(E edge, java.lang.String color, java.lang.String style)
      Adds an edge to the graph.
      protected void addNode​(N node, boolean entry, boolean exit, java.util.function.Function<N,​java.lang.String> labelGenerator)
      Adds a node to the graph.
      void dumpDot​(java.io.Writer writer)
      Dumps this graph through the given Writer.
      boolean equals​(java.lang.Object obj)  
      int hashCode()  
      static <N extends Node<N,​E,​G>,​E extends Edge<N,​E,​G>,​G extends Graph<G,​N,​E>>
      DotGraph<N,​E,​G>
      readDot​(java.io.Reader reader)
      Reads a graph through the given Reader.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • COLOR_BLACK

        protected static final java.lang.String COLOR_BLACK
        The black color.
        See Also:
        Constant Field Values
      • COLOR_GRAY

        protected static final java.lang.String COLOR_GRAY
        The gray color.
        See Also:
        Constant Field Values
      • COLOR_RED

        protected static final java.lang.String COLOR_RED
        The red color.
        See Also:
        Constant Field Values
      • COLOR_BLUE

        protected static final java.lang.String COLOR_BLUE
        The blue color.
        See Also:
        Constant Field Values
      • STYLE

        protected static final java.lang.String STYLE
        The style attribute name.
        See Also:
        Constant Field Values
      • COLOR

        protected static final java.lang.String COLOR
        The color attribute name.
        See Also:
        Constant Field Values
      • SHAPE

        protected static final java.lang.String SHAPE
        The shape attribute name.
        See Also:
        Constant Field Values
      • LABEL

        protected static final java.lang.String LABEL
        The label attribute name.
        See Also:
        Constant Field Values
      • EXIT_NODE_EXTRA_ATTR

        protected static final java.lang.String EXIT_NODE_EXTRA_ATTR
        The name of the extra attribute identifying exit nodes.
        See Also:
        Constant Field Values
      • NODE_SHAPE

        protected static final java.lang.String NODE_SHAPE
        The default shape of a node.
        See Also:
        Constant Field Values
      • EXIT_NODE_EXTRA_VALUE

        protected static final java.lang.String EXIT_NODE_EXTRA_VALUE
        The value of the extra attribute identifying exit nodes.
        See Also:
        Constant Field Values
      • SPECIAL_NODE_COLOR

        protected static final java.lang.String SPECIAL_NODE_COLOR
        The color of a special node (entry or exit).
        See Also:
        Constant Field Values
      • NORMAL_NODE_COLOR

        protected static final java.lang.String NORMAL_NODE_COLOR
        The color of a normal node.
        See Also:
        Constant Field Values
      • CONDITIONAL_EDGE_STYLE

        protected static final java.lang.String CONDITIONAL_EDGE_STYLE
        The style of conditional edges.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DotGraph

        protected DotGraph​(java.lang.String title,
                           org.graphstream.graph.Graph legend)
        Builds a graph.
        Parameters:
        title - the title of the graph, if any
        legend - the legend to append to the graph, if any
    • Method Detail

      • addNode

        protected void addNode​(N node,
                               boolean entry,
                               boolean exit,
                               java.util.function.Function<N,​java.lang.String> labelGenerator)
        Adds a node to the graph. The label of node will be composed by joining node.toString() ( Object.toString()) with labelGenerator.apply(node) (Function.apply(Object)) through a new line.
        Parameters:
        node - the source node
        entry - whether or not this edge is an entrypoint of the graph
        exit - whether or not this edge is an exitpoint of the graph
        labelGenerator - the function that is used to enrich nodes labels
      • addEdge

        protected void addEdge​(E edge,
                               java.lang.String color,
                               java.lang.String style)
        Adds an edge to the graph.
        Parameters:
        edge - the source edge
        color - the color of the edge, or null if none
        style - the style of the edge, or null if none
      • dumpDot

        public void dumpDot​(java.io.Writer writer)
                     throws java.io.IOException
        Dumps this graph through the given Writer. A legend will also be added to the output, to improve its readability.
        Parameters:
        writer - the writer to use for dumping the graph
        Throws:
        java.io.IOException - if an I/O error occurs while writing
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • readDot

        public static <N extends Node<N,​E,​G>,​E extends Edge<N,​E,​G>,​G extends Graph<G,​N,​E>> DotGraph<N,​E,​G> readDot​(java.io.Reader reader)
                                                                                                                                                                        throws java.io.IOException
        Reads a graph through the given Reader. Any legend (i.e., subgraph) will be stripped from the input.
        Type Parameters:
        N - the type of Nodes in the graph
        E - the type of Edges in the graph
        G - the type of the Graph
        Parameters:
        reader - the reader to use for reading the graph
        Returns:
        the DotGraph that has been read
        Throws:
        java.io.IOException - if an I/O error occurs while reading