2

In jgrapht, I have added some vertex.

I wanted to know how to get all vertex that I have added or already exist in jgrapht ?

Is there a way to get it ?

Anto Livish A
  • 322
  • 4
  • 15

2 Answers2

5

This will give all the vertex in the graph.

DefaultDirectedGraph<String, DefaultEdge> directedGraph = new DefaultDirectedGraph<Node, DefaultEdge>(
            DefaultEdge.class)
directedGraph.vertexSet();
Anto Livish A
  • 322
  • 4
  • 15
1

You can use what Anto Livish's answer if you just have a graph If you create a GraphPath (like a shortest path), you can use getVertexList() and store them in a list

Taha
  • 65
  • 1
  • 10