我在HGraph类
中有一个如下所示的Hypergraph构造Map<HEdge, ArrayList<HVertex>> hGraph = new HashMap<HEdge, ArrayList<HVertex>>();
并希望使用以下函数打印所有(键,值)对。但我得到的只是:
Hypergraph:
e4(2.0)[]
e3(2.0)[]
e1(3.0)[]
e2(2.0)[]
e5(2.0)[]
[]中没有任何内容,甚至没有用于调试的“#”符号!!我还覆盖了HEdge和HVertex类中的toString方法来打印出他们的标签。
public void printHGraph(HGraph hGraph) {
Set<HEdge> edges = hGraph.getAllHEdges();
HEdge edge;
HVertex vertex;
ArrayList<HVertex> edge_vertices;
System.out.println("Hypergraph:");
Iterator<HEdge> edge_iterator = edges.iterator();
while(edge_iterator.hasNext()) {
edge = edge_iterator.next();
System.out.print(edge.toString());
System.out.print("[");
edge_vertices = hGraph.getHVertices(edge);
Iterator<HVertex> vertex_iterator = edge_vertices.iterator();
while(vertex_iterator.hasNext()) {
System.out.print("#"); //@debug
vertex = vertex_iterator.next();
System.out.print(vertex.toString()+", ");
}
System.out.print("]");
System.out.println();
}