Package com.alexmerz.graphviz.objects
Class Graph
java.lang.Object
com.alexmerz.graphviz.objects.Graph
This class represents a graph.
A Graph contains Nodes, Edges and Subgraphs
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant for an directed graphstatic final intConstant for an undirected graph -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(String key, String value) Adds a graph attribute.voidAdds an Edge object to the graphvoidaddGenericEdgeAttribute(String key, String value) Sets a generic attribute for all edges of this graph.voidaddGenericGraphAttribute(String key, String value) Sets a generic attribute for clusters of this graph.voidaddGenericNodeAttribute(String key, String value) Sets a generic attribute for all nodes of this graph This attributes are NOT additionally stored in the Node objects.voidAdds a Node object to the graphvoidaddSubgraph(Graph graph) Adds a sub graph to a graphTries to find a node of a Graph depending on the given Id object.getAttribute(String key) Returns an attribute of the Graph or null if not found.Returns all attributes of the graph.getEdges()Returns all edges of this graph.Returns a generic attribute of an edgeReturns a generic attribute of the clusters in the graphReturns a generic attribute of a nodegetId()Returns the Id object to the GraphgetNodes(boolean thisOnly) Returns all Nodes of the graph.Returns a list of all sub graphs.intgetType()Returns the type of the graphbooleanisStrict()Returns wether the graph is strict or notvoidSets the Id object for this graphvoidsetStrict(boolean isStrict) Sets if the graph is strict or not.voidsetType(int type) Sets the type of the graphtoString()Returns a String representation of the graph
-
Field Details
-
UNDIRECTED
public static final int UNDIRECTEDConstant for an undirected graph- See Also:
-
DIRECTED
public static final int DIRECTEDConstant for an directed graph- See Also:
-
-
Constructor Details
-
Graph
public Graph()
-
-
Method Details
-
addGenericEdgeAttribute
Sets a generic attribute for all edges of this graph. This attributes are NOT additionally stored in the Edge objects.- Parameters:
key- the attribute namevalue- the attribute value
-
getGenericEdgeAttribute
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
Sets a generic attribute for clusters of this graph. This attributes are NOT additionally stored in the Edge objects.- Parameters:
key- the attribute namevalue- the attribute value
-
getGenericGraphAttribute
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
Sets a generic attribute for all nodes of this graph This attributes are NOT additionally stored in the Node objects.- Parameters:
key- the attribute namevalue- the attribute value
-
getGenericNodeAttribute
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
Adds a graph attribute. This attributes are NOT inherited to the attributes of sub graphs.- Parameters:
key- the name of the attributevalue- the value of the attribute
-
getAttribute
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
Adds a Node object to the graph- Parameters:
n- the Node Object to add
-
addEdge
Adds an Edge object to the graph- Parameters:
e- the Edge object to add
-
getId
Returns the Id object to the Graph- Returns:
- the Id object
-
setId
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
Returns a String representation of the graph -
getSubgraphs
Returns a list of all sub graphs.- Returns:
- the subgraphs
-
addSubgraph
Adds a sub graph to a graph- Parameters:
graph-
-
findNode
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
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
Returns all attributes of the graph.- Returns:
- the attributes
-
getEdges
Returns all edges of this graph.- Returns:
- a list of Edge objects
-