Class Graph

java.lang.Object
com.alexmerz.graphviz.objects.Graph

public class Graph extends Object
This class represents a graph. A Graph contains Nodes, Edges and Subgraphs
  • Field Details

    • UNDIRECTED

      public static final int UNDIRECTED
      Constant for an undirected graph
      See Also:
    • DIRECTED

      public static final int DIRECTED
      Constant for an directed graph
      See Also:
  • Constructor Details

    • Graph

      public Graph()
  • Method Details

    • addGenericEdgeAttribute

      public void addGenericEdgeAttribute(String key, String value)
      Sets a generic attribute for all edges of this graph. This attributes are NOT additionally stored in the Edge objects.
      Parameters:
      key - the attribute name
      value - the attribute value
    • getGenericEdgeAttribute

      public String getGenericEdgeAttribute(String key)
      Returns a generic attribute of an edge
      Parameters:
      key - the attribute name
      Returns:
      the value of the attribute or null, if the attribute does not exist.
    • addGenericGraphAttribute

      public void addGenericGraphAttribute(String key, String value)
      Sets a generic attribute for clusters of this graph. This attributes are NOT additionally stored in the Edge objects.
      Parameters:
      key - the attribute name
      value - the attribute value
    • getGenericGraphAttribute

      public String getGenericGraphAttribute(String key)
      Returns a generic attribute of the clusters in the graph
      Parameters:
      key - the attribute name
      Returns:
      the value of the attribute or null, if the attribute does not exist.
    • addGenericNodeAttribute

      public void addGenericNodeAttribute(String key, String value)
      Sets a generic attribute for all nodes of this graph This attributes are NOT additionally stored in the Node objects.
      Parameters:
      key - the attribute name
      value - the attribute value
    • getGenericNodeAttribute

      public String getGenericNodeAttribute(String key)
      Returns a generic attribute of a node
      Parameters:
      key - the attribute name
      Returns:
      the value of the attribute or null, if the attribute does not exist.
    • addAttribute

      public void addAttribute(String key, String value)
      Adds a graph attribute. This attributes are NOT inherited to the attributes of sub graphs.
      Parameters:
      key - the name of the attribute
      value - the value of the attribute
    • getAttribute

      public String getAttribute(String key)
      Returns an attribute of the Graph or null if not found.
      Parameters:
      key - the name of the attribute
      Returns:
      the value of the attribute
    • addNode

      public void addNode(Node n)
      Adds a Node object to the graph
      Parameters:
      n - the Node Object to add
    • addEdge

      public void addEdge(Edge e)
      Adds an Edge object to the graph
      Parameters:
      e - the Edge object to add
    • getId

      public Id getId()
      Returns the Id object to the Graph
      Returns:
      the Id object
    • setId

      public void setId(Id id)
      Sets the Id object for this graph
      Parameters:
      id -
    • getType

      public int getType()
      Returns the type of the graph
      Returns:
      the type of the graph
      See Also:
    • setType

      public void setType(int type)
      Sets the type of the graph
      Parameters:
      type - the type of the graph
      See Also:
    • isStrict

      public boolean isStrict()
      Returns wether the graph is strict or not
      Returns:
      the static state
    • setStrict

      public void setStrict(boolean isStrict)
      Sets if the graph is strict or not.
      Parameters:
      isStrict -
    • toString

      public String toString()
      Returns a String representation of the graph
      Overrides:
      toString in class Object
      Returns:
      the string representation
    • getSubgraphs

      public ArrayList<Graph> getSubgraphs()
      Returns a list of all sub graphs.
      Returns:
      the subgraphs
    • addSubgraph

      public void addSubgraph(Graph graph)
      Adds a sub graph to a graph
      Parameters:
      graph -
    • findNode

      public Node findNode(Id id)
      Tries to find a node of a Graph depending on the given Id object.
      Parameters:
      id - the id object to identify the node
      Returns:
      the node or nulll if not found
    • getNodes

      public ArrayList<Node> getNodes(boolean thisOnly)
      Returns all Nodes of the graph. If the graph contains subgraphs, you can use the thisOnly parameter to decide if nodes defined in subgraphs should be added to the list also.
      Parameters:
      thisOnly - if true, also include nodes in subgraphs also, else exclude them
      Returns:
      the nodes of the graph
    • getAttributes

      public Hashtable<String,String> getAttributes()
      Returns all attributes of the graph.
      Returns:
      the attributes
    • getEdges

      public ArrayList<Edge> getEdges()
      Returns all edges of this graph.
      Returns:
      a list of Edge objects