- java.lang.Object
-
- org.chocosolver.util.objects.graphs.UndirectedGraph
-
-
Constructor Summary
Constructors Constructor Description UndirectedGraph(int n, SetType type, boolean allNodes)
Creates an empty (non-backtrackable) undirected graph.UndirectedGraph(Model model, int n, SetType type, boolean allNodes)
Creates an empty backtrable undirected graph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEdge(int x, int y)
Add edge (x,y) to the graphboolean
addNode(int x)
Adds node x to the node set of the graphboolean
edgeExists(int x, int y)
test whether edge (x,y) is in the graph or notint
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
getNeighOf(int x)
Get neighbors of node xISet
getNodes()
ISet
getPredOrNeighOf(int x)
Get either x's predecessors or neighbors.ISet
getSuccOrNeighOf(int x)
Get either x's successors or neighbors.SetType
getType()
Get the type of data structures used in the graphboolean
isArcOrEdge(int x, int y)
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
removeEdge(int x, int y)
Remove edge (x,y) 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
-
UndirectedGraph
public UndirectedGraph(Model model, int n, SetType type, boolean allNodes)
Creates an empty backtrable undirected graph. Allocates memory for n nodes (but they should then be added explicitly, unless allNodes is true).- Parameters:
model
- model providing the backtracking environmentn
- max number of nodestype
- data structure storing for node neighborsallNodes
- true iff all nodes will always remain in the graph
-
UndirectedGraph
public UndirectedGraph(int n, SetType type, boolean allNodes)
Creates an empty (non-backtrackable) undirected graph. Allocates memory for n nodes (but they should then be added explicitly, unless allNodes is true).- Parameters:
n
- max number of nodestype
- data structure used for storing node neighborsallNodes
- true iff all nodes will always remain 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
-
addEdge
public boolean addEdge(int x, int y)
Add edge (x,y) to the graph- Parameters:
x
- a node indexy
- a node index- Returns:
- true iff (x,y) was not already in the graph
-
edgeExists
public boolean edgeExists(int x, int y)
test whether edge (x,y) is in the graph or not- Parameters:
x
- a node indexy
- a node index- Returns:
- true iff edge (x,y) is in the graph
-
isArcOrEdge
public boolean isArcOrEdge(int x, int y)
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:
x
- a node indexy
- a node index
-
removeEdge
public boolean removeEdge(int x, int y)
Remove edge (x,y) from the graph- Parameters:
x
- a node indexy
- a node index- Returns:
- true iff (x,y) was in the graph
-
getNeighOf
public ISet getNeighOf(int x)
Get neighbors of node x- Parameters:
x
- node index- Returns:
- neighbors of x (predecessors and/or successors)
-
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
-
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
-
isDirected
public boolean isDirected()
- Specified by:
isDirected
in interfaceIGraph
- Returns:
- true if and only if
this
is a directed graph
-
-