Skip to content

Commit

Permalink
Add docstring to hierarchical_link_community_full
Browse files Browse the repository at this point in the history
  • Loading branch information
seoanezonjic committed May 27, 2024
1 parent e7cd48b commit aac3043
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cdlib/algorithms/edge_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,41 @@ def hierarchical_link_community_w(g_original: object) -> EdgeClustering:
return EdgeClustering(coms, g_original, "HLC_w", method_parameters={})


"""
HLC (hierarchical link clustering) is a method to classify links into topologically related groups.
The algorithm uses a similarity between links to build a dendrogram where each leaf is a link from the original network and branches represent link communities.
At each level of the link dendrogram is calculated the partition density function, based on link density inside communities, to pick the best level to cut.
This implementation follows exactly the algorithm described in Ahn et al and uses numpy/scipy to improve the clustering computation (It is faster and consumes less memory.
**Supported Graph Types**
========== ======== ========
Undirected Directed Weighted
========== ======== ========
Yes No Yes
========== ======== ========
:param g_original: a networkx/igraph object
:weight: None for unweighted networks, jaccard approximation is used. When defined with a string, edge attribute name (usually 'weight') to be used as weight and Tanimoto approximation is used.
:simthr: None by default. If set to float, all values less than threshold are set to 0 in similarity matrix (it could reduce memory usage).
:hcmethod: Linkage method used in hierarchical clustering, 'single' by default. See scipy.cluster.hierarchy.linkage to get full method list.
:min_edges: None by default. If set to float, minimum number of edges that a community must contain to be kept in the clustering
:verbose: If True, write intermediary steps to disk.
:return: EdgeClustering object
:Example:
>>> from cdlib import algorithms
>>> import networkx as nx
>>> G = nx.karate_club_graph()
>>> com = algorithms.hierarchical_link_community_full(G)
:References:
Ahn, Yong-Yeol, James P. Bagrow, and Sune Lehmann. `Link communities reveal multiscale complexity in networks. <https://www.nature.com/articles/nature09182/>`_ nature 466.7307 (2010): 761.
"""
def hierarchical_link_community_full(g_original: object, weight='weight', simthr=None, hcmethod='single', min_edges= None, verbose=False) -> EdgeClustering:
g = convert_graph_formats(g_original, nx.Graph)
g_number, dictio = nx_node_integer_mapping(g)
Expand Down

0 comments on commit aac3043

Please sign in to comment.