我有一个关于 OrientDB 的 shortestPath() 函数的问题。如果我查询 select shortestPath('#9:1', '#15:1', 'BOTH')
针对 OrientDB,我只得到了路径的顶点。但我也想要它们之间的边缘。
如何同时选择顶点和边?
最佳答案
您可以使用 javascript 函数。
我用过这些记录
我用了这个代码
var g=orient.getGraph();
var b=g.command("sql","select expand(shortestPath(" + start + "," + end + ", 'BOTH'))");
var list=[];
for(i=0;i<b.length-1;i++){
var rid1=b[i].getId();
var rid2=b[i+1].getId();
var query="select from e where out = " + rid1 + " and in = " + rid2 + " limit 1";
var edge=g.command("sql",query);
list.push(b[i]);
list.push(edge[0]);
if(i==b.length-2){
list.push(b[i+1]);
}
}
return list;
希望能帮助到你。
关于OrientDB 使用 shortestPath() 获取边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36794694/