diff --git a/GraphLink.js b/GraphLink.js index de240f1..cfd3a2d 100644 --- a/GraphLink.js +++ b/GraphLink.js @@ -7,8 +7,14 @@ class GraphLink { this.to = nodesByLabel.get(this.toLabel); for (let from of this.from) { for (let to of this.to) { - from.links.push(to); - to.linksIn.push(from); + from.links.push({ + to: to, + label: this.label, + }); + to.linksIn.push({ + from: from, + label: this.label, + }); } } } diff --git a/GraphNode.js b/GraphNode.js index ff65273..924db88 100644 --- a/GraphNode.js +++ b/GraphNode.js @@ -15,8 +15,8 @@ class GraphNode { } ++this.pageRank; visited.add(this); - for (let to of this.links) { - to.incPageRank(visited); + for (let link of this.links) { + link.to.incPageRank(visited); } visited.delete(this); } @@ -28,11 +28,11 @@ class GraphNode { } this.subgraph = subgraph; nodes.delete(this); - for (let to of this.links) { - to.setSubgraph(subgraph, nodes); + for (let link of this.links) { + link.to.setSubgraph(subgraph, nodes); } - for (let from of this.linksIn) { - from.setSubgraph(subgraph, nodes); + for (let link of this.linksIn) { + link.from.setSubgraph(subgraph, nodes); } for (let group of this.groups) { for (let node of group.nodes) { @@ -76,11 +76,11 @@ class GraphNode { } } - for (let to of this.links) { + for (let link of this.links) { // Stronger affinity for links // Prefer to move toward the target instance - this.addAffinity(to, d => d <= 2 ? -INF : d * 11); - to.addAffinity(this, d => d <= 2 ? -INF : d * 9); + this.addAffinity(link.to, d => d <= 2 ? -INF : d * 11); + link.to.addAffinity(this, d => d <= 2 ? -INF : d * 9); } // Affinity for groups diff --git a/Layout.js b/Layout.js index 970b632..f8cfb51 100644 --- a/Layout.js +++ b/Layout.js @@ -212,10 +212,11 @@ class Layout { drawLinks() { let links = []; for (let from of this.nodes_) { - for (let to of from.links) { + for (let link of from.links) { links.push({ from: from, - to: to, + to: link.to, + label: link.label, }); } } @@ -227,9 +228,13 @@ class Layout { for (let link of links) { this.links_.push( - new LayoutLink(link.from, link.to, + new LayoutLink(link.from, link.to, link.label, this.nodesByPos_, this.linksByPos_)); } + + for (let link of this.links_) { + link.drawLabel(); + } } distance(a, b) { diff --git a/LayoutLink.js b/LayoutLink.js index c3669c8..91e0374 100644 --- a/LayoutLink.js +++ b/LayoutLink.js @@ -1,7 +1,8 @@ class LayoutLink { - constructor(from, to, nodesByPos, linksByPos) { + constructor(from, to, label, nodesByPos, linksByPos) { this.from_ = from; this.to_ = to; + this.label_ = label; this.nodesByPos_ = nodesByPos; this.linksByPos_ = linksByPos; this.bfs(); @@ -178,6 +179,9 @@ class LayoutLink { return (this.getOutPoint(from, to) + 4) % 8; } + drawLabel() { + } + getSteps() { let steps = []; diff --git a/LayoutNode.js b/LayoutNode.js index 3021110..009800b 100644 --- a/LayoutNode.js +++ b/LayoutNode.js @@ -10,8 +10,11 @@ class LayoutNode { resolveLinks(nodesByGraphNode) { this.links = []; - for (let to of this.graphNode_.links) { - this.links.push(nodesByGraphNode.get(to)); + for (let link of this.graphNode_.links) { + this.links.push({ + to: nodesByGraphNode.get(link.to), + label: link.label, + }); } }