试试这个查询:
traverse both() from YourClass while both('your_edge_class').size() = 0 and $depth <= 25
所以遍历不会传递连接到您指定的边/边的顶点
编辑:
给定以下图形示例并假设您不想要边type1
和type2
,您想将节点 1、2、3、4、5 和 8 连接到边type 3
还是要避免所有顶点也连接和?type 1
_type 2
编辑:
您可以使用此 javascript 函数和三个参数(rid、maxDepth、excludeEdges)
var g=orient.getGraph();
var result=[];
var current=[];
var next=[];
var listEdges=excludeEdges.substring(1,excludeEdges.length-1).split(",");
var root=g.command('sql','select from '+rid);
current.push(root[0]);
var step=1;
while(current.length>0 && step<=maxDepth){
for(i=0;i<current.length;i++){
getVertex(current[i],"OUT");
getVertex(current[i],"IN");
}
change();
step++;
}
return result;
function change(){
current=[];
for (index=0;index<next.length;index++)
current.push(next[index]);
next=[];
}
function getVertex(start,direction){
var edgeDir="outE()";
var reverseDirection="in";
if(direction=="IN"){
edgeDir="inE()";
reverseDirection="out";
}
var edges=g.command("sql","select expand("+edgeDir +") from "+start.getId());
for(h=0;h<edges.length;h++){
var found=false;
for(m=0;m<listEdges.length;m++){
if(edges[h].getProperty("@class")==listEdges[m]){
found=true;
break;
}
}
if(found==false){
var vertex=g.command("sql","select expand("+ reverseDirection + ") from " +edges[h].getId());
for(j=0;j<result.length;j++){
if(result[j].getId().toString().equals(vertex[0].getId().toString()) ||
vertex[0].getId().toString().equals(rid)){
found=true;
break;
}
}
if(found==false){
result.push(vertex[0]);
next.push(vertex[0]);
}
}
}
}
使用以下命令
select expand(result) from (select myFunction("#9:1",25,"[type1,type2]") as result)