I would like to traverse from a vertex, only following edges that match a particular expression (example: friendsWith.type="bestFriend"
). How do I do this?
Furthermore, I have to run this operation for a bunch of vertices. Is it possible to keep things organized by the "head" of the traversals? Ideally the return would be:
[[start1, [list of all the vertices during traversal], [start2, [...]],...]
I tried with this graph
I used this javascript function with the parameter rid
var g=orient.getGraph();
var nodes = [];
var previous=[];
var currently=[];
var b=g.command("sql","select from " + rid);
if(b.length>0){
var vertex=b[0];
previous.push(vertex);
nodes.push(vertex);
do{
for(i=0;i<previous.length;i++){
var vertexOut=previous[i];
var edges=g.command("sql","select expand(outE('friendsWith')) from "+ vertexOut.getId());
for(s=0;s<edges.length;s++){
var edge=edges[s];
var type= edge.getProperty("type");
if(type=="bestFriend"){
var vertices=g.command("sql","select expand(inV('friendsWith')) from "+ edge.getId());
var vertex=vertices[0];
var found=false;
for(k=0;k<nodes.length;k++){
var id=nodes[i].getId();
var id_v=vertex.getId()
if(id==id_v){
found=true;
break;
}
}
if(found==false){
currently.push(vertex);
nodes.push(vertex);
}
}
}
}
change();
}while(previous.length>0);
return nodes;
}
function change(){
previous=[];
for (indice=0;indice<currently.length;indice++)
previous.push(currently[indice]);
currently=[];
}
and with select expand(node) from (select myFunction("#9:0") as node)
I got
Hope it helps.