Skip to content

Extract node degree

network

Calculate network node degrees (in, out or all).

Usage


The following are the step's expected inputs and outputs and their specific types.

Step signature
extract_node_degree(
    targets: list[number],
    *weights: list[number], 
    {
        "param": value
    }
) -> (degree: number)

where the object {"param": value} is optional in most cases and if present may contain any of the parameters described in the corresponding section below.

Example

E.g. in a network of twitter accounts, where a directed link between nodes A and B indicates the number of times A has retweeted B, the following calculates the total number of retweets each account has received: Since in the example network links A→B and B→A can be different, we indicate that we want to interpret the network as directed. And since each link's weight is the number of retweets, we pass the retweets weight as the weights column. Keep in mind that both columns contain lists of numbers for each row.

Example call (in recipe editor)
extract_node_degree(ds.targets, ds.retweets, {
  "mode": "in",
  "loops": false,
  "directed": true
}) -> (ds.keywords)

Inputs


targets: column:list[number]

A column containing link targets. Source is implied in the index.


*weights: column:list[number]

Outputs


degree: column:number

Column containing the number of incoming, outgoing or all connections for each row/node in the dataset.

Parameters


* Mode defines the types of the paths used for measuring the distance in directed graphs. “in” measures the paths to a vertex, “out” measures paths from a vertex, all uses undirected paths. This argument is ignored for undirected graphs.

mode: string = "all"

Which node connections to count.

Must be one of: "all", "out", "in", "both"

Example parameter values:

  • "all"
  • "out"
  • "in"
  • "both"

directed: boolean = False

Whether the links are directed or not.

Example parameter values:

  • false

loops: boolean

Whether the loop edges are also counted.

Example parameter values:

  • true
  • false
Back to top