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()
IGraph
getNbMaxNodes
in interface IGraph
public ISet getNodes()
public SetType getType()
IGraph
public boolean addNode(int x)
IGraph
public boolean removeNode(int x)
IGraph
removeNode
in interface IGraph
x
- 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)
IGraph
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 careisArcOrEdge
in interface IGraph
x
- 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)
IGraph
getPredOrNeighOf
in interface IGraph
x
- a node indexthis
is directed
x's neighbors otherwisepublic ISet getSuccOrNeighOf(int x)
IGraph
getSuccOrNeighOf
in interface IGraph
x
- a node indexthis
is directed
x's neighbors otherwisepublic boolean isDirected()
isDirected
in interface IGraph
this
is a directed graphCopyright © 2016. All rights reserved.