networkanalysis.statistics#

This module contains classes and functions to compute statistics on networks.

Functions

gwd(graph, decay)

Compute the geometrically weighted degree of the simple graph.

gwesp(graph, decay)

Compute the geometrically weighted edgewise shared partners of the graph.

in_kstars(graph, k)

Count the number of in k-stars of the directed graph.

kstars(graph, k)

Count the number of k-stars of the undirected graph.

mutuals(graph)

Count the number of pairs of nodes in the graph that has a mutual connection.

out_kstars(graph, k)

Count the number of out k-stars of the directed graph.

stats_transform(stats)

Transform the list of statistics into one function that computes the vector of statistics from the list.

Classes

CachedStatsComp

StatsComp that caches the computed statistics.

GWD

Dummy callable object that mimics gwd().

GWESP

Dummy callable object that mimics gwesp().

InKStars

Dummy callable object that mimics in_kstars().

KStars

Dummy callable object that mimics kstars().

Mutuals

Dummy callable object that mimics mutuals().

NEdges

Dummy callable object that mimics number_of_edges().

OutKStars

Dummy callable object that mimics out_kstars().

StatsComp

Callable object that computes a vector of statistics from a graph.

class networkanalysis.statistics.CachedStatsComp#

Bases: StatsComp

StatsComp that caches the computed statistics.

__init__(stats, max_size=10000)#

Initialize the CachedStatsComp object.

Parameters:
class networkanalysis.statistics.GWD#

Bases: object

Dummy callable object that mimics gwd().

__init__(decay)#

Initializa a callable object that mimics gwd().

Parameters:

decay (float) – The decay parameter.

class networkanalysis.statistics.GWESP#

Bases: object

Dummy callable object that mimics gwesp().

__init__(decay)#

Initializa a callable object that mimics gwesp().

Parameters:

decay (float) – The decay parameter.

class networkanalysis.statistics.InKStars#

Bases: object

Dummy callable object that mimics in_kstars().

__init__(k)#

Initializa a callable object that mimics in_kstars().

Parameters:

k (int) – The number of branch of a star.

class networkanalysis.statistics.KStars#

Bases: object

Dummy callable object that mimics kstars().

__init__(k)#

Initializa a callable object that mimics kstars().

Parameters:

k (int) – The number of branch of a star.

class networkanalysis.statistics.Mutuals#

Bases: object

Dummy callable object that mimics mutuals().

class networkanalysis.statistics.NEdges#

Bases: object

Dummy callable object that mimics number_of_edges().

class networkanalysis.statistics.OutKStars#

Bases: object

Dummy callable object that mimics out_kstars().

__init__(k)#

Initializa a callable object that mimics out_kstars().

Parameters:

k (int) – The number of branch of a star.

class networkanalysis.statistics.StatsComp#

Bases: object

Callable object that computes a vector of statistics from a graph. StatsComp can be understand as “Statistics Computer”.

__init__(stats)#

Initialize the StatsComp object.

Parameters:

stats (list[ Callable[ [Graph | DiGraph], float | int] ]) – List of callable object that takes a NetworkX graph as argument. It also accepts another StatsComp object and copy it.

networkanalysis.statistics.gwd(graph, decay)#

Compute the geometrically weighted degree of the simple graph.

Parameters:
  • graph (Graph) – The graph.

  • decay (float) – The decay parameter.

Returns:

The geometrically weighted degree.

Return type:

float

networkanalysis.statistics.gwesp(graph, decay)#

Compute the geometrically weighted edgewise shared partners of the graph.

Parameters:
  • graph (Graph) – The graph.

  • decay (float) – The decay parameter.

Returns:

The geometrically weighted edgewise shared partners.

Return type:

float

networkanalysis.statistics.in_kstars(graph, k)#

Count the number of in k-stars of the directed graph. An in k-star in composed of arcs pointing towards its center.

Parameters:
  • graph (DiGraph) – The graph.

  • k (int) – The number of branch of a star.

Returns:

The number of in k-stars the graph contains.

Return type:

int

networkanalysis.statistics.kstars(graph, k)#

Count the number of k-stars of the undirected graph.

Parameters:
  • graph (Graph) – The graph.

  • k (int) – The number of branch of a star.

Returns:

The number of k-stars the graph contains.

Return type:

int

networkanalysis.statistics.mutuals(graph)#

Count the number of pairs of nodes in the graph that has a mutual connection. In a undirected multigraph, two nodes have a mutual connection if there are at least two edges between them. In a directed graph, two arcs between two nodes must be of opposite direction for having a mutual connection.

Parameters:

graph (Graph | DiGraph) – The graph.

Returns:

The number of mutual connections.

Return type:

int

networkanalysis.statistics.out_kstars(graph, k)#

Count the number of out k-stars of the directed graph. An out k-star in composed of arcs pointing towards its border.

Parameters:
  • graph (DiGraph) – The graph.

  • k (int) – The number of branch of a star.

Returns:

The number of out k-stars the graph contains.

Return type:

int

networkanalysis.statistics.stats_transform(stats)#

Transform the list of statistics into one function that computes the vector of statistics from the list.

Parameters:

stats (SeqGraph2Stats) – List of callable object that takes a NetworkX graph as argument.

Returns:

A callable object that takes a NetworkX graph as argument and returns a vector of statistics.

Return type:

collections.abc.Callable[ [networkx.Graph | networkx.DiGraph], numpy.ndarray]