File tree Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Expand file tree Collapse file tree 4 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @antv/algorithm" ,
3
- "version" : " 0.1.10 " ,
3
+ "version" : " 0.1.11 " ,
4
4
"description" : " graph algorithm" ,
5
5
"keywords" : [
6
6
" graph" ,
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ const breadthFirstSearch = (
43
43
graphData : GraphData ,
44
44
startNodeId : string ,
45
45
originalCallbacks ?: IAlgorithmCallbacks ,
46
+ directed : boolean = true
46
47
) => {
47
48
const callbacks = initCallbacks ( originalCallbacks ) ;
48
49
const nodeQueue = new Queue ( ) ;
@@ -63,7 +64,7 @@ const breadthFirstSearch = (
63
64
} ) ;
64
65
65
66
// 将所有邻居添加到队列中以便遍历
66
- getNeighbors ( currentNode , edges , 'target' ) . forEach ( ( nextNode ) => {
67
+ getNeighbors ( currentNode , edges , directed ? 'target' : undefined ) . forEach ( ( nextNode ) => {
67
68
if (
68
69
callbacks . allowTraversal ( {
69
70
previous : previousNode ,
Original file line number Diff line number Diff line change @@ -503,7 +503,11 @@ const GADDI = (
503
503
) ;
504
504
505
505
// 若未指定 length,自动计算 pattern 半径(最短路径最大值)
506
- if ( ! length ) length = Math . max ( ...patternSpm [ 0 ] , 2 ) ;
506
+ let patternSpmSpread = [ ] ;
507
+ patternSpm ?. forEach ( row => {
508
+ patternSpmSpread = patternSpmSpread . concat ( row ) ;
509
+ } )
510
+ if ( ! length ) length = Math . max ( ...patternSpmSpread , 2 ) ;
507
511
if ( ! k ) k = length ;
508
512
509
513
// console.log("params", directed, length, k);
@@ -735,7 +739,7 @@ const GADDI = (
735
739
736
740
// candidates 经过筛选后,以每个 candidate 为中心,生成 Length-neighbor 的邻居诱导子图
737
741
// 并在诱导子图中去除不可能在 Q 上找到匹配的点:在 Q 上不存在的 label,其他 label 到 candidate 的最大最短距离符合 Q、NDS 距离符合 Q
738
- candidates . forEach ( candidate => {
742
+ candidates ? .forEach ( candidate => {
739
743
const nodeIdx = nodeMap [ candidate . id ] . idx ;
740
744
const lengthNeighborUnit = findKNeighborUnit (
741
745
graphData . nodes ,
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ export interface IAlgorithm {
56
56
graphData : GraphData ,
57
57
startNodeId : string ,
58
58
originalCallbacks ?: IAlgorithmCallbacks ,
59
+ directed ?: boolean
59
60
) => void ,
60
61
connectedComponent : ( graphData : GraphData , directed ?: boolean ) => NodeConfig [ ] [ ] ,
61
62
getDegree : ( graphData : GraphData ) => DegreeType ,
You can’t perform that action at this time.
0 commit comments