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 LinkcreateLink(String linkName, Node startNode, Node endNode)Creates a new link between two nodes.NodecreateNode(String nodeName)Creates a new Node.NodecreateNode(SubGraph subGraph, String nodeName)Method createNode.SubGraphcreateSubGraph(String subGraphName)Method createSubGraph.protected GraphElementFactorygetFactory()Returns the current element factory creating one if none exists yet.StringgetName()Returns the graph's name.NodegetNode(String nodeName)Method getNode.Iterator<Node>getNodes()Method getNodes.NodegetStartNode()Returns the start node of the graph.SubGraphgetSubGraph(String subGraphName)Method getSubGraph.Iterator<SubGraph>getSubgraphs()Method getSubgraphs.booleanhasNode(String nodeName)Method hasNode.booleanhasSubGraph(String subGraphName)Method hasSubGraph.voidsetStartNode(Node node)Sets the graph starting node.protected voidunlinkNode(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:
createLinkin interfaceGraph- Parameters:
linkName- the new link name, can benullstartNode- 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 benulland must be unique within the graph.- Specified by:
createNodein 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:
createNodein 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:
createSubGraphin 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:
getNamein 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,nullwill be returned.- Specified by:
getStartNodein interfaceGraph- Returns:
- start node
- See Also:
Graph.getStartNode()
-
getSubGraph
public final SubGraph getSubGraph(String subGraphName)
Method getSubGraph.- Specified by:
getSubGraphin interfaceGraph- Parameters:
subGraphName- String- Returns:
- SubGraph
- See Also:
Graph.getSubGraph(java.lang.String)
-
getSubgraphs
public final Iterator<SubGraph> getSubgraphs()
Method getSubgraphs.- Specified by:
getSubgraphsin 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:
hasSubGraphin 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:
setStartNodein 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.
-
-