A hash map is one possible criterion for "blinding" traversals, but there are others. What if you want to include all of the edges with timestamps newer than one hour (poor man's TTL), or all of the vertices which have been marked with a certain property, and all of their incident edges. What if you want to create a logical subgraph which is too large to fit into memory?
I have just checked in a wrapper implementation, currently here:
...which lets you create create subgraphs based on arbitrary vertex and/or edge inclusion criteria. E.g.
Graph g = TinkerFactory.createClassic();
Function<Vertex, Boolean> vertexCriterion = vertex -> (int)
vertex.id() < 4;
Function<Edge, Boolean> edgeCriterion = edge -> true;
Subgraph sg = new Subgraph(g, vertexCriterion, edgeCriterion);
// three vertices are included in the subgraph
assertEquals(6, count(g.V().toList()));
assertEquals(3, count(sg.V().toList()));
// only two edges are present, even though edges are not explicitly excluded
// (edges require their incident vertices)
assertEquals(6, count(g.E().toList()));
assertEquals(2, count(sg.E().toList()));
assertEquals(2, count(g.v(1).out("knows").toList()));
assertEquals(1, count(sg.v(1).out("knows").toList()));
or
Set<Integer> includedEdgeIds = new HashSet<>();
includedEdgeIds.add(8);
includedEdgeIds.add(9);
includedEdgeIds.add(10);
Graph g = TinkerFactory.createClassic();
Function<Vertex, Boolean> vertexCriterion = vertex -> true;
Function<Edge, Boolean> edgeCriterion = edge -> includedEdgeIds.contains((int)
edge.id());
Subgraph sg = new Subgraph(g, vertexCriterion, edgeCriterion);
// all vertices are here
assertEquals(6, count(g.V().toList()));
assertEquals(6, count(sg.V().toList()));
// only the given edges are included
assertEquals(6, count(g.E().toList()));
assertEquals(3, count(sg.E().toList()));