From: Li Yuejiong(John) <jo...@ma...> - 2004-12-29 11:44:52
|
Hi, I list a peice of sample code below, I try to find the edge between two vertex. But findEdge works only between neighboor vertex. Is this correct? And is there convient way that I can use to decide if there is any cycle in a graph? Thanks, John Li { DirectedSparseGraph graph =3D new DirectedSparseGraph(); =20 DirectedSparseVertex vertex00 =3D new DirectedSparseVertex(); DirectedSparseVertex vertex01 =3D new DirectedSparseVertex(); DirectedSparseVertex vertex02 =3D new DirectedSparseVertex(); =20 graph.addVertex(vertex00); graph.addVertex(vertex01); graph.addVertex(vertex02); DirectedSparseEdge edge01 =3D new DirectedSparseEdge(vertex00, vertex01); DirectedSparseEdge edge12 =3D new DirectedSparseEdge(vertex01, vertex02); =20 graph.addEdge(edge01); graph.addEdge(edge12); =20 //edgeGet will be "null", is it correct? Edge edgeGet =3D vertex00.findEdge(vertex02); //This can work. Edge neighboor =3D vertex00.findEdge(vertex01); } |