-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meta-ticket: Audit/fix graph methods failing when vertices or edges are of incomparable types #35902
Comments
TypeError Traceback (most recent call last) |
This is with different traceback from the G=graphs.CompleteGraph(4)
H=Graph([("A",1)])
G.subgraph_search(H)
11369 if sort:
> 11370 return sorted(self.vertex_iterator(degree=degree, vertex_property=vertex_property), key=key) |
Thanks for reporting. With #35904 we have: sage: G = Graph([('\x03', '\x05'), ('\x01', 4), ('\x06', 4), ('\x05', 0), (0, 5), ('\x04', 0), (1, 2), (1, 4), ('\x04', 1), ('\x05', 2), ('\x02', 2), ('\x03', 3), ('\x01', 3), ('\x06', 3), ('\x03', 5), ('\x04', 5), ('\x01', '\x02'), ('\x02', '\x06')])
sage: G.is_perfect()
False and sage: G = graphs.CompleteGraph(4)
sage: H = Graph([("A",1)])
sage: G.subgraph_search(H)
Subgraph of (Complete graph): Graph on 2 vertices |
Have you checked regressions? You allow new codepaths, which were not reachable on python3. |
I'm not sure to understand your question. With #35904, we only make |
I mean are you sure you don't introduce new bugs in extreme cases? |
Well, previous doctests are satisfied and I added new doctests... Furthermore, the referees may ask for further changes. |
I don't have sage-latest and am working on 9.6 from fedora and check the testcases on sagecell. Is there another place to check testcases on sage-latest? |
You may use cocalc.com. It should use the last release (10.0). |
Part of #35902. ### 📚 Description We ensure that the method operates properly even when vertices and edges are of incomparable types. On the way, we also avoid a call to `adjacency_matrix`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35904 Reported by: David Coudert Reviewer(s): Matthias Köppe
Part of #35902. The method `find_hamiltonian` had multiple issues: it was not robust to vertices with incomparable labels, it could loop forever if a vertex has degree 1, a segfault was possible on small graphs, it was not properly working for digraphs, etc. We fix multiple issues and the method should now be safe. ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. URL: #35956 Reported by: David Coudert Reviewer(s): Dima Pasechnik
…e_boundary Part of sagemath#35902. ### 📚 Description We add parameter `key` to methods `multiple_edges` and `edge_boundary`. This is useful when users manipulate graphs with edges of incomparable types. On the way, we avoid some calls to `multiple_edges` with `sort=True` in method `is_tree`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#35903 Reported by: David Coudert Reviewer(s): Dima Pasechnik
We do some minor changes in `sage/graphs/domination.py`. The main change is the default value of parameter `work_on_copy` from `False` to `True`. Firstly, it is safer to ensure that the input graph is not modified by default, unless the user asks for such behavior. Secondly, the method was actually working on a copy when the parameter was `False` (wrong order of tests). We also add some tests to show that the methods are robust to vertices with incomparable labels (see sagemath#35902). ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#35982 Reported by: David Coudert Reviewer(s): David Coudert, Matthias Köppe
…e_boundary Part of sagemath#35902. ### 📚 Description We add parameter `key` to methods `multiple_edges` and `edge_boundary`. This is useful when users manipulate graphs with edges of incomparable types. On the way, we avoid some calls to `multiple_edges` with `sort=True` in method `is_tree`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#35903 Reported by: David Coudert Reviewer(s): Dima Pasechnik
We do some minor changes in `sage/graphs/domination.py`. The main change is the default value of parameter `work_on_copy` from `False` to `True`. Firstly, it is safer to ensure that the input graph is not modified by default, unless the user asks for such behavior. Secondly, the method was actually working on a copy when the parameter was `False` (wrong order of tests). We also add some tests to show that the methods are robust to vertices with incomparable labels (see sagemath#35902). ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#35982 Reported by: David Coudert Reviewer(s): David Coudert, Matthias Köppe
…tex labels Part of sagemath#35902. ### 📚 Description We ensure that method `min_spanning_tree` operates properly even when vertices and edges are of incomparable types. We are then able to simplify some code in `src/sage/topology/simplicial_complex.py`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36232 Reported by: David Coudert Reviewer(s): Frédéric Chapoton
…tex labels Part of sagemath#35902. ### 📚 Description We ensure that method `min_spanning_tree` operates properly even when vertices and edges are of incomparable types. We are then able to simplify some code in `src/sage/topology/simplicial_complex.py`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36232 Reported by: David Coudert Reviewer(s): Frédéric Chapoton
Is there an existing issue for this?
Problem Description
Several methods are failing when the vertices of the graph are of incomparable type. For instance:
Proposed Solution
Stop sorting vertices by default whenever possible and add relevant tests / documentation when necessary.
Alternatives Considered
None.
Additional Information
Related issues / PR:
min_spanning_tree
robust to incomparable vertex labels #36232Relevant discussions on sage-devel:
The text was updated successfully, but these errors were encountered: