Skip to content

Commit 7d3ae60

Browse files
publish recent improvements
1 parent 526355c commit 7d3ae60

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/graph.js

+6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ export class Graph {
1616
return this.nodes.length-1;
1717
}
1818

19+
addUniqNode(type, props={}) {
20+
const nid = this.nodes.findIndex(node => node.type == type && node.props?.name == props?.name)
21+
return nid >= 0 ? nid : this.addNode(type, props)
22+
}
23+
1924
addRel(type, from, to, props={}) {
25+
if (from == null || to == null) return null
2026
const obj = {type, from, to, props};
2127
this.rels.push(obj);
2228
const rid = this.rels.length-1;

0 commit comments

Comments
 (0)