| Constructor and 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.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addEdge(int x,
int y)
Add edge (x,y) to the graph
|
boolean |
addNode(int x)
Adds node x to the node set of the graph
|
boolean |
edgeExists(int x,
int y)
test whether edge (x,y) is in the graph or not
|
int |
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 graph
|
ISet |
getNeighOf(int x)
Get neighbors of node x
|
ISet |
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 graph
|
boolean |
isArcOrEdge(int x,
int y)
If
this is directed
returns true if and only if arc (x,y) exists
Else, if this 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 |
boolean |
isDirected() |
boolean |
removeEdge(int x,
int y)
Remove edge (x,y) from the graph
|
boolean |
removeNode(int x)
Remove node x from the graph
|
String |
toString() |
public UndirectedGraph(Model model, int n, SetType type, boolean allNodes)
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 graphpublic UndirectedGraph(int n,
SetType type,
boolean allNodes)
n - max number of nodestype - data structure used for storing node neighborsallNodes - true iff all nodes will always remain in the graphpublic int getNbMaxNodes()
IGraphgetNbMaxNodes in interface IGraphpublic ISet getNodes()
public SetType getType()
IGraphpublic boolean addNode(int x)
IGraphpublic boolean removeNode(int x)
IGraphremoveNode in interface IGraphx - a node indexpublic boolean addEdge(int x,
int y)
x - a node indexy - a node indexpublic boolean edgeExists(int x,
int y)
x - a node indexy - a node indexpublic boolean isArcOrEdge(int x,
int y)
IGraphthis is directed
returns true if and only if arc (x,y) exists
Else, if this is undirected
returns true if and only if edge (x,y) exists
This method enables to capitalize some code but should be called with careisArcOrEdge in interface IGraphx - a node indexy - a node indexpublic boolean removeEdge(int x,
int y)
x - a node indexy - a node indexpublic ISet getNeighOf(int x)
x - node indexpublic ISet getPredOrNeighOf(int x)
IGraphgetPredOrNeighOf in interface IGraphx - a node indexthis is directed
x's neighbors otherwisepublic ISet getSuccOrNeighOf(int x)
IGraphgetSuccOrNeighOf in interface IGraphx - a node indexthis is directed
x's neighbors otherwisepublic boolean isDirected()
isDirected in interface IGraphthis is a directed graphCopyright © 2017. All rights reserved.