OrientDB:仅遍历具有某些属性的边
我想从顶点开始遍历,只遍历与特定表达式匹配的边(例如:OrientDB:仅遍历具有某些属性的边,orientdb,Orientdb,我想从顶点开始遍历,只遍历与特定表达式匹配的边(例如:friendsWith.type=“BestFriends”)。我该怎么做 此外,我必须对一组顶点运行此操作。有可能通过遍历的“头”来组织事物吗?理想的回报是: [[start1,[遍历期间所有顶点的列表],[start2,[…],…]尝试以下操作: select outV().name as start, inV().name as end from(traverse * from friendsWith while type = "bes
friendsWith.type=“BestFriends”
)。我该怎么做
此外,我必须对一组顶点运行此操作。有可能通过遍历的“头”来组织事物吗?理想的回报是:
[[start1,[遍历期间所有顶点的列表],[start2,[…],…]
尝试以下操作:
select outV().name as start, inV().name as end from(traverse * from friendsWith while type = "bestFriend")
即使没有导线测量,也可以做到这一点
希望能有帮助
问候。我试着用这个图表 我将此javascript函数与参数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=[];
}
var g=orient.getGraph();
var节点=[];
var先前=[];
var当前=[];
var b=g.command(“sql”、“从”+rid中选择”);
如果(b.长度>0){
var顶点=b[0];
上推(顶点);
节点。推(顶点);
做{
对于(i=0;它的遍历部分对我不起作用,不是应该是从遍历吗?我尝试了从V中遍历inE('friendsWith'),而type=“bestFriend”
没有得到任何结果。我想,你从V中没有得到任何东西,而type=“bestFriend”因为你的顶点没有属性类型OK,这就更有意义了-你是说我应该遍历边而不是顶点,这样“while”命令就为你提供了边属性。你怎么能用SELECT来做到这一点呢?比如说,只需要向下两层。我知道你可以做SELECT out('friendswith')。out('friendswith'))从E
中,但我不知道如何在那里指定边属性。可以使用WHERE指定边属性condition@MichelaBonizzi是的,但是“where”条件是否适用于第一个或第二个或两个“out('friendswith')”组件?谢谢!你能更好地解释你想要得到什么吗?应该开始什么?你能提供一个例子吗?你能接受一个javascript函数吗?@Alessandrororota实际上一个javascript函数会非常有用。这看起来非常好!我能问一下,你希望在服务器上用javascript调用这个函数有意义吗比用python(pyorient)编写本地脚本(即调用SELECT命令并组织结果)快得多是的,你可以在服务器上用javascript调用这个函数。我的意思是,javascript函数和SQL调用一样快吗?客户端python脚本比两者都慢吗?我认为服务器端的javascript函数比客户端pyhon脚本快