Skip to content

Commit

Permalink
publish recent improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
WardCunningham committed Sep 5, 2024
1 parent 526355c commit 7d3ae60
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ export class Graph {
return this.nodes.length-1;
}

addUniqNode(type, props={}) {
const nid = this.nodes.findIndex(node => node.type == type && node.props?.name == props?.name)
return nid >= 0 ? nid : this.addNode(type, props)
}

addRel(type, from, to, props={}) {
if (from == null || to == null) return null
const obj = {type, from, to, props};
this.rels.push(obj);
const rid = this.rels.length-1;
Expand Down

0 comments on commit 7d3ae60

Please sign in to comment.