remove link.distance/strength, tweak parameters

This commit is contained in:
Nils Schneider 2012-06-07 22:58:45 +02:00
parent 523384d64c
commit 80c2cd394b
4 changed files with 22 additions and 12 deletions

View file

@ -15,9 +15,8 @@ class D3MapBuilder:
'flags': x.flags 'flags': x.flags
} for x in nodes if x.flags['online']] } for x in nodes if x.flags['online']]
output['links'] = [{'source': x.pair[0], 'target': x.pair[1], output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
'distance': x.distance,
'strength': x.strength,
'quality': x.quality, 'quality': x.quality,
'type': x.type,
'id': "-".join(nodes[i].id for i in x.pair) 'id': "-".join(nodes[i].id for i in x.pair)
} for x in self._db.get_links()] } for x in self._db.get_links()]

View file

@ -160,8 +160,20 @@ var force = d3.layout.force()
.friction(0.75) .friction(0.75)
.theta(0.1) .theta(0.1)
.size([w, h]) .size([w, h])
.linkDistance(function (d) { return d.distance; }) .linkDistance(function (d) {
.linkStrength(function (d) { return d.strength; }) switch (d.type) {
case "vpn": return 150
case "client": return 20
default: return 70
}
})
.linkStrength(function (d) {
switch (d.type) {
case "vpn": return 0.15
case "client": return 1
default: return 0.5
}
})
force.on("tick", function() { force.on("tick", function() {
var size = force.size() var size = force.size()

View file

@ -1,7 +1,6 @@
class Link(): class Link():
def __init__(self): def __init__(self):
self.pair = None self.pair = None
self.distance = None
self.strength = None
self.quality = None self.quality = None
self.type = None

View file

@ -157,16 +157,16 @@ class NodeDB:
node.flags['vpn'] = True node.flags['vpn'] = True
def map_link(self, pair): def map_link(self, pair):
distance = 80 type = None
strength = 0.2 if any(filter(lambda x: self._nodes[x].flags['vpn'], pair[0])):
type = "vpn"
if any(filter(lambda x: self._nodes[x].flags['client'], pair[0])): if any(filter(lambda x: self._nodes[x].flags['client'], pair[0])):
distance = 10 type = "client"
strength = 1
link = Link() link = Link()
link.pair = pair[0] link.pair = pair[0]
link.distance = distance link.type = type
link.strength = strength
link.quality = pair[1] link.quality = pair[1]
return link return link