Published
Edited
Jun 22, 2021
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
function autoBox() {
document.body.appendChild(this);
const {x, y, width, height} = this.getBBox();
document.body.removeChild(this);
return [x, y, width, height];
}
Insert cell
announcements = fetch(
`https://stat.ripe.net/data/bgplay/data.json?resource=${asn}&starttime=2021-06-11T00:00:00&endtime=2021-06-21T00:00:00`
)
.then(r => r.json())
.then(r => r.data)
.then(r => r.initial_state)
Insert cell
G = {
let parents = [];

for (let announcement of announcements) {
let path = announcement.path;
let relations = [];

// console.log('path', path);

path.reduce((acc, curr) => {
// repeated child?
// console.log(
// acc,
// curr,
// parents.map(r => r.child),
// parents.map(r => r.child).includes(acc)
// );
if (parents.filter(r => r.child === acc && r.parent === curr).length)
console.log(acc);

// no duplicates... for now
if (parents.filter(r => r.child === acc && r.parent === curr).length)
return curr;
else if (curr === acc) return curr;
// multi-parents nodes
else if (parents.filter(r => r.child === acc).length)
relations.push({ child: `${acc}->${curr}`, parent: curr });
else relations.push({ child: acc, parent: curr });
return curr;
});

parents = [...parents, ...relations];
}

parents.push({ child: asn });
return parents;
}
Insert cell
strats = d3
.stratify()
.id(node => node.child)
.parentId(node => node.parent)(G)
Insert cell
data = d3.hierarchy(strats)
Insert cell
_data = d3.hierarchy(await FileAttachment("flare-2.json").json())
.sort((a, b) => d3.ascending(a.data.name, b.data.name))
Insert cell
tree = d3.tree()
.size([2 * Math.PI, radius])
.separation((a, b) => (a.parent == b.parent ? 1 : 2) / a.depth)
Insert cell
width = 954
Insert cell
radius = width / 2
Insert cell
d3 = require("d3@6")
Insert cell
ngraph = ({
ngraph: await require("ngraph.graph"),
// pagerank: await require("https://bundle.run/ngraph.pagerank@2.0.0"),
// hits: await require("https://bundle.run/ngraph.hits"),
// cw: await require("https://bundle.run/ngraph.cw@2.0.0"),
louvain: await require("https://bundle.run/ngraph.louvain@2.0.0")
// pixel: await require("https://bundle.run/ngraph.pixel")
// generators: await require("https://bundle.run/ngraph.generators")
})
Insert cell
Viva = require("https://bundle.run/vivagraphjs@0.12.0")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more