Interface IGraph<N>
-
- Type Parameters:
N- The type of node labels.
- All Known Subinterfaces:
ILabeledGraph<N,A>
public interface IGraph<N>A graph in which the nodes are labeled.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddEdge(N from, N to)Adds an edge between two nodes in the graph.voidaddNode(N node)Adds a new node to the graphbooleancontains(N node)java.util.Collection<N>getNodes()java.util.Collection<N>getPredecessors(N node)Gets all nodes from which a given node is reachable using one edge.java.util.Collection<N>getSuccessors(N node)Gets all nodes that are reachable over one edge from a given node.voidremoveEdge(N from, N to)Removes an existing edge from the graph.voidremoveNode(N node)Removes an existing node from the graph
-
-
-
Method Detail
-
getNodes
java.util.Collection<N> getNodes()
- Returns:
- The collection of node labels contained in the graph.
-
contains
boolean contains(N node)
- Parameters:
node-- Returns:
- true iff there is a node with the given label in the graph.
-
addNode
void addNode(N node)
Adds a new node to the graph- Parameters:
node- The label for the new node.
-
removeNode
void removeNode(N node)
Removes an existing node from the graph- Parameters:
node- Label of the node to be removed
-
addEdge
void addEdge(N from, N to)
Adds an edge between two nodes in the graph. It is not necessary that the nodes have been added before. If they have not been part of the graph, they are added automatically.- Parameters:
from- Node where the edge departsto- Node targeted by the edge
-
removeEdge
void removeEdge(N from, N to)
Removes an existing edge from the graph. Nodes without an edge are not removed from the graph.- Parameters:
from- Node where the edge departsto- Node targeted by the edge
-
getSuccessors
java.util.Collection<N> getSuccessors(N node)
Gets all nodes that are reachable over one edge from a given node.- Parameters:
node- The node from which to depart- Returns:
- Collection of nodes reachable in one step
-
-