Skip to content

Commit

Permalink
Merge pull request #36 from antvis/0.1.12
Browse files Browse the repository at this point in the history
fix: GADDI with undefined label
  • Loading branch information
Yanyan-Wang authored Oct 29, 2021
2 parents 95569a0 + 08e88f6 commit 165f67c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/graph/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/algorithm",
"version": "0.1.11",
"version": "0.1.13",
"description": "graph algorithm",
"keywords": [
"graph",
Expand Down
7 changes: 3 additions & 4 deletions packages/graph/src/gSpan/gSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ class DFScode {
const toNodeId = dfsEdge.toNode;
const { nodeLabel1, edgeLabel, nodeLabel2 } = dfsEdge.nodeEdgeNodeLabel;

if (nodeLabel1 !== VACANT_NODE_LABEL)
graph.addNode(fromNodeId, nodeLabel1);
if (nodeLabel1 !== VACANT_NODE_LABEL) graph.addNode(fromNodeId, nodeLabel1);
if (nodeLabel2 !== VACANT_NODE_LABEL) graph.addNode(toNodeId, nodeLabel2);

graph.addEdge(undefined, fromNodeId, toNodeId, edgeLabel);
if (nodeLabel1 !== VACANT_NODE_LABEL && nodeLabel2 !== nodeLabel1) graph.addEdge(undefined, fromNodeId, toNodeId, edgeLabel);
});
return graph;
}
Expand Down Expand Up @@ -429,6 +427,7 @@ class GSpan {

// 比较 root 中每一项的 nodeEdgeNodeLabel 大小,按照 nodeLabel1、edgeLabe、nodeLabel2 的顺序比较
let minLabel = this.findMinLabel(root); // line 419
if (!minLabel) return;
dfsCodeMin.dfsEdgeList.push(
new DFSedge(
0,
Expand Down
3 changes: 1 addition & 2 deletions packages/graph/src/gaddi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ const getMatchedCount = (graph, structure, nodeLabelProp, edgeLabelProp) => {
nodeMap[node.id] = node;
});
let count = 0;
if (!structure?.edges?.length || structure?.nodes?.length < 2) return 0;
graph.edges.forEach(e => {
const sourceLabel = nodeMap[e.source][nodeLabelProp];
const targetLabel = nodeMap[e.target][nodeLabelProp];
Expand Down Expand Up @@ -540,7 +541,6 @@ const GADDI = (
// );
// 1.2. 生成上面节点对的相应相交邻居诱导子图。格式为 {'beginNodeIdx-endNodeIdx': {nodes: [], edges: []}}
let intGMap = getIntersectNeighborInducedGraph(nodePairsMap, kNeighborUnits, graphData);

// 1.3. 使用 gSpan 算法(frequent graph mining)计算 ISIntG 的前 10 个频率最高的子结构(3-4条边)
const top = 10,
minSupport = 1,
Expand Down Expand Up @@ -797,7 +797,6 @@ const GADDI = (
}
}


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

0 comments on commit 165f67c

Please sign in to comment.