I want to traverse a graph and return all paths that link 2 nodes where the first relationship is outgoing and the second is incoming. For example if the relationship is Voted and i want to see all possible paths from node 25 to node 86 i have MATCH p=((n {id:"25"}) -[*1..2]-> (m {id:"86"})) RETURN p; Then I want to check if in the returned path i have the same kind of property in the outgoing and incoming relationship (if they have the same vote).
I try to accomplish that with the graph traversal api in java but all i get back is a single path how can I get all possible paths in order to check them?
{it is basically a checking relationships with all common neighbors problem}
int common = 0;
int diff = 0;
for ( Path position : graphDb.traversalDescription()
.relationships(Wikilections_user.RelTypes.Voted, Direction.OUTGOING)
.relationships(Wikilections_user.RelTypes.Voted, Direction.INCOMING)
// .evaluator(Evaluators.fromDepth(1))
.evaluator(Evaluators.toDepth(2))
.evaluator(Evaluators.includeWhereEndNodeIs(node2))
// .evaluator(Evaluators.excludeStartPosition())
.traverse(node1))
{
Iterable<Relationship> myRels = position.reverseRelationships();
for (Relationship temp : myRels) {
System.out.println((temp.getStartNode()).getProperty("id") + " with " + temp.getProperty("with") + " :" + (temp.getEndNode()).getProperty("id"));
}
String with = "";
int i = 0;
for (Relationship temp : myRels) {
if (i == 0) {
with = (String) temp.getProperty("with");
i++;
}
if (i == 1) {
if (((String) temp.getProperty("with")).equals(with)) {
common++;
} else {
diff++;
}
}
}
}
return (double) common * 100 / (common + diff);