如果我理解得很好,你需要一个“节点”对象的表示:
1)允许您存储值,以便稍后搜索正确的节点
2)使用预定义的数据结构来保存图形的信息。
3)允许搜索算法使用。
有一个简单的解决方案可以满足所有三个要求:
public class Node {
// Add as many fields as you need to contain the node info
private String mName;
private int mArbitraryValue;
// Store the adjacent nodes in a list
private List mAdjacencyList;
//Define your constructors
public Node(String name, int arbitraryValue, List adjacencyList) {
mName = name;
mArbitraryValue = arbitraryValue;
mAdjacencyList = adjacencyList;
}
/* Add your methods here depending on the functionality that
you want to implement
*/
public String getName() {
return mName;
}
public int getArbitraryValue() {
return mArbitraryValue;
}