Plumb link labels through to layout
This commit is contained in:
10
GraphLink.js
10
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
GraphNode.js
18
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
|
||||
|
||||
11
Layout.js
11
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) {
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user