Constructor and Description |
---|
Permutation(Graph graph)
Creates a new permutation of the nodes of the graph
graph . |
Modifier and Type | Method and Description |
---|---|
void |
addNode(Node node)
Adds a node at the end of this permutation.
|
boolean |
contains(Node node)
Returns
true if and only if the node node is contained in this permutation. |
Graph |
getGraph()
Returns the graph of this permutation.
|
Node |
getNode(int index)
Returns the
index -th node of this permutation |
int |
getSize()
Returns the size of the permutation, i.e. the number of nodes of this permutation.
|
int |
indexOf(Node node)
Returns the index of the node
node or -1 if the node is not contained
in this permutation. |
boolean |
isEmpty()
Returns
true if and only if the permutation is empty. |
Iterator<Node> |
iterator() |
String |
toString() |
public Permutation(Graph graph)
graph
.graph
- the graph of the permutation.public Graph getGraph()
public void addNode(Node node)
node
- the node to be addedNullPointerException
- thrown if the node node
is null
IllegalArgumentException
- thrown if the node node
does not belong to the
graph of this permutationpublic boolean contains(Node node)
true
if and only if the node node
is contained in this permutation.node
- the node to be testedtrue
if the node is contained, false
otherwisepublic Node getNode(int index) throws IndexOutOfBoundsException
index
-th node of this permutationindex
- the index of the nodeindex
-th nodeIndexOutOfBoundsException
- thrown if the index is less than 0 or greater or
equal to the permutation's sizepublic int getSize()
public boolean isEmpty()
true
if and only if the permutation is empty.true
if the permutation is empty, false
otherwisepublic int indexOf(Node node)
node
or -1 if the node is not contained
in this permutation.node
- the node of which the index is returned