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

Add configuration model #796

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

tapanih
Copy link
Contributor

@tapanih tapanih commented Jan 28, 2023

Added a possibility to generate a random graph using a configuration model. The result is a random graph with a given degree sequence. The Rust library can additionally generate degree sequences from any Distribution.

@CLAassistant
Copy link

CLAassistant commented Jan 28, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 4032314256

  • 91 of 122 (74.59%) changed or added relevant lines in 3 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.2%) to 96.802%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rustworkx-core/src/generators/configuration_model.rs 56 87 64.37%
Files with Coverage Reduction New Missed Lines %
src/shortest_path/all_pairs_bellman_ford.rs 2 98.88%
src/shortest_path/all_pairs_dijkstra.rs 2 98.54%
Totals Coverage Status
Change from base Build 4028447013: -0.2%
Covered Lines: 13835
Relevant Lines: 14292

💛 - Coveralls

Copy link
Collaborator

@IvanIsCoding IvanIsCoding left a comment

Choose a reason for hiding this comment

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

Thanks for contributing this! This is neat.

I will have to read the paper to give a better review of the code, but I do have a question about graph realization right off the bat

Some(seed) => Pcg64::seed_from_u64(seed),
None => Pcg64::from_entropy(),
};
let degree_sequence = match core_generators::DegreeSequence::new(degree_sequence) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need to check this degree sequence with Erdős–Gallai? Or do you return a graph that might not be a simple graph?

Copy link
Contributor Author

@tapanih tapanih Jan 30, 2023

Choose a reason for hiding this comment

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

The graph may not be simple. The generator in NetworkX works in a similar fashion: https://networkx.org/documentation/stable/reference/generated/networkx.generators.degree_seq.configuration_model.html#configuration-model

At some point, it would be good to add a parameter to DegreeSequence constructors that specifies that the degree sequence must be graphical.

@IvanIsCoding
Copy link
Collaborator

IvanIsCoding commented Jan 29, 2023

Also, you'll have to update api.rst to include the new function you added

}
if sum % 2 == 1 {
let index = rng.gen_range(0..length);
degree_sequence[index] += 1;
Copy link
Contributor Author

@tapanih tapanih Jan 30, 2023

Choose a reason for hiding this comment

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

This felt like a "pragmatic" way of ensuring that the sum is even. However, this could lead to out-of-distribution values in the sequence which is probably confusing for the user. Not sure how to fix it. Probably just retry n times?

@mtreinish mtreinish added this to the 0.14.0 milestone Jun 1, 2023
@IvanIsCoding IvanIsCoding modified the milestones: 0.14.0, 0.15.0 Oct 18, 2023
@IvanIsCoding IvanIsCoding removed this from the 0.15.0 milestone Jun 22, 2024
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.

5 participants