Skip to content

.longest_path(algorithm='backtrack') gives incorrect result #36530

@maxale

Description

@maxale

Steps To Reproduce

The following code returns produces a path on 26 vertices:

G = DiGraph( ((x,y) for x,y in Tuples(range(10,100),2) if x!=y and y%sum(ZZ(x).digits())==0), format='list_of_edges' )
with seed(0):
    L = G.longest_path(algorithm='backtrack')
print(L.order())

while G.longest_path(solver='gurobi') produces a path on 64 vertices .

Also, G.longest_path(algorithm='backtrack') ignores the starting vertex when its given. For example, using L = G.longest_path(94, algorithm='backtrack') still produces a path starting at vertex 47.

Expected Behavior

Using algorithm='backtrack' should produce a correct longest path, and obey other given parameters (such as a starting vertex).

Actual Behavior

See above.

Additional Information

No response

Environment

- **OS**: Ubuntu 22.04.3 LTS
- **Sage Version**: 10.2.beta5

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions