Skip to content
Merged
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
23 changes: 6 additions & 17 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8680,12 +8680,10 @@ def longest_path(self, s=None, t=None, use_edge_labels=False,
This parameter can only be used when ``algorithm`` is ``'MILP'``.

- ``algorithm`` -- string (default: ``'MILP'``); the algorithm to use
among ``'MILP'``, ``'backtrack'`` and ``'heuristic'``:
among ``'MILP'`` and ``'heuristic'``:

* ``'MILP'`` returns an exact answer.

* ``'backtrack'`` is renamed ``'heuristic'`` (:issue:`36574`).

* ``'heuristic'`` is a randomized heuristic for finding a long path in
an unweighted (di)graph. This heuristic does not take into account
parameters ``s``, ``t`` and ``use_edge_labels``. An error is raised
Expand Down Expand Up @@ -8760,13 +8758,13 @@ def longest_path(self, s=None, t=None, use_edge_labels=False,

TESTS:

The argument ``algorithm`` must be either ``'backtrack'``,
``'heuristic'`` or ``'MILP'``::
The argument ``algorithm`` must be either ``'heuristic'``
or ``'MILP'``::

sage: graphs.PetersenGraph().longest_path(algorithm='abc')
Traceback (most recent call last):
...
ValueError: algorithm must be either 'backtrack', 'heuristic' or 'MILP'
ValueError: algorithm must be either 'heuristic' or 'MILP'

Disconnected graphs not weighted::

Expand Down Expand Up @@ -8843,10 +8841,6 @@ def longest_path(self, s=None, t=None, use_edge_labels=False,
:issue:`36574`::

sage: G = graphs.PathGraph(3)
sage: P = G.longest_path(algorithm='backtrack')
doctest:...: DeprecationWarning: algorithm 'backtrack' is deprecated.
Use algorithm 'heuristic' instead.
See https://github.com/sagemath/sage/issues/36574 for details.
sage: G.longest_path(algorithm='heuristic', s=0)
Traceback (most recent call last):
...
Expand Down Expand Up @@ -8883,13 +8877,8 @@ def longest_path(self, s=None, t=None, use_edge_labels=False,
"""
self._scream_if_not_simple()

if algorithm not in ("backtrack", "heuristic", "MILP"):
raise ValueError("algorithm must be either 'backtrack', 'heuristic' or 'MILP'")
if algorithm == "backtrack":
from sage.misc.superseded import deprecation
deprecation(36574, "algorithm 'backtrack' is deprecated. "
"Use algorithm 'heuristic' instead.")
algorithm = 'heuristic'
if algorithm not in ("heuristic", "MILP"):
raise ValueError("algorithm must be either 'heuristic' or 'MILP'")
if algorithm == 'heuristic':
if s is not None or t is not None or use_edge_labels:
raise ValueError("parameters s, t, and use_edge_labels can not "
Expand Down
Loading