Module logicng

Class 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:

    This representation can then be written in different output formats. LogicNG currently supports two formats:
    Since:
    2.4.0
    Version:
    2.4.0
    • 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 undirected
        background - 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 undirected
        background - the background color (only possible in DOT output)
        nodes - the nodes of the graph
        edges - 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 name
        writer - 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 file
        writer - 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:
        true if all terminal nodes should be aligned on the same level (only possible in DOT output), otherwise false
      • isDirected

        public boolean isDirected()
        Returns whether the graph of the representation is directed or undirected.
        Returns:
        true if the graph of the representation is directed, otherwise false
      • 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