mercredi 1 avril 2020

Guava: MutableGraph with nodeOrder that is inverse-insertion

I want to create an object of type MutableGraph from Guava, like this:

MutableGraph<Integer> subgraph = GraphBuilder.undirected().nodeOrder(ElementOrder.insertion()).build();

When I use an iterator to get the nodes from the graph, the order is their insertion. I need to get them in reverse, so that I can retrieve that last added vertex with one call of

subgraph.nodes().iterator().next()

Aucun commentaire:

Enregistrer un commentaire