This module provides a class to model a graph in Java.
This section allows you to access the Java source file of the module.
Here are listed the classes provided by the module. To use one of them, you have to specify the namespace of the module.
Represents a graph.
public JavaGraph()
Builds a new graph.
public Collection arcs()
Returns a collection of the arcs of the graph.
public Collection nodes()
Returns a collection of the nodes of the graph.
public Arc arc(long agKey)
Returns the arc associated with a given key.
public Node node(long agKey)
Returns the node associated with a given key.
public long getNewArcKey()
Gets randomly a new arc key that is not used yet.
public long getNewNodeKey()
Gets randomly a new node key that is not used yet.
public Arc addArc(long agKey,String agName,Node agSource,Node agTarget) throws Exception
Adds an arc between two nodes into the graph. Source and target nodes can be null
.
public Arc addArc(long agKey,Node agSource,Node agTarget) throws Exception
Adds an arc into the graph. Its name is an empty string.
public Arc addArc(String agName,Node agSource,Node agTarget) throws Exception
Adds an arc into the graph. Its key is randomly chosen.
public Arc addArc(Node agSource,Node agTarget) throws Exception
Adds an arc into the graph. Its name is an empty string and its key is randomly chosen.
public Node addNode(long agKey,String agName) throws Exception
Adds a node into the graph.
public Node addNode(long agKey) throws Exception
Adds a node into the graph. Its name is an empty string.
public Node addNode(String agName) throws Exception
Adds a node into the graph. Its key is randomly chosen.
public Node addNode() throws Exception
Adds a node into the graph. Its name is an empty string and its key is randomly chosen.
public void removeArc(long agKey) throws Exception
Removes the arc associated with a given key from the graph.
public void removeArc(Arc agArc) throws Exception
Removes a given arc from the graph.
public void removeNode(long agKey) throws Exception
Removes the node associated with a given key from the graph.
public void removeNode(Node agNode) throws Exception
Removes a given node from the graph.
public void removeArcs()
Removes all the arcs from the graph.
public void removeNodes()
Removes all the nodes from the graph.
public void clear()
Removes all the nodes and arcs from the graph.
public JavaGraph duplicate()
Duplicates the whole graph.
public Node mergeNodes(Node agNode1,Node agNode2)
Merges two nodes. The resulting node is returned.
public String toString()
Returns a string that fully describes the state of the graph.
public void fromString(String agString) throws Exception
Changes the state of the graph according to the description provided by a given string.
public PropertyMap attachArcProperty(String agName,Property agProperty)
Attaches a property to all the arcs of the graph. A property map that allows to access this property for any arc is returned.
public PropertyMap attachNodeProperty(String agName,Property agProperty)
Attaches a property to all the nodes of the graph. A property map that allows to access this property for any node is returned.
public void detachArcProperty(PropertyMap agPropertyMap)
Detaches a property from all the arcs of the graph.
public void detachNodeProperty(PropertyMap agPropertyMap)
Detaches a property from all the nodes of the graph.
public PropertyMap arcPropertyMap(String agName)
Finds the property map for the arcs of the graph that is associated with a given name.
public PropertyMap nodePropertyMap(String agName)
Finds the property map for the nodes of the graph that is associated with a given name.
public Collection arcPropertyMaps()
Returns a collection of all the property maps for the arcs of the graph.
public Collection nodePropertyMaps()
Returns a collection of all the property maps for the nodes of the graph.
Represents an arc of a graph. Inner class of JavaGraph
.
Represents a node of a graph. Inner class of JavaGraph
.