Skip to content

Commit

Permalink
last step bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ftheberge committed Jul 25, 2024
1 parent 98dc91b commit baf0cda
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hypernetx/algorithms/hypergraph_modularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,12 @@ def _last_step_weighted(H, A, wdc, delta=0.01, verbose=False):
n_moves = 0
for v in list(np.random.permutation(list(H.nodes))):
dct_A_v = dct_A[v]
H_id = [H.incidence_dict[x] for x in H.nodes[v].memberships]
H_id = [H.incidence_dict[x] for x in H.nodes[v]]
L = [[dct_A[i] for i in x] for x in H_id]

## ec portion before move
_keys = [(Counter(l).most_common(1)[0][1], len(l)) for l in L]
_vals = [H.edges[x].weight for x in H.nodes[v].memberships]
_vals = [H.edges[x].weight for x in H.nodes[v]]
_df = pd.DataFrame(zip(_keys, _vals), columns=["key", "val"])
_df = _df.groupby(by="key").sum()
ec = sum(
Expand Down Expand Up @@ -425,7 +425,7 @@ def _last_step_weighted(H, A, wdc, delta=0.01, verbose=False):
L = [[dct_A[i] for i in x] for x in H_id]
## EC
_keys = [(Counter(l).most_common(1)[0][1], len(l)) for l in L]
_vals = [H.edges[x].weight for x in H.nodes[v].memberships]
_vals = [H.edges[x].weight for x in H.nodes[v]]
_df = pd.DataFrame(zip(_keys, _vals), columns=["key", "val"])
_df = _df.groupby(by="key").sum()
ecp = sum(
Expand Down Expand Up @@ -491,7 +491,7 @@ def _last_step_unweighted(H, A, wdc, delta=0.01, verbose=False):
n_moves = 0
for v in list(np.random.permutation(list(H.nodes))):
dct_A_v = dct_A[v]
H_id = [H.incidence_dict[x] for x in H.nodes[v].memberships]
H_id = [H.incidence_dict[x] for x in H.nodes[v]]
L = [[dct_A[i] for i in x] for x in H_id]
deg_v = H.degree(v)

Expand Down

0 comments on commit baf0cda

Please sign in to comment.