I am trying to randomly traverse through the graph in jgrapht (until I find some target node). To do it, I need to start at the sourceNode, randomly pick any coming out edge and follow it.
I know there there is a method getAllEdges(sourceVertex, targetVertex)
that returns all the edges between two given nodes. But how can I get all edges while having only sourceNode, without the target one?
vertexSet()
method) and then pass each vertex from this set astargetVertex
for the methodgetAllEdges()
and combine the results of all these calls. or 2. get all edges usingedgeSet()
method. Then for each of these edges callgetEdgeSource(E e)
to get sourceVertext. Then compare it eith given vertex to see if this edge starts from the given vertex. Collect these edges and you have your desired result. – Tetter