Class DirectedGraph
- 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 booleanaddArc(int from, int to)add arc (from,to) to the graphbooleanaddNode(int x)Adds node x to the node set of the graphbooleanarcExists(int from, int to)Test whether arc (from,to) exists or not in the graphintgetNbMaxNodes()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 graphISetgetNodes()ISetgetPredOf(int x)Get predecessors of node xISetgetPredOrNeighOf(int x)Get either x's predecessors or neighbors.ISetgetSuccOf(int x)Get successors of node xISetgetSuccOrNeighOf(int x)Get either x's successors or neighbors.SetTypegetType()Get the type of data structures used in the graphbooleanisArcOrEdge(int from, int to)Ifthisis directed returns true if and only if arc (x,y) exists Else, ifthisis undirected returns true if and only if edge (x,y) existsbooleanisDirected()booleanremoveArc(int from, int to)remove arc (from,to) from the graphbooleanremoveNode(int x)Remove node x from the graphStringtoString()
-
-
-
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:IGraphThe 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:
getNbMaxNodesin interfaceIGraph- Returns:
- the maximum number of nodes of the graph
-
getNodes
public ISet getNodes()
-
getType
public SetType getType()
Description copied from interface:IGraphGet the type of data structures used in the graph
-
addNode
public boolean addNode(int x)
Description copied from interface:IGraphAdds node x to the node set of the graph
-
removeNode
public boolean removeNode(int x)
Description copied from interface:IGraphRemove node x from the graph- Specified by:
removeNodein 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:IGraphIfthisis directed returns true if and only if arc (x,y) exists Else, ifthisis 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:
isArcOrEdgein interfaceIGraph- Parameters:
from- a node indexto- a node index
-
isDirected
public boolean isDirected()
- Specified by:
isDirectedin interfaceIGraph- Returns:
- true if and only if
thisis 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:IGraphGet either x's successors or neighbors. This method enables to capitalize some code but should be called with care- Specified by:
getSuccOrNeighOfin interfaceIGraph- Parameters:
x- a node index- Returns:
- x's successors if
thisis 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:IGraphGet either x's predecessors or neighbors. This method enables to capitalize some code but should be called with care- Specified by:
getPredOrNeighOfin interfaceIGraph- Parameters:
x- a node index- Returns:
- x's predecessors if
thisis directed x's neighbors otherwise
-
-