Skip to content

Extract node degree


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


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 calculate a weighted degree, which sums up the number of all retweets (if we chose "weighted": false, we'd simply count the number of accounts that have retweeted each node, not the total number of retweets). Finally, in case some accounts have retweeted themselves, we chose to ignore loops.

extract_node_degree(links, {
  "mode": "in",
  "loops": false,
  "weighted": true,
  "directed": true
}) -> (ds.keywords)


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

extract_node_degree(links: dataset, {"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.


links: dataset

A dataset of links between nodes, i.e. containing source, target and weight columns.


degree: column:number

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


  • If the graph has a weight edge attribute, then this is used by default. Weights are used to calculate weighted shortest paths, so they are interpreted as distances.
  • 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

weights: string | null

Optional Column name containing positive weights for calculating weighted betweenness.