2017-12-19 27 views
1

연결 구성 요소, 내가 컬렉션을 통과 한 후 카운터를 추가 할그래프를 통과 할 때 나는 카운터를 추가 할

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 [email protected] \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 [email protected] \n" + 
" return MYFUNCTION::dfs(v,@count,@@collection,@graph)"; 
var param = {count:c,@tv:collection,graph:graphName}; 
db._query(query,param); 
} 
module.exports = connection; 

작성하는 법을 모르겠습니다. 도와 주실 수 있습니까?

그래프의 약한 연결 요소를 찾고 싶었습니다.

답변

0

약 결합 된 구성 요소를 찾기 위해 "연결된 구성 요소"라는 알고리즘을 ArangoDB에서 사용할 수 있습니다. 그것은 함께 실행될 수 https://docs.arangodb.com/3.2/Manual/Graphs/Pregel/#connected-components

:

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

알고리즘이 문서화되고