diff --git a/d3mapbuilder.py b/d3mapbuilder.py index 9148961..34e238b 100644 --- a/d3mapbuilder.py +++ b/d3mapbuilder.py @@ -12,7 +12,8 @@ class D3MapBuilder: } for x in self._db.get_nodes() if x.online] output['links'] = [{'source': x.pair[0], 'target': x.pair[1], 'distance': x.distance, - 'strength': x.strength + 'strength': x.strength, + 'quality': x.quality } for x in self._db.get_links()] return json.dumps(output) diff --git a/html/force.js b/html/force.js index a8402b0..d5ea14c 100644 --- a/html/force.js +++ b/html/force.js @@ -122,18 +122,21 @@ function render_graph(type) { d.source.group != 3 && d.target.group != 3; }); - var linkdata = vis.selectAll("line.link") - .data(linkdata) - var link = linkdata.enter().append("line") + var link = vis.selectAll("line.link") + .data(linkdata) + .enter().append("line") .attr("class", "link") .style("stroke-width", function(d) { return Math.min(1, d.strength * 2); }); - var linklabel = linkdata.enter().append("text") + var linklabel = vis.selectAll("text") + .data(linkdata.filter(function (d) {return d.quality != "TT"})) + .enter() + .append("text") .attr("text-anchor", "middle") .attr("color", "#000") .attr("class", "strength") - .text(function (d) { return d.strength; }); + .text(function (d) { return d.quality; });     function isConnected(a, b) {         return linkedByIndex[a.index + "," + b.index] || linkedByIndex[b.index + "," + a.index] || a.index == b.index; diff --git a/link.py b/link.py index c69b141..301d813 100644 --- a/link.py +++ b/link.py @@ -3,4 +3,5 @@ class Link(): self.pair = None self.distance = None self.strength = None + self.quality = None diff --git a/nodedb.py b/nodedb.py index ea253e5..0d328c8 100644 --- a/nodedb.py +++ b/nodedb.py @@ -96,7 +96,7 @@ class NodeDB: a = self._nodes.index(router) b = self._nodes.index(neighbor) - self._links.add(tuple(sorted((a,b)))) + self._links.add(tuple((tuple(sorted((a,b))), x['label']))) for line in lines: x = json.loads(line) @@ -135,14 +135,15 @@ class NodeDB: def map_link(self, pair): distance = 80 strength = 0.2 - if any(filter(lambda x: self._nodes[x].group == 3, pair)): + if any(filter(lambda x: self._nodes[x].group == 3, pair[0])): distance = 10 strength = 1 link = Link() - link.pair = pair + link.pair = pair[0] link.distance = distance link.strength = strength + link.quality = pair[1] return link def import_wikigps(self, url): @@ -213,7 +214,7 @@ class NodeDB: def find_link(self, i): for link in self._links: - if i in link: + if i in link[0]: return link def wilder_scheiss(self):