Skip to content

Conversation

@DanielLacina
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented Sep 4, 2025

CLA assistant check
All committers have signed the CLA.

@DanielLacina
Copy link
Contributor Author

Apologies if I did anything wrong. This is my first PR.

Copy link
Collaborator

@miratepuffin miratepuffin left a comment

Choose a reason for hiding this comment

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

Couple innitial thoughts

use crate::prelude::*;

#[test]
fn test_erdos_renyi_small_graph() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wanna add some tests where you add 100,000 nodes or somethign else reasonably big.
Also a good idea to look at adding some tests for graphs which already have nodes and edges present.

for other_id in all_ids.iter() {
if id != other_id && rng.gen::<f64>() < p {
latest_time += 1;
graph
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we consider that an edge may already be present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could I delete an edge if its present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ig ignore it

#[test]
fn test_erdos_renyi_small_graph() {
let graph = Graph::new();
let n_nodes = 5;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could also add some tests to see if the graphs have expected stats e.g. density

Copy link
Contributor Author

Choose a reason for hiding this comment

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

like a hypothesis test?

@ljeub-pometry
Copy link
Collaborator

You might also be interested in this paper: https://kim246.wwwdns.kim.uni-konstanz.de/publications/bb-eglrn-05.pdf

In section IIa they have an algorithm for generating these graphs without looping over all pairs of nodes which is going to be a lot more efficient for sparse graphs. Note that you can parallelise it by dividing the edges into chunks as the geometric distribution is memory-free.

@DanielLacina
Copy link
Contributor Author

appreciate it

@DanielLacina
Copy link
Contributor Author

@LJeub Would what you suggested only be like an extra performant feature that a user can specify?

@DanielLacina
Copy link
Contributor Author

DanielLacina commented Jan 19, 2026

@ljeub-pometry

@ljeub-pometry
Copy link
Collaborator

@LJeub Would what you suggested only be like an extra performant feature that a user can specify?

This is an optimisation that should almost always be faster in realistic scenarios (it reduces the number of random variables generated to O(m) where m is the actual number of edges in the final graph rather than O(n^2)). However, you do not need to implement it for this first version. We can change it later and also benchmark the two implementations. Just thought you might be interested...

Copy link
Collaborator

@ljeub-pometry ljeub-pometry left a comment

Choose a reason for hiding this comment

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

  • need to fix the error handling to actually return errors
  • probably better if this doesn't take a graph as input

Copy link
Collaborator

@ljeub-pometry ljeub-pometry left a comment

Choose a reason for hiding this comment

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

You are basically there, just need to add some ? to actually return the errors.

Copy link
Collaborator

@ljeub-pometry ljeub-pometry left a comment

Choose a reason for hiding this comment

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

this should be the last change before merging it 🤞

Copy link
Collaborator

@ljeub-pometry ljeub-pometry left a comment

Choose a reason for hiding this comment

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

This looks ok for a first version. We need to expose this in python as well.

@ljeub-pometry ljeub-pometry changed the title implemented erdos renyl model generation implemented erdos reny model generation Jan 26, 2026
@ljeub-pometry ljeub-pometry changed the title implemented erdos reny model generation implemented Erdos-Renyi model generation Jan 26, 2026
@ljeub-pometry ljeub-pometry merged commit aee2d61 into Pometry:master Jan 26, 2026
2 checks passed
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.

4 participants