Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix when a cluster has only two nodes #246

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading