easygraph.functions.centrality package

Submodules

easygraph.functions.centrality.betweenness module

easygraph.functions.centrality.betweenness.betweenness_centrality(*args, **kwargs)

easygraph.functions.centrality.closeness module

easygraph.functions.centrality.closeness.closeness_centrality(*args, **kwargs)

easygraph.functions.centrality.degree module

easygraph.functions.centrality.degree.degree_centrality(G)[source]

Compute the degree centrality for nodes in a bipartite network.

The degree centrality for a node v is the fraction of nodes it is connected to.

Parameters:

G (graph) – A easygraph graph

Returns:

nodes – Dictionary of nodes with degree centrality as the value.

Return type:

dictionary

Notes

The degree centrality are normalized by dividing by n-1 where n is number of nodes in G.

easygraph.functions.centrality.degree.in_degree_centrality(G)[source]

Compute the in-degree centrality for nodes.

The in-degree centrality for a node v is the fraction of nodes its incoming edges are connected to.

Parameters:

G (graph) – A EasyGraph graph

Returns:

nodes – Dictionary of nodes with in-degree centrality as values.

Return type:

dictionary

Raises:

EasyGraphNotImplemented: – If G is undirected.

Notes

The degree centrality values are normalized by dividing by the maximum possible degree in a simple graph n-1 where n is the number of nodes in G.

For multigraphs or graphs with self loops the maximum degree might be higher than n-1 and values of degree centrality greater than 1 are possible.

easygraph.functions.centrality.degree.out_degree_centrality(G)[source]

Compute the out-degree centrality for nodes.

The out-degree centrality for a node v is the fraction of nodes its outgoing edges are connected to.

Parameters:

G (graph) – A EasyGraph graph

Returns:

nodes – Dictionary of nodes with out-degree centrality as values.

Return type:

dictionary

Raises:

EasyGraphNotImplemented: – If G is undirected.

Notes

The degree centrality values are normalized by dividing by the maximum possible degree in a simple graph n-1 where n is the number of nodes in G.

For multigraphs or graphs with self loops the maximum degree might be higher than n-1 and values of degree centrality greater than 1 are possible.

easygraph.functions.centrality.ego_betweenness module

easygraph.functions.centrality.ego_betweenness.ego_betweenness(G, node)[source]

ego networks are networks consisting of a single actor (ego) together with the actors they are connected to (alters) and all the links among those alters.[1] Burt (1992), in his book Structural Holes, provides ample evidence that having high betweenness centrality, which is highly correlated with having many structural holes, can bring benefits to ego.[1] Returns the betweenness centrality of a ego network whose ego is set

Parameters:
  • G (graph) –

  • node (int) –

Returns:

sum – the betweenness centrality of a ego network whose ego is set

Return type:

float

Examples

Returns the betwenness centrality of node 1.

>>> ego_betweenness(G,node=1)

Reference

easygraph.functions.centrality.flowbetweenness module

easygraph.functions.centrality.flowbetweenness.flowbetweenness_centrality(G)[source]

Compute the independent-basic betweenness centrality for nodes in a flow network.

\[c_B(v) =\sum_{s,t \in V}\]

rac{sigma(s, t|v)}{sigma(s, t)}

where V is the set of nodes,

\[\sigma(s, t)\ is\ the\ number\ of\ independent\ (s, t)-paths,\]
\[\sigma(s, t|v)\ is\ the\ maximum\ number\ possible\ of\ those\ paths\ passing\ through\ some\ node\ v\ other\ than\ s, t.\]
\[If\ s\ =\ t,\ \sigma(s, t)\ =\ 1,\ and\ if\ v \in \{s, t\},\ \sigma(s, t|v)\ =\ 0\ [2]_.\]
Ggraph

A easygraph directed graph.

nodesdictionary

Dictionary of nodes with independent-basic betweenness centrality as the value.

A flow network is a directed graph where each edge has a capacity and each edge receives a flow.

easygraph.functions.centrality.laplacian module

easygraph.functions.centrality.laplacian.laplacian(G, n_workers=None)[source]

Returns the laplacian centrality of each node in the weighted graph

Parameters:

G (graph) – weighted graph

Returns:

CL – the laplacian centrality of each node in the weighted graph

Return type:

dict

Examples

Returns the laplacian centrality of each node in the weighted graph G

>>> laplacian(G)

Reference

“Laplacian centrality: A new centrality measure for weighted networks.” Information Sciences, Volume 194, Pages 240-253, 2012.

easygraph.functions.centrality.pagerank module

easygraph.functions.centrality.pagerank.pagerank(*args, **kwargs)

Module contents