I'm looking for a way to retrieve a node using an identifier, using only the Guava library. I prefer not to use an external HashSet, which I have considered, because my dataset is too big.
I would like a way to index all of my graph nodes using an index, using a String or integer type, and be later able to retrieve my nodes efficiently.
Right now I could iterate over the nodes set of my MutableGraph, and check for object equality, like this :
MutableGraph<CategoryNode> wikiGraph = GraphBuilder.directed().build();
for (MyNode node : wikiGraph.nodes()) {
if(node.equals(new MyNode("myStringIndex"))) {
// object found !
return node;
}
}
But this is highly inefficient if the number of nodes gets big. Is there a built-in solution for indexing graph nodes in Guava or do I need to use another library ?