Search code examples
jgrapht

Get all vertex in JgraphT


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 ?


Solution

  • This will give all the vertex in the graph.

    DefaultDirectedGraph<String, DefaultEdge> directedGraph = new DefaultDirectedGraph<Node, DefaultEdge>(
                DefaultEdge.class)
    directedGraph.vertexSet();