easygraph.functions.hypergraph.hypergraph_clustering module#

Algorithms for computing nodal clustering coefficients.

easygraph.functions.hypergraph.hypergraph_clustering.hypergraph_clustering_coefficient(H)[source]#

Return the clustering coefficients for each node in a Hypergraph.

This clustering coefficient is defined as the clustering coefficient of the unweighted pairwise projection of the hypergraph, i.e., \(c = A^3_{i,i}/\binom{k}{2},\) where \(A\) is the adjacency matrix of the network and \(k\) is the pairwise degree of \(i\).

Parameters:

H (Hypergraph) – Hypergraph

Returns:

nodes are keys, clustering coefficients are values.

Return type:

dict

Notes

The clustering coefficient is undefined when the number of neighbors is 0 or 1, but we set the clustering coefficient to 0 in these cases. For more discussion, see https://arxiv.org/abs/0802.2512

See also

local_clustering_coefficient, two_node_clustering_coefficient

References

“Clustering Coefficients in Protein Interaction Hypernetworks” by Suzanne Gallagher and Debra Goldberg. DOI: 10.1145/2506583.2506635

Example

>>> import easygraph as eg
>>> H = eg.random_hypergraph(3, [1, 1])
>>> cc = eg.clustering_coefficient(H)
>>> cc
{0: 1.0, 1: 1.0, 2: 1.0}
easygraph.functions.hypergraph.hypergraph_clustering.hypergraph_local_clustering_coefficient(H)[source]#

Compute the local clustering coefficient.

This clustering coefficient is based on the overlap of the edges connected to a given node, normalized by the size of the node’s neighborhood.

Parameters:

H (Hypergraph) – Hypergraph

Returns:

keys are node IDs and values are the clustering coefficients.

Return type:

dict

Notes

The clustering coefficient is undefined when the number of neighbors is 0 or 1, but we set the clustering coefficient to 0 in these cases. For more discussion, see https://arxiv.org/abs/0802.2512

See also

clustering_coefficient, two_node_clustering_coefficient

References

“Properties of metabolic graphs: biological organization or representation artifacts?” by Wanding Zhou and Luay Nakhleh. https://doi.org/10.1186/1471-2105-12-132

“Hypergraphs for predicting essential genes using multiprotein complex data” by Florian Klimm, Charlotte M. Deane, and Gesine Reinert. https://doi.org/10.1093/comnet/cnaa028

Example

>>> import easygraph as eg
>>> H = eg.random_hypergraph(3, [1, 1])
>>> cc = eg.local_clustering_coefficient(H)
>>> cc
{0: 1.0, 1: 1.0, 2: 1.0}
easygraph.functions.hypergraph.hypergraph_clustering.hypergraph_two_node_clustering_coefficient(H, kind='union')[source]#

Return the clustering coefficients for each node in a Hypergraph.

This definition averages over all of the two-node clustering coefficients involving the node.

Parameters:
  • H (Hypergraph) – Hypergraph

  • kind (string, optional) – The type of two node clustering coefficient. Options are “union”, “max”, and “min”. By default, “union”.

Returns:

nodes are keys, clustering coefficients are values.

Return type:

dict

Notes

The clustering coefficient is undefined when the number of neighbors is 0 or 1, but we set the clustering coefficient to 0 in these cases. For more discussion, see https://arxiv.org/abs/0802.2512

See also

clustering_coefficient, local_clustering_coefficient

References

“Clustering Coefficients in Protein Interaction Hypernetworks” by Suzanne Gallagher and Debra Goldberg. DOI: 10.1145/2506583.2506635

Example

>>> import easygraph as eg
>>> H = eg.random_hypergraph(3, [1, 1])
>>> cc = eg.two_node_clustering_coefficient(H, kind="union")
>>> cc
{0: 0.5, 1: 0.5, 2: 0.5}