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

Remove nx #22

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ dependencies = [
"websockets==10.3",
"python-dateutil==2.8.0",
"numpy==1.24.3",
"networkx",
"tqdm",
"pytest"
]
Expand Down
41 changes: 20 additions & 21 deletions src/p2lab/genetic/matching.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import networkx as nx
from itertools import combinations

# import networkx as nx
import numpy as np


Expand All @@ -17,23 +19,20 @@ def dense(teams: list[object]) -> np.ndarray:
np.ndarray shape (N_edges, 2)

"""
g = nx.complete_graph(len(teams))

# Select only the node index pairs, exclude the feature dict.
return np.stack(g.edges(data=False))


def mst(teams: list[object]) -> np.ndarray:
r"""
Returns a minimum spanning tree graph generated from the
fully connected graph over the teams.

Outputs:

np.ndarray shape (N_edges, 2)

"""
g = nx.complete_graph(len(teams))
mst = nx.algorithms.tree.minimum_spanning_edges(g, data=False)

return list(mst)
return list(combinations(range(len(teams)), 2))


# def mst(teams: list[object]) -> np.ndarray:
# r"""
# Returns a minimum spanning tree graph generated from the
# fully connected graph over the teams.
#
# Outputs:
#
# np.ndarray shape (N_edges, 2)
#
# """
# g = nx.complete_graph(len(teams))
# mst = nx.algorithms.tree.minimum_spanning_edges(g, data=False)
#
# return list(mst)