- java.lang.Object
-
- org.logicng.io.graphical.GraphicalRepresentation
-
public class GraphicalRepresentation extends Object
A graphical representation of a formula, BDD, or graph. The representation is a graph and holds the nodes and edges for the graph, a background color (only used for DOT output), a flag whether all terminal nodes should be on the same level (only used for DOT output) and a flag whether the graph is directed or undirected.This is a generic representation which can be generated by one of the following generators:
- Formula AST:
FormulaAstGraphicalGenerator - Formula DAG:
FormulaDagGraphicalGenerator - BDD:
BddGraphicalGenerator - Graph:
GraphGraphicalGenerator
- DOT format:
GraphicalDotWriter - Mermaid.js format:
GraphicalMermaidWriter
- Since:
- 2.4.0
- Version:
- 2.4.0
- Formula AST:
-
-
Constructor Summary
Constructors Constructor Description GraphicalRepresentation(boolean alignTerminals, boolean directed)Generates a new graphical representation with the given values and no background.GraphicalRepresentation(boolean alignTerminals, boolean directed, GraphicalColor background)Generates a new graphical representation with the given values.GraphicalRepresentation(boolean alignTerminals, boolean directed, GraphicalColor background, List<GraphicalNode> nodes, List<GraphicalEdge> edges)Generates a new graphical representation with the given values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEdge(GraphicalEdge edge)Adds an edge to this graph.voidaddNode(GraphicalNode node)Adds a node to this graph.GraphicalColorgetBackground()Returns the background color (only possible in DOT output).List<GraphicalEdge>getEdges()Returns the edges of this graph.List<GraphicalNode>getNodes()Returns the nodes of this graph.List<GraphicalNode>getNonTerminalNodes()Returns the non-terminal nodes of this graph.List<GraphicalNode>getTerminalNodes()Returns the terminal nodes of this graph.booleanisAlignTerminals()Returns whether all terminal nodes should be aligned on the same level (only possible in DOT output).booleanisDirected()Returns whether the graph of the representation is directed or undirected.StringtoString()voidwrite(File file, GraphicalRepresentationWriter writer)Writes this representation to the given file using the given writer.voidwrite(String fileName, GraphicalRepresentationWriter writer)Writes this representation to a file with the given file name using the given writer.StringwriteString(GraphicalRepresentationWriter writer)Returns this representation as a string using the given writer.
-
-
-
Constructor Detail
-
GraphicalRepresentation
public GraphicalRepresentation(boolean alignTerminals, boolean directed)Generates a new graphical representation with the given values and no background.- Parameters:
alignTerminals- a flag whether all terminal nodes should be aligned on the same level (only possible in DOT output)directed- a flag whether the graph of the representation is directed or undirected
-
GraphicalRepresentation
public GraphicalRepresentation(boolean alignTerminals, boolean directed, GraphicalColor background)Generates a new graphical representation with the given values.- Parameters:
alignTerminals- a flag whether all terminal nodes should be aligned on the same level (only possible in DOT output)directed- a flag whether the graph of the representation is directed or undirectedbackground- the background color (only possible in DOT output)
-
GraphicalRepresentation
public GraphicalRepresentation(boolean alignTerminals, boolean directed, GraphicalColor background, List<GraphicalNode> nodes, List<GraphicalEdge> edges)Generates a new graphical representation with the given values.- Parameters:
alignTerminals- a flag whether all terminal nodes should be aligned on the same level (only possible in DOT output)directed- a flag whether the graph of the representation is directed or undirectedbackground- the background color (only possible in DOT output)nodes- the nodes of the graphedges- the edges of the graph
-
-
Method Detail
-
addNode
public void addNode(GraphicalNode node)
Adds a node to this graph.- Parameters:
node- the new node
-
addEdge
public void addEdge(GraphicalEdge edge)
Adds an edge to this graph.- Parameters:
edge- the new edge
-
write
public void write(String fileName, GraphicalRepresentationWriter writer) throws IOException
Writes this representation to a file with the given file name using the given writer.- Parameters:
fileName- the file namewriter- the writer- Throws:
IOException- if there is a problem writing the file
-
write
public void write(File file, GraphicalRepresentationWriter writer) throws IOException
Writes this representation to the given file using the given writer.- Parameters:
file- the filewriter- the writer- Throws:
IOException- if there is a problem writing the file
-
writeString
public String writeString(GraphicalRepresentationWriter writer)
Returns this representation as a string using the given writer.- Parameters:
writer- the writer- Returns:
- this representation as a string
-
isAlignTerminals
public boolean isAlignTerminals()
Returns whether all terminal nodes should be aligned on the same level (only possible in DOT output).- Returns:
trueif all terminal nodes should be aligned on the same level (only possible in DOT output), otherwisefalse
-
isDirected
public boolean isDirected()
Returns whether the graph of the representation is directed or undirected.- Returns:
trueif the graph of the representation is directed, otherwisefalse
-
getBackground
public GraphicalColor getBackground()
Returns the background color (only possible in DOT output).- Returns:
- the background color (only possible in DOT output)
-
getNodes
public List<GraphicalNode> getNodes()
Returns the nodes of this graph.- Returns:
- the nodes of this graph
-
getTerminalNodes
public List<GraphicalNode> getTerminalNodes()
Returns the terminal nodes of this graph.- Returns:
- the terminal nodes of this graph
-
getNonTerminalNodes
public List<GraphicalNode> getNonTerminalNodes()
Returns the non-terminal nodes of this graph.- Returns:
- the non-terminal nodes of this graph
-
getEdges
public List<GraphicalEdge> getEdges()
Returns the edges of this graph.- Returns:
- the edges of this graph
-
-