Skip to content

degrees

AbstractDegree

Bases: GraphMeasure, ABC

A measure calculating various degrees for the graph's nodes.

A degree is a measure in graph theory that represents the number of edges connected to a vertex, accounting for incoming, outgoing, or both directions depending on the type of degree.

compute(graph)

Compute graph measure and add it as a property to the graph.

Parameters:

Name Type Description Default
graph Graph

The graph to calculate the measure for.

required

Returns:

Type Description
ndarray

np.ndarray: the graph with the measure computed.

get_degree(graph) abstractmethod

precalculate_degrees(graph) staticmethod

Degree

Bases: AbstractDegree

The total amount of edges coming in or out of the node (in + out)

get_degree(graph)

Computes the degree of a graph

Parameters:

Name Type Description Default
graph Graph

The graph to calculate the measure for.

required

Returns:

Type Description
ndarray

np.array: an array of the degree for each node in the graph

DegreeDiff

Bases: AbstractDegree

The difference between the in_degree and out_degree

get_degree(graph)

Computes the degree difference of a graph

Parameters:

Name Type Description Default
graph Graph

The graph to calculate the measure for.

required

Returns:

Type Description
ndarray

np.array: an array of the degree difference for each node in the graph

InDegree

Bases: AbstractDegree

The number of edges coming into a node

get_degree(graph)

Computes the in degree of a graph

Parameters:

Name Type Description Default
graph Graph

The graph to calculate the measure for.

required

Returns:

Type Description
ndarray

np.array: an array of the in degree for each node in the graph

OutDegree

Bases: AbstractDegree

The number of edges coming out of a node

get_degree(graph)

Computes the out degree of a graph

Parameters:

Name Type Description Default
graph Graph

The graph to calculate the measure for.

required

Returns:

Type Description
ndarray

np.array: an array of the out degree for each node in the graph