Skip to content

Commit 165f67c

Browse files
authored
Merge pull request #36 from antvis/0.1.12
fix: GADDI with undefined label
2 parents 95569a0 + 08e88f6 commit 165f67c

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

packages/graph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@antv/algorithm",
3-
"version": "0.1.11",
3+
"version": "0.1.13",
44
"description": "graph algorithm",
55
"keywords": [
66
"graph",

packages/graph/src/gSpan/gSpan.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,9 @@ class DFScode {
112112
const toNodeId = dfsEdge.toNode;
113113
const { nodeLabel1, edgeLabel, nodeLabel2 } = dfsEdge.nodeEdgeNodeLabel;
114114

115-
if (nodeLabel1 !== VACANT_NODE_LABEL)
116-
graph.addNode(fromNodeId, nodeLabel1);
115+
if (nodeLabel1 !== VACANT_NODE_LABEL) graph.addNode(fromNodeId, nodeLabel1);
117116
if (nodeLabel2 !== VACANT_NODE_LABEL) graph.addNode(toNodeId, nodeLabel2);
118-
119-
graph.addEdge(undefined, fromNodeId, toNodeId, edgeLabel);
117+
if (nodeLabel1 !== VACANT_NODE_LABEL && nodeLabel2 !== nodeLabel1) graph.addEdge(undefined, fromNodeId, toNodeId, edgeLabel);
120118
});
121119
return graph;
122120
}
@@ -429,6 +427,7 @@ class GSpan {
429427

430428
// 比较 root 中每一项的 nodeEdgeNodeLabel 大小,按照 nodeLabel1、edgeLabe、nodeLabel2 的顺序比较
431429
let minLabel = this.findMinLabel(root); // line 419
430+
if (!minLabel) return;
432431
dfsCodeMin.dfsEdgeList.push(
433432
new DFSedge(
434433
0,

packages/graph/src/gaddi.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ const getMatchedCount = (graph, structure, nodeLabelProp, edgeLabelProp) => {
204204
nodeMap[node.id] = node;
205205
});
206206
let count = 0;
207+
if (!structure?.edges?.length || structure?.nodes?.length < 2) return 0;
207208
graph.edges.forEach(e => {
208209
const sourceLabel = nodeMap[e.source][nodeLabelProp];
209210
const targetLabel = nodeMap[e.target][nodeLabelProp];
@@ -540,7 +541,6 @@ const GADDI = (
540541
// );
541542
// 1.2. 生成上面节点对的相应相交邻居诱导子图。格式为 {'beginNodeIdx-endNodeIdx': {nodes: [], edges: []}}
542543
let intGMap = getIntersectNeighborInducedGraph(nodePairsMap, kNeighborUnits, graphData);
543-
544544
// 1.3. 使用 gSpan 算法(frequent graph mining)计算 ISIntG 的前 10 个频率最高的子结构(3-4条边)
545545
const top = 10,
546546
minSupport = 1,
@@ -797,7 +797,6 @@ const GADDI = (
797797
}
798798
}
799799

800-
801800
// prune3: 若该邻居点到 candidate 的 NDS 距离比和它有相同 label 的节点到 beginPNode 的最小 NDS 距离小,移除这个点
802801
const ndsToCandidate = ndsDist[key]
803802
? ndsDist[key]

0 commit comments

Comments
 (0)