Skip to main content

Applying Filtering

Our first node-link diagram looked quite cluttered.

There were many nodes with only one or two connections, but we're more interested in the nodes with more conenctions, so let's apply some filtering.


{
"data": [
{
"name": "data",
"url": "/data/blogs/network.csv",
"format": {"type": "csv"}
}
],

"networks": [
{
"name": "network",
"links": "data",
"directed": true,
"source_node": [ "id", "source" ],
"target_node": [ "id", "target" ],

We apply two transforms, to calculate the degree of every node, and then remove any node with a degree of 2 or less.


"transform": [
{"type": "metric", "metric": "degree"}
{"type": "filterNodes", "expression": "datum.degree > 2 "}
]
}


],

"layouts": [
{
"name": "layout",
"network": "network",
"type": "d3-force"
}
],

"vis": [
{
"entries": "network.links",
"layout": "layout",
"mark": {
"type": "linkpath",
"start": "source",
"end": "target"
}
},
{
"entries": "network.nodes",
"layout": "layout",
"mark": {
"type": "circle",
"area": 70,
"fill": "steelblue"
}
}
]
}