if possible please post some sample codes. Because we have a project wherein we need to set up locations within a map, and connect those locations with a line. Other than we also need to have a starting and end point in which we need to find a path going from the designated starting to the end point.
import java.util.*;
class Node {
Node(Object object) {
this.object=object;
}
Object object;
List<Node> children=new ArrayList<Node>();
public String toString() {
return object.toString();
}
static void traverse(Node node) {
System.out.println(node);
for(Node child:node.children)
traverse(child);
}
}
public class Main {
public static void main(String[] args) {
Node root=new Node("root");
root.children.add(new Node("child 1"));
root.children.add(new Node("child 2"));
Node.traverse(root);
}
}
如果您没有阅读有关Dijkstra的信息,请首先尝试,如果您想找到一种方法来获取两个节点之间的最佳(最短)路线...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.