Skip to content

Commit

Permalink
Merge pull request #246 from seoanezonjic/master
Browse files Browse the repository at this point in the history
Minor fix when a cluster has only two nodes
  • Loading branch information
GiulioRossetti authored Sep 3, 2024
2 parents 74d55d3 + 001306a commit c7e0939
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cdlib/algorithms/internal/HLC.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,13 @@ def get_nodesNedges_per_cluster(self, members, edge_list):

def get_cluster_partial_partition_density(self, edges, nodes):
n = len(nodes) # node number
m = len(edges) # link number
# return (m-(n-1))/(n*(n-1)/(2-(n-1))) #Ahn
return (m * (m - n + 1)) / ((n - 2) * (n - 1)) # kalinka
if n == 2:
partial_partition_density = 0
else:
m = len(edges) # link number
# partial_partition_density = (m-(n-1))/(n*(n-1)/(2-(n-1))) #Ahn
partial_partition_density = (m * (m - n + 1)) / ((n - 2) * (n - 1)) # kalinka
return partial_partition_density

def get_pden(self, last_cluster_pool, partial_partition_densities, constant):
partition_den_sum = sum(
Expand Down

0 comments on commit c7e0939

Please sign in to comment.