Skip to content

Commit

Permalink
Merge pull request #512 from dwavesystems/dwave-systemarcondello/netw…
Browse files Browse the repository at this point in the history
…orkx-transitive-dependency

Remove NetworkX as a direct dependency
  • Loading branch information
arcondello authored Jan 16, 2024
2 parents 0ae6d26 + 270471e commit a5a7eec
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx>=4.0.0,<5.0.0
sphinx
sphinx_rtd_theme
dwave-greedy==0.3.0
4 changes: 4 additions & 0 deletions dwave/system/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import os
import json
import networkx as nx
import warnings

__all__ = ['common_working_graph', 'classproperty']

Expand Down Expand Up @@ -60,6 +61,9 @@ def common_working_graph(graph0, graph1):
>>> p3_working_graph = common_working_graph(P3, sampler.adjacency)
"""
warnings.warn("dwave.system.common_working_graph() is deprecated as of dwave-system 1.23.0 "
"and will be removed in dwave-system 2.0. Use networkx.intersection() instead.",
DeprecationWarning, stacklevel=2)

G = nx.Graph()
G.add_nodes_from(v for v in graph0 if v in graph1)
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
'dwave-cloud-client>=0.11.0,<0.13.0',
'dwave-networkx>=0.8.10',
'dwave-preprocessing>=0.5.0',
'networkx>=2.0,<3.0',
'homebase>=1.0.0,<2.0.0',
'minorminer>=0.2.8,<0.3.0',
'numpy>=1.21.6', # minimum inherited from minorminer
Expand Down
12 changes: 8 additions & 4 deletions tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class TestCommonWorkingGraph(unittest.TestCase):
def test_single_tile(self):

G1 = dnx.chimera_graph(1)
G = common_working_graph(G1, G1)
with self.assertWarns(DeprecationWarning):
G = common_working_graph(G1, G1)

# should have 8 nodes
self.assertEqual(len(G), 8)
Expand All @@ -44,7 +45,8 @@ def test_c1_c2_tiles(self):
G1 = dnx.chimera_graph(1)
G2 = dnx.chimera_graph(2)

G = common_working_graph(G1, G1)
with self.assertWarns(DeprecationWarning):
G = common_working_graph(G1, G1)

self.assertEqual(len(G), 8)

Expand All @@ -53,7 +55,8 @@ def test_missing_node(self):
G1.remove_node(2)
G2 = dnx.chimera_graph(2)

G = common_working_graph(G1, G1)
with self.assertWarns(DeprecationWarning):
G = common_working_graph(G1, G1)

self.assertNotIn(2, G)
self.assertNotIn((2, 4), G.edges())
Expand All @@ -62,7 +65,8 @@ def test_sampler_adjacency(self):
adj = {0: {1, 2}, 1: {2}, 2: {0, 1}}
G = dnx.chimera_graph(1)

H = common_working_graph(adj, G)
with self.assertWarns(DeprecationWarning):
H = common_working_graph(adj, G)

self.assertEqual(set(H.nodes), {0, 1, 2})
self.assertEqual(set(H.edges), set())
Expand Down

0 comments on commit a5a7eec

Please sign in to comment.