Groupings
In the types of visualizations that NetPanorama was intended to help create, it is common to aggregate data based on common elements.
For example, we may have a list of links, and want to aggregate this into a list of lists, each containing links with the same source node and same target node.
In Vega, this sort of grouping would be achieved by using a transform
of type
aggregation
, with an aggregation operation
of values
.
We chose to deviate from this behaviour: this means that the aggregation
transforms consistently aggregate multiple values into a single number, and for our intended uses groupings
are sufficiently important to be reified as top-levle objects.
Example
Suppose that the value of edges
is:
[
{source: 1, target: 2, id: 1},
{source: 1, target: 2, id: 2},
{source: 1, target: 3, id: 3},
{source: 1, target: 4, id: 4},
{source: 1, target: 5, id: 5},
{source: 2, target: 2, id: 6},
{source: 2, target: 2, id: 7},
{source: 3, target: 3, id: 8},
{source: 3, target: 4, id: 9},
{source: 4, target: 5, id: 10},
]
We can group by a single attribute - the grouping
{
"groupings": {
"name": "grouped_links",
"data": "links",
"common": ["source"]
}
}
would give
[
[
{"source": 1, "target": 2, "id": 1},
{"source": 1, "target": 2, "id": 2},
{"source": 1, "target": 3, "id": 3 },
{"source": 1, "target": 4, "id": 4},
{"source": 1, "target": 5, "id": 5}
],
[
{"source": 2, "target": 2, "id": 6},
{"source": 2, "target": 2, "id": 7}
],
[
{"source": 3, "target": 3, "id": 8},
{"source": 3, "target": 4, "id": 9}
],
[{"source": 4, "target": 5, "id": 10}]
]
Alternatively, we could group by two attributes - the grouping
{
"groupings": {
"name": "grouped_links",
"data": "links",
"common": ["source", "target"]
}
}
would give
[
[{ "source": 1, "target": 2, "id": 1 }, { "source": 1, "target": 2, "id": 2 }],
[{ "source": 1, "target": 3, "id": 3 }],
[{ "source": 1, "target": 4, "id": 4 }],
[{ "source": 1, "target": 5, "id": 5 }],
[{ "source": 2, "target": 2, "id": 6 }, { "source": 2, "target": 2, "id": 7 }],
[{ "source": 3, "target": 3, "id": 8 }],
[{ "source": 3, "target": 4, "id": 9 }],
[{ "source": 4, "target": 5, "id": 10 }]
]
Additional attributes
Each computed group get the following properties:
key
: the common value of the groupdata
: the data elements that have the common valuerepresents
:nodes
|links
. Type of network element that each group representsrepresentsId
:nodes
|links
. Id of the nodes of links represented by each group. This is useful to specify interactions.
Grouping networks
It is also possible to construct a grouping from a network rather than a table, by setting the network
attribute of the specification.
In this case, each entry in the resulting group array will include nodes
and links
arrays.
Links whose source and target nodes are in different groups are saved separately in the <GROUP_NAME>_INTER_GROUP_LINKS
attribute of the state.