Last active
May 15, 2020 03:12
-
-
Save hammadmazhar1/b43a410f9da659eadc85bac6ac4405da to your computer and use it in GitHub Desktop.
Higher Minimum Threshold 0.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"directed": false, "multigraph": false, "graph": {}, "nodes": [{"ips": "[('pindorama.amazon.com', 443)]", "labels": "Counter({'amazon echo': 20})", "label": "amazon echo", "host": "('pindorama.amazon.com', 443)", "id": 0}, {"ips": "[('35.225.145.245', 443)]", "labels": "Counter({'nest cam': 20})", "label": "nest cam", "host": "('35.225.145.245', 443)", "id": 1}, {"ips": "[('54.210.22.58', 443)]", "labels": "Counter({'nest cam': 20})", "label": "nest cam", "host": "('54.210.22.58', 443)", "id": 2}, {"ips": "[('23.23.78.10', 40317)]", "labels": "Counter({'amazon echo': 10})", "label": "amazon echo", "host": "('23.23.78.10', 40317)", "id": 3}, {"ips": "[('52.91.1.141', 443)]", "labels": "Counter({'nest cam': 20})", "label": "nest cam", "host": "('52.91.1.141', 443)", "id": 4}, {"ips": "[('174.129.150.185', 443)]", "labels": "Counter({'nest cam': 20})", "label": "nest cam", "host": "('174.129.150.185', 443)", "id": 5}, {"ips": "[('23.23.78.19', 49317)]", "labels": "Counter({'amazon echo': 10})", "label": "amazon echo", "host": "('23.23.78.19', 49317)", "id": 6}, {"ips": "[('52.88.245.81', 443)]", "labels": "Counter({'plume design inc plume': 120})", "label": "plume design inc plume", "host": "('52.88.245.81', 443)", "id": 7}, {"ips": "[('104.155.18.91', 443)]", "labels": "Counter({'phillips hue': 20})", "label": "phillips hue", "host": "('104.155.18.91', 443)", "id": 8}, {"ips": "[('52.23.249.19', 443)]", "labels": "Counter({'nest cam': 20})", "label": "nest cam", "host": "('52.23.249.19', 443)", "id": 9}, {"ips": "[('time.plumenet.io', 80)]", "labels": "Counter({'plume design inc plume': 2})", "label": "plume design inc plume", "host": "('time.plumenet.io', 80)", "id": 10}, {"ips": "[('pool.ntp.org', 123)]", "labels": "Counter({'amazon echo': 2})", "label": "amazon echo", "host": "('pool.ntp.org', 123)", "id": 11}, {"ips": "[('log-rts36-iad01.devices.nest.com', 443)]", "labels": "Counter({'nest learning': 2})", "label": "nest learning", "host": "('log-rts36-iad01.devices.nest.com', 443)", "id": 12}, {"ips": "[('time-ios.apple.com', 123)]", "labels": "Counter({'apple apple tv': 6})", "label": "apple apple tv", "host": "('time-ios.apple.com', 123)", "id": 13}, {"ips": "[('czfe63-front01-iad01.transport.home.nest.com', 9543)]", "labels": "Counter({'nest learning': 4})", "label": "nest learning", "host": "('czfe63-front01-iad01.transport.home.nest.com', 9543)", "id": 14}, {"ips": "[('czfe85-front01-iad01.transport.home.nest.com', 9543)]", "labels": "Counter({'nest learning': 4})", "label": "nest learning", "host": "('czfe85-front01-iad01.transport.home.nest.com', 9543)", "id": 15}, {"ips": "[('54.149.55.150', 8883)]", "labels": "Counter({'plume design inc plume': 24})", "label": "plume design inc plume", "host": "('54.149.55.150', 8883)", "id": 16}, {"ips": "[('52.33.173.244', 8883)]", "labels": "Counter({'plume design inc plume': 24})", "label": "plume design inc plume", "host": "('52.33.173.244', 8883)", "id": 17}, {"ips": "[('34.216.204.101', 8883)]", "labels": "Counter({'plume design inc plume': 24})", "label": "plume design inc plume", "host": "('34.216.204.101', 8883)", "id": 18}, {"ips": "[('49-courier.push.apple.com', 5223)]", "labels": "Counter({'apple apple tv': 2})", "label": "apple apple tv", "host": "('49-courier.push.apple.com', 5223)", "id": 19}, {"ips": "[('54.237.209.209', 443)]", "labels": "Counter({'sonos play': 4})", "label": "sonos play", "host": "('54.237.209.209', 443)", "id": 20}, {"ips": "[('34.203.247.167', 443)]", "labels": "Counter({'sonos play': 8})", "label": "sonos play", "host": "('34.203.247.167', 443)", "id": 21}, {"ips": "[('99.224.6.96', 123)]", "labels": "Counter({'amazon echo': 2})", "label": "amazon echo", "host": "('99.224.6.96', 123)", "id": 22}, {"ips": "[('1-courier.push.apple.com', 5223)]", "labels": "Counter({'apple apple tv': 6})", "label": "apple apple tv", "host": "('1-courier.push.apple.com', 5223)", "id": 23}, {"ips": "[('sonos.pandora.com', 443)]", "labels": "Counter({'sonos play': 4})", "label": "sonos play", "host": "('sonos.pandora.com', 443)", "id": 24}, {"ips": "[('czfe26-front01-iad01.transport.home.nest.com', 9543)]", "labels": "Counter({'nest learning': 4})", "label": "nest learning", "host": "('czfe26-front01-iad01.transport.home.nest.com', 9543)", "id": 25}, {"ips": "[('audio-ch1-t1-2-v4v6.pandora.com', 443)]", "labels": "Counter({'sonos play': 10})", "label": "sonos play", "host": "('audio-ch1-t1-2-v4v6.pandora.com', 443)", "id": 26}, {"ips": "[('2.android.pool.ntp.org', 123)]", "labels": "Counter({'amazon echo': 2})", "label": "amazon echo", "host": "('2.android.pool.ntp.org', 123)", "id": 27}, {"ips": "[('mt-ingestion-service-mr22.itunes-apple.com.akadns.net', 443)]", "labels": "Counter({'apple apple tv': 2})", "label": "apple apple tv", "host": "('mt-ingestion-service-mr22.itunes-apple.com.akadns.net', 443)", "id": 28}, {"ips": "[('208.81.1.244', 123)]", "labels": "Counter({'amazon echo': 2})", "label": "amazon echo", "host": "('208.81.1.244', 123)", "id": 29}, {"ips": "[('34.224.25.56', 443)]", "labels": "Counter({'sonos play': 6})", "label": "sonos play", "host": "('34.224.25.56', 443)", "id": 30}, {"ips": "[('54.89.36.250', 443)]", "labels": "Counter({'sonos play': 6})", "label": "sonos play", "host": "('54.89.36.250', 443)", "id": 31}, {"ips": "[('xp.itunes-apple.com.akadns.net', 443)]", "labels": "Counter({'apple apple tv': 4})", "label": "apple apple tv", "host": "('xp.itunes-apple.com.akadns.net', 443)", "id": 32}, {"ips": "[('224.0.0.251', 5353)]", "labels": "Counter({'apple apple tv': 4, 'phillips hue': 1})", "label": "Shared", "host": "('224.0.0.251', 5353)", "id": 33}, {"ips": "[('SSDP', 1900)]", "labels": "Counter({'phillips hue': 5, 'sonos play': 5})", "label": "Shared", "host": "('SSDP', 1900)", "id": 34}, {"ips": "[('avs-alexa-na.amazon.com', 443)]", "labels": "Counter({'sonos play': 10})", "label": "sonos play", "host": "('avs-alexa-na.amazon.com', 443)", "id": 35}, {"ips": "[('e673.e9.akamaiedge.net', 443)]", "labels": "Counter({'apple apple tv': 6})", "label": "apple apple tv", "host": "('e673.e9.akamaiedge.net', 443)", "id": 36}, {"ips": "[('54.174.157.87', 443)]", "labels": "Counter({'sonos play': 6})", "label": "sonos play", "host": "('54.174.157.87', 443)", "id": 37}, {"ips": "[('34.196.76.9', 443)]", "labels": "Counter({'amazon echo': 6})", "label": "amazon echo", "host": "('34.196.76.9', 443)", "id": 38}, {"ips": "[('audio-sv5-t3-1-v4v6.pandora.com', 443)]", "labels": "Counter({'sonos play': 11})", "label": "sonos play", "host": "('audio-sv5-t3-1-v4v6.pandora.com', 443)", "id": 39}], "links": [{"value": 10, "source": 0, "target": 1}, {"value": 10, "source": 0, "target": 2}, {"value": 10, "source": 0, "target": 3}, {"value": 10, "source": 0, "target": 4}, {"value": 10, "source": 0, "target": 5}, {"value": 10, "source": 0, "target": 6}, {"value": 10, "source": 0, "target": 7}, {"value": 10, "source": 0, "target": 8}, {"value": 10, "source": 0, "target": 9}, {"value": 6.0, "source": 0, "target": 16}, {"value": 6.0, "source": 0, "target": 17}, {"value": 6.0, "source": 0, "target": 18}, {"value": 5.0, "source": 0, "target": 26}, {"value": 6.0, "source": 0, "target": 34}, {"value": 5.0, "source": 0, "target": 35}, {"value": 6.0, "source": 0, "target": 39}, {"value": 10, "source": 1, "target": 2}, {"value": 10, "source": 1, "target": 3}, {"value": 10, "source": 1, "target": 4}, {"value": 10, "source": 1, "target": 5}, {"value": 10, "source": 1, "target": 6}, {"value": 10, "source": 1, "target": 7}, {"value": 10, "source": 1, "target": 8}, {"value": 10, "source": 1, "target": 9}, {"value": 6.0, "source": 1, "target": 16}, {"value": 6.0, "source": 1, "target": 17}, {"value": 6.0, "source": 1, "target": 18}, {"value": 5.0, "source": 1, "target": 26}, {"value": 6.0, "source": 1, "target": 34}, {"value": 5.0, "source": 1, "target": 35}, {"value": 6.0, "source": 1, "target": 39}, {"value": 10, "source": 2, "target": 3}, {"value": 10, "source": 2, "target": 4}, {"value": 10, "source": 2, "target": 5}, {"value": 10, "source": 2, "target": 6}, {"value": 10, "source": 2, "target": 7}, {"value": 10, "source": 2, "target": 8}, {"value": 10, "source": 2, "target": 9}, {"value": 6.0, "source": 2, "target": 16}, {"value": 6.0, "source": 2, "target": 17}, {"value": 6.0, "source": 2, "target": 18}, {"value": 5.0, "source": 2, "target": 26}, {"value": 6.0, "source": 2, "target": 34}, {"value": 5.0, "source": 2, "target": 35}, {"value": 6.0, "source": 2, "target": 39}, {"value": 10, "source": 3, "target": 4}, {"value": 10, "source": 3, "target": 5}, {"value": 10, "source": 3, "target": 6}, {"value": 10, "source": 3, "target": 7}, {"value": 10, "source": 3, "target": 8}, {"value": 10, "source": 3, "target": 9}, {"value": 6.0, "source": 3, "target": 16}, {"value": 6.0, "source": 3, "target": 17}, {"value": 6.0, "source": 3, "target": 18}, {"value": 5.0, "source": 3, "target": 26}, {"value": 6.0, "source": 3, "target": 34}, {"value": 5.0, "source": 3, "target": 35}, {"value": 6.0, "source": 3, "target": 39}, {"value": 10, "source": 4, "target": 5}, {"value": 10, "source": 4, "target": 6}, {"value": 10, "source": 4, "target": 7}, {"value": 10, "source": 4, "target": 8}, {"value": 10, "source": 4, "target": 9}, {"value": 6.0, "source": 4, "target": 16}, {"value": 6.0, "source": 4, "target": 17}, {"value": 6.0, "source": 4, "target": 18}, {"value": 5.0, "source": 4, "target": 26}, {"value": 6.0, "source": 4, "target": 34}, {"value": 5.0, "source": 4, "target": 35}, {"value": 6.0, "source": 4, "target": 39}, {"value": 10, "source": 5, "target": 6}, {"value": 10, "source": 5, "target": 7}, {"value": 10, "source": 5, "target": 8}, {"value": 10, "source": 5, "target": 9}, {"value": 6.0, "source": 5, "target": 16}, {"value": 6.0, "source": 5, "target": 17}, {"value": 6.0, "source": 5, "target": 18}, {"value": 5.0, "source": 5, "target": 26}, {"value": 6.0, "source": 5, "target": 34}, {"value": 5.0, "source": 5, "target": 35}, {"value": 6.0, "source": 5, "target": 39}, {"value": 10, "source": 6, "target": 7}, {"value": 10, "source": 6, "target": 8}, {"value": 10, "source": 6, "target": 9}, {"value": 6.0, "source": 6, "target": 16}, {"value": 6.0, "source": 6, "target": 17}, {"value": 6.0, "source": 6, "target": 18}, {"value": 5.0, "source": 6, "target": 26}, {"value": 6.0, "source": 6, "target": 34}, {"value": 5.0, "source": 6, "target": 35}, {"value": 6.0, "source": 6, "target": 39}, {"value": 10, "source": 7, "target": 8}, {"value": 10, "source": 7, "target": 9}, {"value": 6.0, "source": 7, "target": 16}, {"value": 6.0, "source": 7, "target": 17}, {"value": 6.0, "source": 7, "target": 18}, {"value": 5.0, "source": 7, "target": 26}, {"value": 6.0, "source": 7, "target": 34}, {"value": 5.0, "source": 7, "target": 35}, {"value": 6.0, "source": 7, "target": 39}, {"value": 10, "source": 8, "target": 9}, {"value": 6.0, "source": 8, "target": 16}, {"value": 6.0, "source": 8, "target": 17}, {"value": 6.0, "source": 8, "target": 18}, {"value": 5.0, "source": 8, "target": 26}, {"value": 6.0, "source": 8, "target": 34}, {"value": 5.0, "source": 8, "target": 35}, {"value": 6.0, "source": 8, "target": 39}, {"value": 6.0, "source": 9, "target": 16}, {"value": 6.0, "source": 9, "target": 17}, {"value": 6.0, "source": 9, "target": 18}, {"value": 5.0, "source": 9, "target": 26}, {"value": 6.0, "source": 9, "target": 34}, {"value": 5.0, "source": 9, "target": 35}, {"value": 6.0, "source": 9, "target": 39}, {"value": 10, "source": 10, "target": 11}, {"value": 10, "source": 10, "target": 12}, {"value": 10, "source": 10, "target": 13}, {"value": 10, "source": 11, "target": 12}, {"value": 10, "source": 11, "target": 13}, {"value": 10, "source": 12, "target": 13}, {"value": 6.666666666666666, "source": 14, "target": 15}, {"value": 5.0, "source": 14, "target": 34}, {"value": 10, "source": 16, "target": 17}, {"value": 10, "source": 16, "target": 18}, {"value": 5.0, "source": 16, "target": 23}, {"value": 5.0, "source": 16, "target": 30}, {"value": 5.0, "source": 16, "target": 31}, {"value": 5.0, "source": 16, "target": 34}, {"value": 5.0, "source": 16, "target": 39}, {"value": 10, "source": 17, "target": 18}, {"value": 5.0, "source": 17, "target": 23}, {"value": 5.0, "source": 17, "target": 30}, {"value": 5.0, "source": 17, "target": 31}, {"value": 5.0, "source": 17, "target": 34}, {"value": 5.0, "source": 17, "target": 39}, {"value": 5.0, "source": 18, "target": 23}, {"value": 5.0, "source": 18, "target": 30}, {"value": 5.0, "source": 18, "target": 31}, {"value": 5.0, "source": 18, "target": 34}, {"value": 5.0, "source": 18, "target": 39}, {"value": 5.0, "source": 19, "target": 20}, {"value": 5.0, "source": 20, "target": 27}, {"value": 7.5, "source": 21, "target": 30}, {"value": 7.5, "source": 21, "target": 31}, {"value": 5.0, "source": 24, "target": 27}, {"value": 5.0, "source": 25, "target": 32}, {"value": 6.666666666666666, "source": 25, "target": 37}, {"value": 10, "source": 28, "target": 29}, {"value": 10, "source": 30, "target": 31}, {"value": 5.0, "source": 30, "target": 36}, {"value": 5.0, "source": 31, "target": 36}, {"value": 5.0, "source": 34, "target": 39}, {"value": 6.0, "source": 35, "target": 37}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.links line { | |
stroke: #999; | |
stroke-opacity: 0.6; | |
} | |
.nodes circle { | |
stroke: #fff; | |
stroke-width: 1.5px; | |
} | |
text { | |
font-family: sans-serif; | |
font-size: 10px; | |
} | |
</style> | |
<svg width="1280" height="900"></svg> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script> | |
<script> | |
var svg = d3.select("svg"), | |
width = +svg.attr("width"), | |
height = +svg.attr("height"); | |
var devices = new Set(); | |
var yCenter = {}; | |
var xCenter = {}; | |
var simulation = d3.forceSimulation() | |
.force('x', d3.forceX().x(function(d){return xCenter[d.label]; })) | |
.force('y',d3.forceY().y(function(d){return yCenter[d.label]; })) | |
.force("link", d3.forceLink().id(function(d) { return d.id; })) | |
.force("charge", d3.forceManyBody()) | |
.force("center", d3.forceCenter(width / 2, height / 2)); | |
d3.json("./300_size_batch_0_win_30_min_0.5.json", function(error, graph) { | |
if (error) throw error; | |
graph.nodes.forEach(function(d){ | |
devices.add(d.label); | |
}); | |
devices = Array.from(devices).sort() | |
var distance = devices.length * 50 | |
console.log(distance) | |
var color = d3.scaleOrdinal() | |
.domain(devices) | |
.range(d3.schemeCategory10); | |
var rad_per_idx = ((2*Math.PI)/devices.length) | |
console.log(rad_per_idx) | |
devices.forEach(function(d,index){ | |
// console.log(d) | |
// console.log(index) | |
if (d == 'Shared'){ | |
yCenter[d] = width/2 | |
} else{ | |
yCenter[d] = width/2 + distance* Math.sin(rad_per_idx * index); | |
} | |
}); | |
devices.forEach(function(d,index){ | |
if (d == 'Shared'){ | |
xCenter[d] = height/2 | |
} else{ | |
xCenter[d] = height/2+ distance* Math.cos(rad_per_idx * index); | |
} | |
}); | |
console.log(xCenter) | |
console.log(yCenter) | |
var link = svg.append("g") | |
.attr("class", "links") | |
.selectAll("line") | |
.data(graph.links) | |
.enter().append("line") | |
.attr("stroke-width", function(d) { return (d.value/10) }); | |
var node = svg.append("g") | |
.attr("class", "nodes") | |
.selectAll("g") | |
.data(graph.nodes) | |
.enter().append("g") | |
var circles = node.append("circle") | |
.attr("r", 5) | |
.attr("fill", function(d) { return color(d.label); }) | |
.call(d3.drag() | |
.on("start", dragstarted) | |
.on("drag", dragged) | |
.on("end", dragended)); | |
var lables = node.append("text") | |
.text(function(d) { | |
return d.host; | |
}) | |
.attr('x', 6) | |
.attr('y', 3); | |
node.append("title") | |
.text(function(d) { return d.id; }); | |
// Add one dot in the legend for each name. | |
svg.selectAll("mydots") | |
.data(Array.from(devices)) | |
.enter() | |
.append("circle") | |
.attr("cx", 100) | |
.attr("cy", function(d,i){ return 100 + i*25}) // 100 is where the first dot appears. 25 is the distance between dots | |
.attr("r", 7) | |
.style("fill", function(d){ return color(d)}) | |
// Add one dot in the legend for each name. | |
svg.selectAll("mylabels") | |
.data(Array.from(devices)) | |
.enter() | |
.append("text") | |
.attr("x", 120) | |
.attr("y", function(d,i){ return 100 + i*25}) // 100 is where the first dot appears. 25 is the distance between dots | |
.style("fill", function(d){ return color(d)}) | |
.text(function(d){ return d}) | |
.attr("text-anchor", "left") | |
.style("alignment-baseline", "middle") | |
simulation | |
.nodes(graph.nodes) | |
.on("tick", ticked); | |
simulation.force("link") | |
.links(graph.links) | |
.strength(function(d){ | |
return 1/d.value | |
}) | |
.distance(function(d){ | |
return 100 | |
}); | |
function ticked() { | |
link | |
.attr("x1", function(d) { return d.source.x; }) | |
.attr("y1", function(d) { return d.source.y; }) | |
.attr("x2", function(d) { return d.target.x; }) | |
.attr("y2", function(d) { return d.target.y; }); | |
node | |
.attr("transform", function(d) { | |
return "translate(" + d.x + "," + d.y + ")"; | |
}) | |
} | |
}); | |
function dragstarted(d) { | |
if (!d3.event.active) simulation.alphaTarget(0.3).restart(); | |
d.fx = d.x; | |
d.fy = d.y; | |
} | |
function dragged(d) { | |
d.fx = d3.event.x; | |
d.fy = d3.event.y; | |
} | |
function dragended(d) { | |
if (!d3.event.active) simulation.alphaTarget(0); | |
d.fx = null; | |
d.fy = null; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment