Skip to content

Commit 42363bf

Browse files
author
Matthias Koeppe
committed
src/sage/graphs/bipartite_graph.py: Use lazy_import
1 parent a14c1b9 commit 42363bf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/sage/graphs/bipartite_graph.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
from sage.rings.integer import Integer
4848
from sage.misc.decorators import rename_keyword
4949
from sage.misc.cachefunc import cached_method
50+
from sage.misc.lazy_import import lazy_import
51+
52+
lazy_import('networkx', ['MultiGraph', 'Graph'], as_=['networkx_MultiGraph', 'networkx_Graph'])
5053

5154

5255
class BipartiteGraph(Graph):
@@ -504,8 +507,7 @@ def __init__(self, data=None, partition=None, check=True, hash_labels=None, *arg
504507
if len(left) + len(right) != self.num_verts():
505508
raise ValueError("not all vertices appear in partition")
506509

507-
import networkx
508-
if isinstance(data, (networkx.MultiGraph, networkx.Graph)):
510+
if isinstance(data, (networkx_MultiGraph, networkx_Graph)):
509511
if hasattr(data, "node_type"):
510512
# Assume the graph is bipartite
511513
self.left = set()

0 commit comments

Comments
 (0)