Skip to content

Commit c7e0939

Browse files
Merge pull request #246 from seoanezonjic/master
Minor fix when a cluster has only two nodes
2 parents 74d55d3 + 001306a commit c7e0939

File tree

1 file changed

+7
-3
lines changed
  • cdlib/algorithms/internal

1 file changed

+7
-3
lines changed

cdlib/algorithms/internal/HLC.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,13 @@ def get_nodesNedges_per_cluster(self, members, edge_list):
493493

494494
def get_cluster_partial_partition_density(self, edges, nodes):
495495
n = len(nodes) # node number
496-
m = len(edges) # link number
497-
# return (m-(n-1))/(n*(n-1)/(2-(n-1))) #Ahn
498-
return (m * (m - n + 1)) / ((n - 2) * (n - 1)) # kalinka
496+
if n == 2:
497+
partial_partition_density = 0
498+
else:
499+
m = len(edges) # link number
500+
# partial_partition_density = (m-(n-1))/(n*(n-1)/(2-(n-1))) #Ahn
501+
partial_partition_density = (m * (m - n + 1)) / ((n - 2) * (n - 1)) # kalinka
502+
return partial_partition_density
499503

500504
def get_pden(self, last_cluster_pool, partial_partition_densities, constant):
501505
partition_den_sum = sum(

0 commit comments

Comments
 (0)