Skip to content

Conversation

@RaoulLuque
Copy link
Member

@RaoulLuque RaoulLuque commented May 23, 2025

Closes #796.

As discussed in the Issue #796, this should be fixed with the version bump of Quickcheck to 1.0, but until then, this should fix the issue.

We simply use an interface exposed by the Gen trait which is a subtrait of RngCore, which exposes the next_u64 function.

As a result of the Quickchecks running properly there are now two tests which fail:

failures:
    maximal_cliques_matches_ref_impl
    test_steiner_tree

I will try to fix these as well and incorporate the changes into this PR to not make the CI fail a bunch of times.

@starovoid
Copy link
Collaborator

Hmm, interesting... now we need to figure out why these tests are failing.

@RaoulLuque
Copy link
Member Author

RaoulLuque commented May 25, 2025

It seems like regarding the Bron Kerbosch Max Cliques algorithm, the authors were of the impression that the algorithm works (in a consistent way) on both directed and undirected graphs. This is however wrong. Thus I adjusted the tests and docs accordingly.

Now the Docstring of Bron Kerbosch states that it can be called on directed graphs, but only if the directed graph is symmetric.

I also cleaned up the tests.

(The Steiner Tree Quickcheck(s) still fail and I'll take a look at that next)

@RaoulLuque
Copy link
Member Author

Okay, similar to what was going on with Max Cliques, the Steiner Tree authors assumed that the algorithm would work on all undirected graphs (or at least did not specify that it does not). Instead, the algorithm (or rather the current implementation) only works on connected graphs. I adapted the quickcheck accordingly to skip graphs which are not connected.

I am not sure whether I like this solution, since a lot of arbitrary graphs should not be connected. Instead we could also call the steiner tree function on the biggest connected component. I would like some input on that :)

Also I cleaned up the Docstring again 🌞

@starovoid
Copy link
Collaborator

I would like some input on that

It's not worth changing the implementation of steiner_tree right now, but in the next major release, we'll replace panicked operations with checked methods and return Result. Well, or we can refine the algorithm to steiner_forest, this is a debatable question - I'll open the issue a little later.

For now, lets limit to your documentation and quickcheck corrections. And please move all the changes regarding steiner_tree in a separate PR to make the change history more atomic.

@starovoid starovoid added this to the 0.8.2 milestone May 26, 2025
@RaoulLuque
Copy link
Member Author

Okay, I think I was not specific enough. I was asking for some input regarding the test setup we want to chose. Since currently we simply disregard all non connected graphs in the quickcheck, I was wondering how we could change that. I would edit the quickcheck to execute on all connected components (of size greater than 1) of the arbitrary graph and perform the checks there.

Regarding the separate PR, what do you mean by that? I only have Documentation changes in both the maximal_cliques and steiner_tree modules

@starovoid
Copy link
Collaborator

I would edit the quickcheck to execute on all connected components (of size greater than 1) of the arbitrary graph and perform the checks there.

Oh, I guess I didn't read the question carefully. Yes, you can do testing for each connected component separately, if you wish. But even if disconnected graphs are simply discarded, the test will not lose much reliability, since the relative number of such input graphs is small. But in the future, this behavior will most likely be changed, and we will start checking that the algorithm returns something like Err(SteinerError::GraphDisconnected) on disconnected graphs.

@starovoid
Copy link
Collaborator

starovoid commented May 26, 2025

Regarding the separate PR, what do you mean by that? I only have Documentation changes in both the maximal_cliques and steiner_tree modules

I just suggest moving the steiner_tree's docs and steiner_tree quickcheck's changes to new PR.

@RaoulLuque
Copy link
Member Author

RaoulLuque commented May 26, 2025

Regarding the separate PR, what do you mean by that? I only have Documentation changes in both the maximal_cliques and steiner_tree modules

I just suggest moving the steiner_tree's docs and steiner_tree quickcheck's changes to new PR.

Ah, I see 👍 And what about Maximal Cliques? Because I thought I'd do it all in one because otherwise the CI Will break if we update the quickcheck but don't update the quickchecks for Steiner tree and Maximal cliques

@starovoid
Copy link
Collaborator

Ah, I see 👍 And what about Maximal Cliques? Because I thought I'd do it all in one because otherwise the CI Will break if we update the quickcheck but don't update the quickchecks for Steiner tree and Maximal cliques

I'll merge PR with steiner_tree fixes before that, so the CI won't break.
Regarding Maximal Cliques, I'll look at them today or tomorrow, I want to think over one of my ideas...

@RaoulLuque
Copy link
Member Author

I'll merge PR with steiner_tree fixes before that, so the CI won't break.
Regarding Maximal Cliques, I'll look at them today or tomorrow, I want to think over one of my ideas...

Ahh, sry🤦‍♂️😅 I'll create a new PR then and also a new one for the maximal cliques changes 😁

@RaoulLuque
Copy link
Member Author

RaoulLuque commented May 27, 2025

Okay, I created two other PRs for Maximal Cliques and Steiner Trees respectively since I thought they'd both be split off anyways. See #800 and #801 . Also I reset this PR to only include the Quickcheck randomness change

github-merge-queue bot pushed a commit that referenced this pull request May 28, 2025
…rical (#800)

Splitted off from #798. See
there for details
github-merge-queue bot pushed a commit that referenced this pull request May 29, 2025
…rly support disconnected graphs (#801)

Splitted off from #798. See
there for details

---------

Co-authored-by: Egor Starovoitov <52821033+starovoid@users.noreply.github.com>
@starovoid starovoid force-pushed the quickcheck_random01_bug branch from d2cc9bd to 187960a Compare May 29, 2025 16:19
@starovoid starovoid added this pull request to the merge queue May 29, 2025
Merged via the queue into petgraph:master with commit 1125c33 May 29, 2025
10 checks passed
@github-actions github-actions bot mentioned this pull request May 29, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jun 6, 2025
## 🤖 New release

* `petgraph`: 0.8.1 -> 0.8.2 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.8.2](https://github.com/petgraph/petgraph/compare/petgraph@v0.8.1...petgraph@v0.8.2)
- 2025-06-06

### Bug Fixes

- Ford Fulkerson sometimes Panics on StableGraphs
([#793](#793))
- Run Maximal Cliques Quickcheck only on Digraphs which are symmetrical
([#800](#800))
- Run Steiner Tree Quickcheck on the connected components to properly
support disconnected graphs
([#801](#801))
- Quickcheck random01 function only outputs 0
([#798](#798))

### Documentation

- Specify that Acyclic::try_udpate_edge may add an edge
([#770](#770))
- Update remove_node doc comment in graphmap.rs
([#663](#663))
- Add examples to minimum spanning tree functions
([#808](#808))
- Minimal typo fix in comments
([#803](#803))
- Update docs.rs ([#807](#807))
- Add note about `StableGraph::edge_indices` behaviour
([#812](#812))
- Clarification of references to nodes and V (refresh #358)
([#814](#814))
- Fix link and mention Dfs and Bfs as special case in examples
([#816](#816))
- Unify algo docs
([#815](#815))

### New Features

- *(parser)* allow parsing graphs from Dot/Graphviz files
([#653](#653))
- Implement `DataMap` for `GraphMap` graphs
([#776](#776))
- Add Johnson's algorithm
([#741](#741))
- Add algorithm to find bridge edges
([#590](#590))

### Performance

- Reuse queue allocation in `maximum_matching` main loop
([#817](#817))

### Refactor

- Fix new clippy warnings
([#791](#791))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: starovoid <prototyperailgun@gmail.com>
RaoulLuque pushed a commit to RaoulLuque/petgraph that referenced this pull request Jun 18, 2025
## 🤖 New release

* `petgraph`: 0.8.1 -> 0.8.2 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.8.2](https://github.com/petgraph/petgraph/compare/petgraph@v0.8.1...petgraph@v0.8.2)
- 2025-06-06

### Bug Fixes

- Ford Fulkerson sometimes Panics on StableGraphs
([petgraph#793](petgraph#793))
- Run Maximal Cliques Quickcheck only on Digraphs which are symmetrical
([petgraph#800](petgraph#800))
- Run Steiner Tree Quickcheck on the connected components to properly
support disconnected graphs
([petgraph#801](petgraph#801))
- Quickcheck random01 function only outputs 0
([petgraph#798](petgraph#798))

### Documentation

- Specify that Acyclic::try_udpate_edge may add an edge
([petgraph#770](petgraph#770))
- Update remove_node doc comment in graphmap.rs
([petgraph#663](petgraph#663))
- Add examples to minimum spanning tree functions
([petgraph#808](petgraph#808))
- Minimal typo fix in comments
([petgraph#803](petgraph#803))
- Update docs.rs ([petgraph#807](petgraph#807))
- Add note about `StableGraph::edge_indices` behaviour
([petgraph#812](petgraph#812))
- Clarification of references to nodes and V (refresh petgraph#358)
([petgraph#814](petgraph#814))
- Fix link and mention Dfs and Bfs as special case in examples
([petgraph#816](petgraph#816))
- Unify algo docs
([petgraph#815](petgraph#815))

### New Features

- *(parser)* allow parsing graphs from Dot/Graphviz files
([petgraph#653](petgraph#653))
- Implement `DataMap` for `GraphMap` graphs
([petgraph#776](petgraph#776))
- Add Johnson's algorithm
([petgraph#741](petgraph#741))
- Add algorithm to find bridge edges
([petgraph#590](petgraph#590))

### Performance

- Reuse queue allocation in `maximum_matching` main loop
([petgraph#817](petgraph#817))

### Refactor

- Fix new clippy warnings
([petgraph#791](petgraph#791))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: starovoid <prototyperailgun@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quickcheck random_01 function only outputting 0 makes all QuickCheck Arbitrary Graphs (almost) complete

2 participants