|
424 | 424 | from sage.misc.rest_index_of_methods import doc_index, gen_thematic_rest_table_index
|
425 | 425 | from sage.graphs.views import EdgesView
|
426 | 426 |
|
| 427 | +from sage.misc.lazy_import import lazy_import |
| 428 | +from sage.features import PythonModule |
| 429 | +lazy_import('sage.graphs.mcqd', ['mcqd'], |
| 430 | + feature=PythonModule('sage.graphs.mcqd', spkg='mcqd')) |
427 | 431 |
|
428 | 432 | class Graph(GenericGraph):
|
429 | 433 | r"""
|
@@ -2718,8 +2722,9 @@ def treewidth(self, k=None, certificate=False, algorithm=None):
|
2718 | 2722 | # TDLIB
|
2719 | 2723 | if algorithm == 'tdlib':
|
2720 | 2724 | if not tdlib_found:
|
2721 |
| - from sage.misc.package import PackageNotFoundError |
2722 |
| - raise PackageNotFoundError("tdlib") |
| 2725 | + from sage.features import FeatureNotPresentError |
| 2726 | + raise FeatureNotPresentError(PythonModule('sage.graphs.graph_decompositions.tdlib', |
| 2727 | + spkg='tdlib')) |
2723 | 2728 |
|
2724 | 2729 | T = tdlib.treedecomposition_exact(g, -1 if k is None else k)
|
2725 | 2730 | width = tdlib.get_width(T)
|
@@ -6411,11 +6416,6 @@ def clique_maximum(self, algorithm="Cliquer", solver=None, verbose=0):
|
6411 | 6416 | elif algorithm == "MILP":
|
6412 | 6417 | return self.complement().independent_set(algorithm=algorithm, solver=solver, verbosity=verbose)
|
6413 | 6418 | elif algorithm == "mcqd":
|
6414 |
| - try: |
6415 |
| - from sage.graphs.mcqd import mcqd |
6416 |
| - except ImportError: |
6417 |
| - from sage.misc.package import PackageNotFoundError |
6418 |
| - raise PackageNotFoundError("mcqd") |
6419 | 6419 | return mcqd(self)
|
6420 | 6420 | else:
|
6421 | 6421 | raise NotImplementedError("Only 'MILP', 'Cliquer' and 'mcqd' are supported.")
|
@@ -6514,11 +6514,6 @@ def clique_number(self, algorithm="Cliquer", cliques=None, solver=None, verbose=
|
6514 | 6514 | elif algorithm == "MILP":
|
6515 | 6515 | return len(self.complement().independent_set(algorithm=algorithm, solver=solver, verbosity=verbose))
|
6516 | 6516 | elif algorithm == "mcqd":
|
6517 |
| - try: |
6518 |
| - from sage.graphs.mcqd import mcqd |
6519 |
| - except ImportError: |
6520 |
| - from sage.misc.package import PackageNotFoundError |
6521 |
| - raise PackageNotFoundError("mcqd") |
6522 | 6517 | return len(mcqd(self))
|
6523 | 6518 | else:
|
6524 | 6519 | raise NotImplementedError("Only 'networkx' 'MILP' 'Cliquer' and 'mcqd' are supported.")
|
|
0 commit comments