【发布时间】:2017-12-19 10:55:31
【问题描述】:
我想在遍历图的时候加一个计数器,
for x in mycollection
for v,e,p in 1..1 any x._id graph'mygraph'
return v
我想在遍历集合后加一个计数器,我想遍历遍历后的图形计数器加1。
let count=1
for x in mycollection
for v,e,p in 1..1 any x._id graph'mygraph'
return v
count++
我对集合的长度不感兴趣,我只想遍历每个之后的图形,计数器加1 我写了两个未完成的js文件, 事实上,我是在尝试找出图中的弱连通分量,代码如下所示
'use strict';
function connectionGraph(vertex,count1,collection,graphName) {
var db = require('@arangodb').db;
var q2 = " for v,e,p in 1..1 any @vt._id graph @graph \n" +
" update x with{label:@count} in @@ttv \n" +
" filter v.label!=@count \n" +
" return MYFUNCTION::dfs(v,@count,@@ttv)";
var param = {vt:vertex,count:count1,@ttv:collection,graph:graphName}
db._query(q2,param);
}
module.exports = connectionGraph;
'use strict';
function connection(c,collection,graphName) {
var db = require('@arangodb').db;
int c = 1;
var query = "for x in @@tv \n"
"for v,e,p in 1..1 any x._id graph @graph \n" +
" update x with{label:@count} in @@tv \n" +
" filter v.label!=@count \n" +
" return MYFUNCTION::dfs(v,@count,@@collection,@graph)";
var param = {count:c,@tv:collection,graph:graphName};
db._query(query,param);
}
module.exports = connection;
我不知道怎么写,你能帮帮我吗?
我只是想找到一个图的弱连通分量。
【问题讨论】: