# Extract node degree¶

networkgraphcentrality

Calculate network node degrees.

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 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]

An optional column containing link weights.

## Outputs¶

degree: column:number

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

## Parameters¶

mode: string = "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.

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

directed: boolean = False

Whether the links are directed or not.

loops: boolean

Whether loops will be counted. Loops are links of nodes to themselves.