- java.lang.Object
-
- org.chocosolver.util.objects.graphs.DirectedGraph
-
-
Constructor Summary
Constructors Constructor Description DirectedGraph(int n, SetType type, boolean allNodes)
Creates an empty graph.DirectedGraph(Model model, int n, SetType type, boolean allNodes)
Creates an empty backtrable graph of n nodes Allocates memory for n nodes (but they should then be added explicitly, unless allNodes is true).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addArc(int from, int to)
add arc (from,to) to the graphboolean
addNode(int x)
Adds node x to the node set of the graphboolean
arcExists(int from, int to)
Test whether arc (from,to) exists or not in the graphint
getNbMaxNodes()
The maximum number of nodes in the graph Vertices of the graph belong to [0,getNbMaxNodes()-1] This quantity is fixed at the creation of the graphISet
getNodes()
ISet
getPredOf(int x)
Get predecessors of node xISet
getPredOrNeighOf(int x)
Get either x's predecessors or neighbors.ISet
getSuccOf(int x)
Get successors of node xISet
getSuccOrNeighOf(int x)
Get either x's successors or neighbors.SetType
getType()
Get the type of data structures used in the graphboolean
isArcOrEdge(int from, int to)
Ifthis
is directed returns true if and only if arc (x,y) exists Else, ifthis
is undirected returns true if and only if edge (x,y) existsboolean
isDirected()
boolean
removeArc(int from, int to)
remove arc (from,to) from the graphboolean
removeNode(int x)
Remove node x from the graphString
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.chocosolver.util.objects.graphs.IGraph
graphVizExport
-
-
-
-
Constructor Detail
-
DirectedGraph
public DirectedGraph(int n, SetType type, boolean allNodes)
Creates an empty graph. Allocates memory for n nodes (but they should then be added explicitly, unless allNodes is true).- Parameters:
n
- maximum number of nodestype
- data structure to use for representing node successors and predecessorsallNodes
- true iff all nodes must always remain present in the graph. i.e. The node set is fixed to [0,n-1] and will never change
-
DirectedGraph
public DirectedGraph(Model model, int n, SetType type, boolean allNodes)
Creates an empty backtrable graph of n nodes Allocates memory for n nodes (but they should then be added explicitly, unless allNodes is true).- Parameters:
model
- model providing the backtracking environmentn
- maximum number of nodestype
- data structure to use for representing node successors and predecessorsallNodes
- true iff all nodes must always remain present in the graph
-
-
Method Detail
-
getNbMaxNodes
public int getNbMaxNodes()
Description copied from interface:IGraph
The maximum number of nodes in the graph Vertices of the graph belong to [0,getNbMaxNodes()-1] This quantity is fixed at the creation of the graph- Specified by:
getNbMaxNodes
in interfaceIGraph
- Returns:
- the maximum number of nodes of the graph
-
getNodes
public ISet getNodes()
-
getType
public SetType getType()
Description copied from interface:IGraph
Get the type of data structures used in the graph
-
addNode
public boolean addNode(int x)
Description copied from interface:IGraph
Adds node x to the node set of the graph
-
removeNode
public boolean removeNode(int x)
Description copied from interface:IGraph
Remove node x from the graph- Specified by:
removeNode
in interfaceIGraph
- Parameters:
x
- a node index- Returns:
- true iff x was present in the graph
-
removeArc
public boolean removeArc(int from, int to)
remove arc (from,to) from the graph- Parameters:
from
- a node indexto
- a node index- Returns:
- true iff arc (from,to) was in the graph
-
arcExists
public boolean arcExists(int from, int to)
Test whether arc (from,to) exists or not in the graph- Parameters:
from
- a node indexto
- a node index- Returns:
- true iff arc (from,to) exists in the graph
-
isArcOrEdge
public boolean isArcOrEdge(int from, int to)
Description copied from interface:IGraph
Ifthis
is directed returns true if and only if arc (x,y) exists Else, ifthis
is undirected returns true if and only if edge (x,y) exists This method enables to capitalize some code but should be called with care- Specified by:
isArcOrEdge
in interfaceIGraph
- Parameters:
from
- a node indexto
- a node index
-
isDirected
public boolean isDirected()
- Specified by:
isDirected
in interfaceIGraph
- Returns:
- true if and only if
this
is a directed graph
-
addArc
public boolean addArc(int from, int to)
add arc (from,to) to the graph- Parameters:
from
- a node indexto
- a node index- Returns:
- true iff arc (from,to) was not already in the graph
-
getSuccOf
public ISet getSuccOf(int x)
Get successors of node x- Parameters:
x
- node index- Returns:
- successors of x
-
getSuccOrNeighOf
public ISet getSuccOrNeighOf(int x)
Description copied from interface:IGraph
Get either x's successors or neighbors. This method enables to capitalize some code but should be called with care- Specified by:
getSuccOrNeighOf
in interfaceIGraph
- Parameters:
x
- a node index- Returns:
- x's successors if
this
is directed x's neighbors otherwise
-
getPredOf
public ISet getPredOf(int x)
Get predecessors of node x- Parameters:
x
- node index- Returns:
- predecessors of x
-
getPredOrNeighOf
public ISet getPredOrNeighOf(int x)
Description copied from interface:IGraph
Get either x's predecessors or neighbors. This method enables to capitalize some code but should be called with care- Specified by:
getPredOrNeighOf
in interfaceIGraph
- Parameters:
x
- a node index- Returns:
- x's predecessors if
this
is directed x's neighbors otherwise
-
-