Package net.ggtools.grand.graph
Class GraphImpl
- java.lang.Object
-
- net.ggtools.grand.graph.GraphImpl
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Link
createLink(String linkName, Node startNode, Node endNode)
Creates a new link between two nodes.Node
createNode(String nodeName)
Creates a new Node.Node
createNode(SubGraph subGraph, String nodeName)
Method createNode.SubGraph
createSubGraph(String subGraphName)
Method createSubGraph.protected GraphElementFactory
getFactory()
Returns the current element factory creating one if none exists yet.String
getName()
Returns the graph's name.Node
getNode(String nodeName)
Method getNode.Iterator<Node>
getNodes()
Method getNodes.Node
getStartNode()
Returns the start node of the graph.SubGraph
getSubGraph(String subGraphName)
Method getSubGraph.Iterator<SubGraph>
getSubgraphs()
Method getSubgraphs.boolean
hasNode(String nodeName)
Method hasNode.boolean
hasSubGraph(String subGraphName)
Method hasSubGraph.void
setStartNode(Node node)
Sets the graph starting node.protected void
unlinkNode(Node node)
Remove all links starting from or ending to the node.
-
-
-
Constructor Detail
-
GraphImpl
public GraphImpl(String graphName)
Creates a new named graph.- Parameters:
graphName
- name for the new graph.
-
-
Method Detail
-
createLink
public final Link createLink(String linkName, Node startNode, Node endNode)
Creates a new link between two nodes. UnlikecreateNode(String)
, this method do not require the link's name to be unique or not null. Both nodes should be not null.- Specified by:
createLink
in interfaceGraph
- Parameters:
linkName
- the new link name, can benull
startNode
- start nodeendNode
- end node- Returns:
- new link
- See Also:
Graph.createLink(String, Node, Node)
-
createNode
public final Node createNode(String nodeName) throws DuplicateElementException
Creates a new Node. The object's name must not benull
and must be unique within the graph.- Specified by:
createNode
in interfaceGraph
- Parameters:
nodeName
- new node's name- Returns:
- a new Node.
- Throws:
DuplicateElementException
- if there is already a node with the same name.- See Also:
Graph.createNode(String)
-
createNode
public final Node createNode(SubGraph subGraph, String nodeName) throws DuplicateElementException
Method createNode.- Specified by:
createNode
in interfaceGraph
- Parameters:
subGraph
- SubGraphnodeName
- String- Returns:
- Node
- Throws:
DuplicateElementException
- if there is already a node with the same name.- See Also:
Graph.createNode(net.ggtools.grand.graph.SubGraph, java.lang.String)
-
createSubGraph
public final SubGraph createSubGraph(String subGraphName) throws DuplicateElementException
Method createSubGraph.- Specified by:
createSubGraph
in interfaceGraph
- Parameters:
subGraphName
- String- Returns:
- SubGraph
- Throws:
DuplicateElementException
- if there is already a subgraph with the same name.- See Also:
Graph.createSubGraph(java.lang.String)
-
getName
public final String getName()
Returns the graph's name.- Specified by:
getName
in interfaceGraph
- Returns:
- graph's name.
- See Also:
Graph.getName()
-
getNode
public final Node getNode(String nodeName)
Method getNode.- Parameters:
nodeName
- String- Returns:
- Node
- See Also:
NodeContainer.getNode(java.lang.String)
-
getNodes
public final Iterator<Node> getNodes()
Method getNodes.- Returns:
- Iterator<Node>
- See Also:
NodeContainer.getNodes()
-
getStartNode
public final Node getStartNode()
Returns the start node of the graph. If no such node is defined,null
will be returned.- Specified by:
getStartNode
in interfaceGraph
- Returns:
- start node
- See Also:
Graph.getStartNode()
-
getSubGraph
public final SubGraph getSubGraph(String subGraphName)
Method getSubGraph.- Specified by:
getSubGraph
in interfaceGraph
- Parameters:
subGraphName
- String- Returns:
- SubGraph
- See Also:
Graph.getSubGraph(java.lang.String)
-
getSubgraphs
public final Iterator<SubGraph> getSubgraphs()
Method getSubgraphs.- Specified by:
getSubgraphs
in interfaceGraph
- Returns:
- Iterator<SubGraph>
- See Also:
Graph.getSubgraphs()
-
hasNode
public final boolean hasNode(String nodeName)
Method hasNode.- Parameters:
nodeName
- String- Returns:
- boolean
- See Also:
NodeContainer.hasNode(java.lang.String)
-
hasSubGraph
public final boolean hasSubGraph(String subGraphName)
Method hasSubGraph.- Specified by:
hasSubGraph
in interfaceGraph
- Parameters:
subGraphName
- String- Returns:
- boolean
- See Also:
Graph.hasSubGraph(java.lang.String)
-
setStartNode
public final void setStartNode(Node node)
Sets the graph starting node.- Specified by:
setStartNode
in interfaceGraph
- Parameters:
node
- to be marked as the starting node of the graph.- See Also:
Graph.setStartNode(Node)
-
getFactory
protected GraphElementFactory getFactory()
Returns the current element factory creating one if none exists yet. This method can be overridden to use a custom factory.- Returns:
- the element factory.
-
unlinkNode
protected final void unlinkNode(Node node)
Remove all links starting from or ending to the node. This method do not remove the node from nodeList.- Parameters:
node
- node to remove from the links.
-
-