我Treeset
用来对边缘进行排序,这是代码:
TreeSet<Edge> edges = new TreeSet<Edge>();
//Sample problem - replace these values with your problem set
edges.add(new Edge("0", "1", 2));
edges.add(new Edge("0", "3", 1));
edges.add(new Edge("1", "2", 3));
edges.add(new Edge("2", "3", 5));
edges.add(new Edge("2", "4", 7));
edges.add(new Edge("3", "4", 6));
edges.add(new Edge("4", "5", 4));
System.out.println("Graph");
KruskalEdges vv = new KruskalEdges();
for (Edge edge : edges) {
System.out.println(edge);
vv.insertEdge(edge);
}
我只想从用户那里获取输入,而不是静态地给予edges.add