Skip to main content
Calculates the degree centrality of each node in the network, i.e. the number of each node’s incoming and/or outgoing connections.

Usage

The following example shows how the step can be used in a recipe.

Examples

  • Example 1
  • Signature
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.
extract_node_degree(ds.targets, ds.retweets, {
  "mode": "in",
  "loops": false,
  "directed": true
}) -> (ds.keywords)

Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally columns (ds.first_name), datasets (ds or ds[["first_name", "last_name"]]) or models (referenced by name e.g. "churn-clf").
targets
column[list[number]]
required
A column containing link targets. Source is implied in the index.
*weights
column[list[number]]
An optional column containing link weights.
degree
column[number]
required
Column containing the number of incoming, outgoing or all connections for each row/node in the dataset.

Configuration

The following parameters can be used to configure the behaviour of the step by including them in a json object as the last “input” to the step, i.e. step(..., {"param": "value", ...}) -> (output).

Parameters

mode
string
default:"all"
Which node connections to count. Whether to
  • in: count only a node’s incoming links
  • out: count only a node’s outgoing links
  • all/both count both incoming and outgoing links.
Values must be one of the following:
  • all
  • out
  • in
  • both
directed
boolean
default:"false"
Whether the links are directed or not.
loops
boolean
Whether loops will be counted. Loops are links of nodes to themselves.
I