Package org.jtool.graph
Class Graph<N extends GraphNode,E extends GraphEdge>
java.lang.Object
org.jtool.graph.Graph<N,E>
- Type Parameters:
N
- The type of nodes in this graphE
- The type of edges in this graph
A graph object having nodes and edges.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a given edge to this graph.void
Adds a given node to this graph.void
Sets edges of this graph.void
Adds nodes of this graph.void
clear()
Clears all nodes and all edges of this graph.boolean
Tests if this graph contains a given edge.boolean
Tests if this graph contains a given node.getEdges()
Returns all edges of this graph.getNodes()
Returns all nodes of this graph.void
Removes a given edge from this graph.void
Removes a given node from this graph.toString()
Obtains information on this graph.protected String
Obtains information on all edges enclosed in this graph.protected String
Obtains information on all nodes enclosed in this graph.
-
Field Details
-
nodes
Nodes of this graph. -
edges
Edges of this graph.
-
-
Constructor Details
-
Graph
public Graph()Creates a new, empty object for storing a graph information.
-
-
Method Details
-
clear
public void clear()Clears all nodes and all edges of this graph. -
getNodes
Returns all nodes of this graph.- Returns:
- the collection of the nodes
-
getEdges
Returns all edges of this graph.- Returns:
- the collection of the edges
-
addNodes
Adds nodes of this graph.- Parameters:
nodes
- a collection of nodes to be added
-
addEdges
Sets edges of this graph.- Parameters:
edges
- a collection of edges to be added
-
add
Adds a given node to this graph.- Parameters:
node
- the node to be added
-
add
Adds a given edge to this graph.- Parameters:
edge
- the edge to be added
-
remove
Removes a given node from this graph.- Parameters:
node
- the node to be removed
-
remove
Removes a given edge from this graph.- Parameters:
edge
- the edge to be removed
-
contains
Tests if this graph contains a given node.- Parameters:
node
- the node to be checked- Returns:
true
if this graph contains the node, otherwisefalse
-
contains
Tests if this graph contains a given edge.- Parameters:
edge
- the edge to be checked- Returns:
true
if this graph contains the edge, otherwisefalse
-
toString
Obtains information on this graph. -
toStringForNodes
Obtains information on all nodes enclosed in this graph.- Returns:
- the string representing the information
-
toStringForEdges
Obtains information on all edges enclosed in this graph.- Returns:
- the string representing the information
-