Hello again, everyone!
I have a Gremlin question relating to sub-graphing and/or shortest paths. I'm looking to identify the best way to go about this specific type of inquiry.
I have a set of IDs of nodes I'm interested in (sources) understanding the possible relationships with other node IDs (targets) representing concepts I'm already familiar with. The target nodes are sort of like "gold standard" nodes - I'm interested to see how seemingly unrelated concepts individually and (ideally) jointly link to them.
This sounds like a shortest-path problem between all unique combinations of node source and target node IDs.
Say I have the following:
sourceIDs = 101,102,103
targetIDs = 1,2
You'd want to aggregate N number of shortest paths (where path <= 6, say) between [101,1], [101,2], [102,1], [102,2], [103,1], [103,2]. And let's see whether there are any meaningful paths to the target nodes, as well as any interesting merges which occur between the paths returned.
This seems like it utilizes some type of iteration I'm not familiar with how to do in the context of Gremlin.
Solutions I've tried so far:
1.) Create a subgraph from all the edges between all the included source + target nodes:
g.V(1,2,101,102,103).repeat(__.outE().subgraph('subgraph').inV()).times(3).cap('subgraph').next()
This doesn't really get me what I'm looking for, since I have to hardcode the number of .times() and hope for some meaningful connections to surface to the targets, and it returns back EVERY connected node - which is memory intensive.
2.) Use path:
g.V(101,102,103).repeat(out().simplePath()).until(hasId(1)).path().limit(5);
g.V(101,102,103).repeat(out().simplePath()).until(hasId(2)).path().limit(5);
But this does not guarantee that the next node ID (i.e. 102) will ever be considered (at least this is my understanding).
What I need is more like an aggregation of all paths via #2 of all unique source/target combinations.
Is there any way I can accomplish this in Gremlin?
Thanks all and have a great weekend!
Tim