Skip to main content
caution

Transformations that simply treat data as a table of values, without understanding the network structure of a dataset (i.e., that an edge connects a source and target nodes) are instead defined in the data block.

note

Not all Network Transformations change the network topology.

When constructing a network, you can specify a list of transformations that should be applied to it.

  • aggregating edges (the data is aggregated, but the node and link references are not)
  • filtering edges or nodes (for consistency, this requires filtering out any edges connected to filtered-out nodes)
  • projecting edges
  • aggregating nodes into a supernode

Transformations applied to a network do not modify the data from which the network was created.

Transformations are applied in the order in which they are listed.

Topological changes

Aggregation

Aggregate Edges

Aggregate multiple edges with the same source and target node into a single edge.

AttributeTypeDescription
type"aggregateEdges"
operation?AggregationFuncAggregation function to be applied to the edges that are being merged, to obtain the data for the new aggregate edge.
directed?booleanIf directed is false, two edges between the same pair of nodes will be merged even if they have opposite directions.

An aggregation function can be specified to define how data associated with each edge should be combined.

Aggregate Nodes

Aggregate nodes into a single node.

AttributeTypeDescription
type"aggregateNodes"
fieldstringNodes with the same value for this field will be merged.
fieldsstringNodes with the same value for these fields will be merged.
expressionstringNodes for which evaluating this expression gives the same result will be merged.
as?stringThe merged nodes will contain the name of the field (or result of evaluating expression) as a field with this name.

Note that only one of field, fields and expression can be specified.

Grouping nodes is similar to grouping tabular data, except that the attached edges also have to be adjusted.

Nodes will be merged into a single node if they have the same value for the specified field, or if the expression gives the same value when evaluated for them.

Note that aggregating nodes does not aggregate the attached edges; this can achieved by a separate transform.

Project Edges

Projection replaces a path between two nodes via a third node with a single link directly joining them (i.e., A->B->C become A->C)

AttributeTypeDescription
type"project"
fieldName?stringField that indicates the node type (default: "_type").
remainingNodeTypestring or numberThe value of the node type field for the nodes that will be joined by the newly-created link (i.e., nodes A and C in the example A->B->C).
removedNodeTypestring or numberThe value of the node type filed for the node that will be replace (i.e., node B in the example A->B->C)
directedbooleanIf directed is false, ignore edge directions when considering paths to project (i.e, A->B->C and A<-B->C would become A->C).
linkDataReduceranyHow to aggregate the data from the links that are being merged.

Remove Isolated Nodes

Remove isolate nodes (i.e., nodes with no attached edges)

AttributeTypeDescription
type"removeIsolated"

Filter

Nodes or edges can be filtered by providing an expression.

Note that when filtering nodes, any link connected to a removed node is also removed as dangling links are invalid. When filtering links, isolated nodes are not removed; they can be removed by applying a removeIsolated transform.

Filter nodes

Remove some nodes, retaining only those for which the expression is true. When a node is removed, so are any edges that were attached to it.

AttributeTypeDescription
type"filterNodes"
expressionstringThe expression to evaluate for each node.

Filter edges

Remove some edges, retaining only those for which the expression is true.

AttributeTypeDescription
type"filterEdges"
expressionstringThe expression to evaluate for each edge.

Connect nodes

Add a connection between each pair of nodes for which the value of a specified field (or result of evaluating a specified expression) in the same.

AttributeTypeDescription
type"connect"
as?stringValue to be stored in the "_type" field for edges created by this operation.
fieldstringThe name of the field to be examined.
expressionstringThe expression to be evaluated.
bothDirections?booleanEach pair of nodes will be joined by a single edge (if false), or a pair of edges with opposite directions (if true). Default is true.

Only one of field or expression can be specified.

Reverse Edge Directions

Swap the direction of edges.

AttributeTypeDescription
type"reverseEdges"
condition?stringIf an expression is provided as a condition, then only edges for which it evaluates to true will be reversed.

Set Edge Directedness

Change whether or not edges are directed.

AttributeTypeDescription
type"setDirectness"
value"directed" or "undirected"The value of directedness to apply to all edges.
expressionstringThis expression will be evaluated for all edges; if it evaluates to true, then the edge will be treated as directed.

Swap Nodes And Edges

Swap nodes and links by computing the Line Graph.This consists of a node for each edge in the original graph;these are joined if they share a common edge in the original graph (in the undirected case)or if they correspond to edges that form a directed path of length two in the original graph.

AttributeTypeDescription
type"swapNodesAndEdges"
directed?booleanWhether to treat edges as directed

Promote field or expression to a node

Promote a field to a node type. This creates a node for each distinct value of a field (or evaluating an expression) on existing nodes, and adds an edge from each original node to the corresponding new value node.

AttributeTypeDescription
type"promote"
fieldstringThe name of the field to be promoted.
expressionstringThe expression to be evaluated for each node
prefixstringPrefix to be applied before the value when assigning the ID for the new nodes.
linkPrefix?stringPrefix to be applied to the ID of newly created edges.
direction?"toValue" or "fromValue"Whether the new edges should be directed from the existing nodes to the new value nodes or vice-versa.

Only one of field or expression can be specified.

Deriving new attributes

Calculate new attribute, considering nodes in isolation

Calculate new attribute for each node or link, based on the current attributes of only the same node or link.

AttributeTypeDescription
type"calculate"
for?"nodes" or "links"Whether to do calculation for each node or edge (default is nodes).
calculatestringThe expression to calculate.
asstringThe name of the field in which result should be stored (defaults to the same as the method).

You can specify an expression to be evaluated for each node or link, with the result saved in an attribute.

For example:

{"type": "calculate", "as": "label", "calculate": "datum.name + ' (' + datum.louvain + ')'"},
{"type": "calculate", "as": "label", "calculate": "datum.source.name + ' --- ' + datum.target.name", "for": "links"},

In some cases, expressions like this can be used directly in the specification of visual encodings, but it may be clearer to separately calculate them as separate attributes.

Calculate new attribute, based on node and neighbours

Computes a new data attribute for each node, based on the data associated with its neighbours. For each edge, the attribute selector is applied to an object with a node and edge attributes; the selector can thus access properties of either the neighbouring node or the edge connecting it.

AttributeTypeDescription
type"connectivityBasedAttribute"
attributeSelectorstringWhich data attribute to select for each neighbouring node.
asstringThe name of the field in which the result should be stored.
operation?AggregationFuncThe aggregation operation to be applied.
direction?"in" or "out" or "both"When calculating value for a node, consider edges directed in towards that node, out away from that node, or both.Default is both.

Calculate metrics based on whole network

Compute a metric for each node. These may depend on the structure of the network as a whole.

AttributeTypeDescription
type"metric"
metricMetricNameWhich metric to calculate.
as?stringThe name of the field in which the value of the metric calculated for each node should be stored (defaults to the same as the metric).

Several node metrics can be calculated: "degree" | "in-degree" | "out-degree" | "undirected-betweeness" | "directed-betweeness" | "closeness" | "eccentricity"

Cluster Nodes

Perform clustering/community detection.

AttributeTypeDescription
type"cluster"
method?"louvain"The clustering method to use.
as?stringThe name of the field in which the cluster id of each node should be stored (defaults to the same as the method).

NetPanorama currently supports community detection using the Louvain method, as implemented by ngraph.louvain.