【问题标题】:How to weaken the connection component如何弱化连接组件
【发布时间】: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;

我不知道怎么写,你能帮帮我吗?

我只是想找到一个图的弱连通分量。

【问题讨论】:

    标签: graph arangodb


    【解决方案1】:

    ArangoDB 提供了一种名为“连接组件”的算法,用于在图中查找弱连接组件。 它可以通过以下方式执行:

    var pregel = require("@arangodb/pregel");
    pregel.start("connectedcomponents", "graphname")
    

    算法记录在: https://docs.arangodb.com/3.2/Manual/Graphs/Pregel/#connected-components

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-27
      相关资源
      最近更新 更多