Skip to content

Commit

Permalink
Bump networkx from 2.5 to 3.0 (#2)
Browse files Browse the repository at this point in the history
* Bump networkx from 2.5 to 3.0

Bumps [networkx](https://github.com/networkx/networkx) from 2.5 to 3.0.
- [Release notes](https://github.com/networkx/networkx/releases)
- [Commits](networkx/networkx@networkx-2.5...networkx-3.0)

---
updated-dependencies:
- dependency-name: networkx
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Updated code for networkx 3.0

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jan Ernsting <[email protected]>
  • Loading branch information
dependabot[bot] and jernsting authored Feb 17, 2023
1 parent cefcdea commit d3986f3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gem/embedding/hope.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def learn_embedding(self, graph=None,
if not graph:
raise ValueError('graph needed')

A = nx.to_numpy_matrix(graph)
A = nx.to_numpy_array(graph)
m_g = np.eye(len(graph.nodes)) - self._beta * A
m_l = self._beta * A
S = np.dot(np.linalg.inv(m_g), m_l)
Expand Down
2 changes: 1 addition & 1 deletion gem/embedding/lle.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def learn_embedding(self, graph=None,
if not graph:
raise ValueError('graph needed')
graph = graph.to_undirected()
A = nx.to_scipy_sparse_matrix(graph)
A = nx.to_scipy_sparse_array(graph)
normalize(A, norm='l1', axis=1, copy=False)
i_n = sp.eye(len(graph.nodes))
i_min_A = i_n - A
Expand Down
2 changes: 1 addition & 1 deletion gem/embedding/sdne.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def learn_embedding(self, graph=None,
is_weighted=False, no_python=False):
if not graph:
raise ValueError('graph needed')
sparse = nx.to_scipy_sparse_matrix(graph)
sparse = nx.to_scipy_sparse_array(graph)
sparse = (sparse + sparse.T) / 2
self._node_num = len(graph.nodes)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
numpy==1.24.2
scipy>=0.19.0
networkx==2.5
networkx==3.0
matplotlib>=2.0.0
scikit-learn>=0.21.2
theano>=0.9.0
Expand Down
3 changes: 2 additions & 1 deletion tests/test_sbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


from tests.fit_model import fit_model
from tests.utils import read_gpickle


class SBMTest(unittest.TestCase):
Expand All @@ -30,7 +31,7 @@ def setUp(self) -> None:
file_prefix = os.path.join(self.source_dir, 'data/sbm.gpickle')

# Load graph
G = nx.read_gpickle(file_prefix)
G = read_gpickle(file_prefix)
# convert G (networkx 1.x digraph) to networkx 2.x
H = nx.DiGraph()
H.add_nodes_from(G.node)
Expand Down
7 changes: 7 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pickle


def read_gpickle(path: str):
with open(path, 'rb') as f:
g = pickle.load(f)
return g

0 comments on commit d3986f3

Please sign in to comment.