Labyrinth
A labyrinth game assignment
|
Provides a graph functionality for the room preventing algorithm. More...
Package Functions | |
Graph (int v) | |
Constructs a node of the graph using the value of a vertex(node). More... | |
Graph (Edge e) | |
Constructor that transform an edge into graph. More... | |
int | getV () |
Access to the current vertex. More... | |
ArrayList< Graph > | getE () |
Access to the links of the current vertex. More... | |
boolean | attach (Edge e) |
Attach an edge into a graph IFF the graph already has a vertex with the same value as one of the vertices of the edge. More... | |
int | count (int v) |
Counts the number of vertices on the graph with the value of v More... | |
Private Member Functions | |
int | tryAttach (Edge e, int count) |
Recursive algorithm that tries to attach an edge into a graph IFF the graph already has a vertex with the same value as one of the vertices of the edge. More... | |
int | tryCount (int v, int count) |
Recursive algorithm that tries to count the number of vertices on the graph with the same value as v . More... | |
Private Attributes | |
int | V |
The value of the current vertex/node. More... | |
ArrayList< Graph > | E |
A list of all the child nodes. More... | |
Provides a graph functionality for the room preventing algorithm.
We use a graph to represent the wall structure of the walls. This way its easy to find any closed loops. Using graph we transform the problem of the closed room into the problem of finding a non simple graph.
If the board has non connected wall structure then we would need more than one graph to represent it.
An example graph we can create from the board bellow, starting from V=1 is:
6—7 8 (1) | | / \ 3 4 5 (4) (2) | | | \ 0 1—2 (5)–(8)
Definition at line 324 of file Common.java.
|
package |
Constructs a node of the graph using the value of a vertex(node).
v | The verteg to attach. |
Definition at line 329 of file Common.java.
|
package |
Constructor that transform an edge into graph.
e | The edge to transform. |
Definition at line 337 of file Common.java.
|
package |
Attach an edge into a graph IFF the graph already has a vertex with the same value as one of the vertices of the edge.
e | The edge to attach. |
Definition at line 356 of file Common.java.
|
package |
Counts the number of vertices on the graph with the value of v
v | The vertex to count |
v
Definition at line 365 of file Common.java.
|
package |
Access to the links of the current vertex.
Definition at line 346 of file Common.java.
|
package |
Access to the current vertex.
Definition at line 344 of file Common.java.
|
private |
Recursive algorithm that tries to attach an edge into a graph IFF the graph already has a vertex with the same value as one of the vertices of the edge.
e | The edge to attach. |
count | An initial count value to feed the algorithm. |
Definition at line 380 of file Common.java.
|
private |
Recursive algorithm that tries to count the number of vertices on the graph with the same value as v
.
v | The vertex to count |
count | An initial count value to feed to the algorithm. |
v
Definition at line 402 of file Common.java.
|
private |
A list of all the child nodes.
Definition at line 411 of file Common.java.
|
private |
The value of the current vertex/node.
Definition at line 410 of file Common.java.