Package it.unive.lisa.outputs
Class DotGraph<N extends Node<N,E,G>,E extends Edge<N,E,G>,G extends Graph<G,N,E>>
- java.lang.Object
-
- it.unive.lisa.outputs.DotGraph<N,E,G>
-
- Type Parameters:
N- the type of theNodes in the original graphE- the type of theEdges in the original graphG- the type of the originalGraphs
- 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.ObjectAn auxiliary graph built from aGraphthat can be dumped in dot format, together with a legend. Instances of this class can be read from a file throughreadDot(Reader).
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCOLORThe color attribute name.protected static java.lang.StringCOLOR_BLACKThe black color.protected static java.lang.StringCOLOR_BLUEThe blue color.protected static java.lang.StringCOLOR_GRAYThe gray color.protected static java.lang.StringCOLOR_REDThe red color.protected static java.lang.StringCONDITIONAL_EDGE_STYLEThe style of conditional edges.protected static java.lang.StringEXIT_NODE_EXTRA_ATTRThe name of the extra attribute identifying exit nodes.protected static java.lang.StringEXIT_NODE_EXTRA_VALUEThe value of the extra attribute identifying exit nodes.protected static java.lang.StringLABELThe label attribute name.protected static java.lang.StringNODE_SHAPEThe default shape of a node.protected static java.lang.StringNORMAL_NODE_COLORThe color of a normal node.protected static java.lang.StringSHAPEThe shape attribute name.protected static java.lang.StringSPECIAL_NODE_COLORThe color of a special node (entry or exit).protected static java.lang.StringSTYLEThe style attribute name.
-
Constructor Summary
Constructors Modifier Constructor Description protectedDotGraph(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 voidaddEdge(E edge, java.lang.String color, java.lang.String style)Adds an edge to the graph.protected voidaddNode(N node, boolean entry, boolean exit, java.util.function.Function<N,java.lang.String> labelGenerator)Adds a node to the graph.voiddumpDot(java.io.Writer writer)Dumps this graph through the givenWriter.booleanequals(java.lang.Object obj)inthashCode()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 givenReader.java.lang.StringtoString()
-
-
-
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
-
-
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 ofnodewill be composed by joiningnode.toString()(Object.toString()) withlabelGenerator.apply(node)(Function.apply(Object)) through a new line.- Parameters:
node- the source nodeentry- whether or not this edge is an entrypoint of the graphexit- whether or not this edge is an exitpoint of the graphlabelGenerator- 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 edgecolor- the color of the edge, ornullif nonestyle- the style of the edge, ornullif none
-
dumpDot
public void dumpDot(java.io.Writer writer) throws java.io.IOExceptionDumps this graph through the givenWriter. 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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-