|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--net.aerith.misao.util.Graph
The Graph represents a graph which consists of some
nodes and branches connecting the nodes.
| Field Summary | |
protected boolean[][] |
branch
The branch[i][j] is true if node i and j is directly connected. |
private int |
max_steps
The maximum steps to search, used in method checkReachableIndexes. |
protected int |
number_of_nodes
The number of nodes. |
private boolean[] |
reached_flag
The reached_flag[i] is true if node i is reached already, used in method checkReachableIndexes. |
| Constructor Summary | |
Graph(int nodes)
Constructs a Graph of the specified number of
nodes. |
|
| Method Summary | |
private void |
checkReachableIndexes(int index,
int current_step)
Checkes the reachable nodes. |
void |
connect(int i,
int j)
Connects the node i and j. |
void |
disconnect(int i,
int j)
Disconnects the node i and j. |
int |
getNodeCount()
Gets the number of nodes. |
int[] |
getReachableIndexes(int index)
Gets the list of indexes of nodes reachable from the specified node. |
int[] |
getReachableIndexesInStep(int index,
int steps)
Gets the list of indexes of nodes reachable from the specified node within the specified steps. |
boolean |
isConnected(int i,
int j)
Returns true if the node i and j are connected. |
boolean |
isReachable(int i,
int j)
Returns true if the node j is reachable from the node i. |
boolean |
isReachableInStep(int i,
int j,
int steps)
Returns true if the node j is reachable from the node i within the specified steps. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected int number_of_nodes
protected boolean[][] branch
private int max_steps
checkReachableIndexes.private boolean[] reached_flag
checkReachableIndexes.| Constructor Detail |
public Graph(int nodes)
Graph of the specified number of
nodes. No nodes are connected with the other nodes at first.nodes - the number of nodes.| Method Detail |
public int getNodeCount()
public void connect(int i,
int j)
i - the index of node to be connected.j - the index of node to be connected.
public void disconnect(int i,
int j)
i - the index of node to be disconnected.j - the index of node to be disconnected.
public boolean isConnected(int i,
int j)
i - the index of node to check.j - the index of node to check.
public boolean isReachable(int i,
int j)
i - the index of node to check.j - the index of node to check.
public boolean isReachableInStep(int i,
int j,
int steps)
i - the index of node to check.j - the index of node to check.steps - the maximum steps to reach to node j from i.public int[] getReachableIndexes(int index)
index - the index of start node.
public int[] getReachableIndexesInStep(int index,
int steps)
index - the index of start node.steps - the maximum steps to reach. In the case of -1, it
means there is no limit of steps to reach.
private void checkReachableIndexes(int index,
int current_step)
getReachableIndexesInStep. The
max_steps and reached_flag must be set
properly before invoking this method.index - the index of start node.current_step - the current step.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||