Hi,
I've been struggling with how to find every path that follows a certain patern (i.e Va(property1="a")->Vb(property1="b")->Vc(property1="c")) and store the vertices (Va,Vb and Vc in this example) for every path found.
As for now, i find all vertices which property1 is "a" and then i use the interseccion of "neighbors" and "select(property1,Condition.Equal,v.setString("b")" finally i repeat this step by each hop.
¿Any tips on how do this query?.
Thank for your time.
PD: API Java
int newEdgeType(java.lang.String name, boolean directed, boolean neighbors) <- TRUE
Value val = new Value();
ObjectsIterator it_A = nodes_A.iterator();
while (it_A.hasNext()) {
long oid_A = it_A.next();
// STEP 5
// For each oid_A get its neigbors that fit the B condition
// Assuming there's only one possible edge type. You should repteat this
// process for each possible edge type.
Objects nodes_B = graph.neighbors(oid_A, the_edge_type, EdgesDirection.Outgoing);
ObjectsIterator it_B = nodes_B.iterator();
while (it_B.hasNext()) {
long oid_B = it_B.next();
// Get the property for the oid_B node
graph.getAtrribute(oid_B, theProperty, val);
// Check if the value fits the condition
if ( /* the val is ok */)
{
// STEP 6
// Repeat the same process of the step 5 again for the C objects
Objects nodes_C = graph.neighbors(oid_B, the_edge_type, EdgesDirection.Outgoing);
ObjectsIterator it_C = nodes_C.iterator();
while (it_C.hasNext()) {
long oid_C = it_C.next();
// Get the property for the oid_C node
graph.getAtrribute(oid_C, theProperty, val);
// Check if the value fits the condition
if ( /* the val is ok */)
{
// PATH FOUND: oid_A -> oid_B -> oid_C
}
}
it_C.close();
nodes_C.close();
}
}
it_B.close();
nodes_B.close();
}
// Remember to close the iterators and Objects
it_A.close();
nodes_A.close();