Skip to content
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

Implemented methods concerning bricks and braces of a matching covered graph #39065

Open
wants to merge 38 commits into
base: develop
Choose a base branch
from

Conversation

janmenjayap
Copy link
Contributor

@janmenjayap janmenjayap commented Dec 1, 2024

The objective of this issue is to implement the methods pertaining to the bricks and brace of a matching covered graph.

More specifically, this PR aims to implement the following two methods:

  • bricks_and_braces() | Return the list of (underlying simple graph of) the bricks and braces of the (matching covered) graph.
  • is_brace() | Check if the (matching covered) graph is a brace
  • is_brick() | Check if the (matching covered) graph is a brick.
  • number_of_braces() | Return the number of braces.
  • number_of_bricks() | Return the number of bricks.
  • number_of_petersen_bricks() | Return the number of Petersen bricks.
  • tight_cut_decomposition() | Return a tight cut decomposition.

This PR shall address the methods related to bricks, braces and tight cut decomposition of matching covered graphs.

Fixes #38216.
Note that this issue fixes a small part of the mentioned issue.

📝 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

This PR depends on the PR #38742 and #38892.

cc: @dcoudert.

Copy link

github-actions bot commented Dec 1, 2024

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

src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
Copy link
Contributor

@dcoudert dcoudert left a comment

Choose a reason for hiding this comment

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

Check your code to avoid redundant operations.

src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
@janmenjayap
Copy link
Contributor Author

Please note that for the following doctest:

One may set the ``coNP_certificate`` to be ``True``::

            sage: H = graphs.HexahedralGraph()
            sage: G = MatchingCoveredGraph(H)
            sage: G.is_brace(coNP_certificate=True)
            (True, None, None)
            sage: C = graphs.CycleGraph(6)
            sage: D = MatchingCoveredGraph(C)
            sage: D.is_brace(coNP_certificate=True)
            (False, [(0, 5, None), (2, 3, None)], {0, 1, 2})

It is passing in my local for the following two commands:

  1. ./sage -t src/sage/graphs/matching_covered_graph.py
  2. ./sage -t --long --warn-long 30.0 --random-seed=48323011685507437272567463462221430408 src/sage/graphs/matching_covered_graph.py

However, it is failing in the check for Build & Test / test-new (pull_request).

@dcoudert
Copy link
Contributor

dcoudert commented Dec 1, 2024

is the returned certificate valid ? if so, you must make the method or doctest more robust. This might be a side effect of some data structure (set, graph, etc.) that do not guaranty the order of the items.

@janmenjayap
Copy link
Contributor Author

janmenjayap commented Dec 1, 2024 via email

@user202729
Copy link
Contributor

Please note that for the following doctest:

One may set the ``coNP_certificate`` to be ``True``::

            sage: H = graphs.HexahedralGraph()
            sage: G = MatchingCoveredGraph(H)
            sage: G.is_brace(coNP_certificate=True)
            (True, None, None)
            sage: C = graphs.CycleGraph(6)
            sage: D = MatchingCoveredGraph(C)
            sage: D.is_brace(coNP_certificate=True)
            (False, [(0, 5, None), (2, 3, None)], {0, 1, 2})

It is passing in my local for the following two commands:

  1. ./sage -t src/sage/graphs/matching_covered_graph.py
  2. ./sage -t --long --warn-long 30.0 --random-seed=48323011685507437272567463462221430408 src/sage/graphs/matching_covered_graph.py

However, it is failing in the check for Build & Test / test-new (pull_request).

I don't think it's a very large issue. We have # random for that.

You can then do e.g. manual checking that the result is in some finite list in a TESTS:: block later.

@dcoudert
Copy link
Contributor

dcoudert commented Dec 7, 2024

You may implement a method to check that the returned certificate is valid and use it instead of printing the certificate.

:meth:`~sage.graphs.graph.Graph.is_bicritical`
"""
if self.is_bipartite():
raise ValueError('the input graph is bipartite')
Copy link
Contributor

Choose a reason for hiding this comment

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

why raising an error and not returning False ?

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 suppose it's more of that p → q logic statement.
Like given a nonbipartite matching covered graph (statement p), it is a brick if it is free of nontrivial tight cuts (statement q).

The definition includes the term nonbipartite. so if not p (that is either it is bipartite or not matching covered or both), then the statement is always true.

Also, in the case of bipartite if we return False, we don't have any useful coNP certificate. One may avoid this ValueError, just by checking if it is bipartite or not before checking if it is a brick.

I might be wrong. I will be glad to have your view.

Copy link
Contributor

Choose a reason for hiding this comment

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

Raising an error is not a good behavior here. If the issue is that you don't khave a coNP certificate, then you can return an extra boolean indicating that the input is bipartite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. That's also I have thought of. But the method is_brick() is solely defined for nonbipartite graphs and in that case, we have to return an extra boolean True showing that the graph is nonbipartite for each valid and useful input instances of the method, which seems a bit unnecessary.

src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Outdated Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Show resolved Hide resolved
src/sage/graphs/matching_covered_graph.py Show resolved Hide resolved
@@ -2663,6 +3260,14 @@ def remove_loops(self, vertices=None):

return

@doc_index('Bricks, braces and tight cut decomposition')
def tight_cut_decomposition(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you adding this method in this PR ? It would be better to finalize this PR and then add new material in another PR.

Copy link
Contributor Author

@janmenjayap janmenjayap Dec 27, 2024

Choose a reason for hiding this comment

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

Sure. I will add tight_cut_decomposition() in a different PR. In fact, that methods need some more work.

For now, with that method in hold, I have half implemented bricks_and_braces() (a small method), where actually one of the outputs (that is nontrivial_odd_component) of the above two methods (in this PR) are getting used. While doing so, I just saw that instead of returning a single nontrivial_odd_component, if we return all possible relevant nontrivial_odd_components in the above two methods, in other methods, the running time can be improved (even though the complexity remains the same theoretically).

H.delete_vertices([u, v])

if not H.is_matching_covered(list(matching - set([e]))):
if not coNP_certificate:
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 was just playing with some more examples and it turned out that I have not implemented the exception handling properly, yet.

For instance, if we take the original graph to be a Ladder Graph on 6 or more vertices, this check of whether that graph is matching covered raises an error instead of returning False, as H is not connected anymore. This one is to be checked and implemented.

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.

On Decompositions, Generation Methods and related concepts in the theory of Matching Covered Graphs
3 participants