Skip to content

Conversation

dcoudert
Copy link
Contributor

Fixes #39934.

We ensure that the sparse/dense/static_sparse graph backends have the methods needed in lex_BFS and slice_decomposition.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Copy link

github-actions bot commented Apr 13, 2025

Documentation preview for this PR (built with commit 8253903; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@dcoudert
Copy link
Contributor Author

@cyrilbouvier, can you check this PR. A segmentation fault occurs with immutable graphs but I don't understand what's going on. As you can see, the behavior is somewhat random but will eventually crash.
Help is more than welcome.

sage: G = Graph(graphs.HouseGraph(), immutable=True)
sage: G.lex_BFS(algorithm="fast")
---------------------------------------------------------------------------
SignalError                               Traceback (most recent call last)
Cell In[2], line 1
----> 1 G.lex_BFS(algorithm="fast")

File ~/sage/src/sage/graphs/traversals.pyx:500, in sage.graphs.traversals.lex_BFS()
    498 else:
    499     initial_v_int = -1
--> 500 sig_on()
    501 extended_lex_BFS(cg, sigma_int, NULL, initial_v_int, &pred, NULL, NULL)
    502 sig_off()

SignalError: Segmentation fault
sage: G = Graph(graphs.HouseGraph(), immutable=True)
sage: G.lex_BFS(algorithm="fast")
[None, 0, 0, 0, 4]
sage: G = Graph(graphs.HouseGraph(), immutable=True)
sage: G.lex_BFS(algorithm="fast")
[0, 1, 2, 3, 4]

@dcoudert
Copy link
Contributor Author

Got it ! The number of arcs in StaticSparseCGraph was not properly initialized.

@cyrilbouvier
Copy link
Contributor

@cyrilbouvier, can you check this PR. A segmentation fault occurs with immutable graphs but I don't understand what's going on. As you can see, the behavior is somewhat random but will eventually crash. Help is more than welcome.

sage: G = Graph(graphs.HouseGraph(), immutable=True)
sage: G.lex_BFS(algorithm="fast")
---------------------------------------------------------------------------
SignalError                               Traceback (most recent call last)
Cell In[2], line 1
----> 1 G.lex_BFS(algorithm="fast")

File ~/sage/src/sage/graphs/traversals.pyx:500, in sage.graphs.traversals.lex_BFS()
    498 else:
    499     initial_v_int = -1
--> 500 sig_on()
    501 extended_lex_BFS(cg, sigma_int, NULL, initial_v_int, &pred, NULL, NULL)
    502 sig_off()

SignalError: Segmentation fault
sage: G = Graph(graphs.HouseGraph(), immutable=True)
sage: G.lex_BFS(algorithm="fast")
[None, 0, 0, 0, 4]
sage: G = Graph(graphs.HouseGraph(), immutable=True)
sage: G.lex_BFS(algorithm="fast")
[0, 1, 2, 3, 4]

Sorry for not replying earlier, I was on holidays.
Thanks for fixing the issue, I will try to review the PR this week.

Copy link
Contributor

@cyrilbouvier cyrilbouvier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
The failing CI does not seem related to this PR (error is no space left on device., looks more like an error with the CI or runner)

Comment on lines +435 to +438
sig_on()
extended_lex_BFS(cg, sigma, NULL, initial_v_int, NULL,
&(self.xslice_len), &lex_label)
sig_off()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More a naive question than a remark: why sig_on/sig_off are needed here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's mandatory, but in case of failure it helps locating the issue in this call.

@dcoudert
Copy link
Contributor Author

Thanks for the review. I set this PR to positive review on your behalf.

@vbraun vbraun merged commit 82553b1 into sagemath:develop Apr 29, 2025
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lex_BFS fails with immutable graphs
3 participants