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 uniform generator of random proper interval graphs #38354

Merged
merged 6 commits into from
Jul 24, 2024

Conversation

dcoudert
Copy link
Contributor

This PR implements the random proper interval graph generator proposed in

  • Toshiki Saitoh, Katsuhisa Yamanaka, Masashi Kiyomi, Ryuhei Uehara: Random Generation and Enumeration of Proper Interval Graphs. IEICE Trans. Inf. Syst. 93-D(7): 1816-1823 (2010)

The time complexity of the generator is in $O(n^3)$.

To check that the generator is uniform, we can use:

def test(n, steps=1000):
    from collections import Counter
    C = Counter()
    for _ in range(steps):
        G = graphs.RandomProperIntervalGraph(n)
        C[G.canonical_label().copy(immutable=True)] += 1
    L = list(C.values())
    import numpy
    print(f"different graphs = {len(L)}, avg number = {numpy.mean(L)}, standard deviation = {numpy.std(L)}")

and we get

sage: test(10, 100000)
different graphs = 2542, avg number = 39.33910306845004, standard deviation = 7.640982640860865
sage: test(15, 100000)
different graphs = 96384, avg number = 1.0375166002656042, standard deviation = 0.19487594733725658
sage: test(100, 100000)
different graphs = 100000, avg number = 1.0, standard deviation = 0.0

It seems that the generator is asymptotically uniform.

📝 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

Copy link

github-actions bot commented Jul 13, 2024

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

@dcoudert
Copy link
Contributor Author

@cyrilbouvier this generator can be useful for your tests.

Copy link
Contributor

@fchapoton fchapoton left a comment

Choose a reason for hiding this comment

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

nice addition, thanks

@dcoudert
Copy link
Contributor Author

Thanks for the review.

@vbraun vbraun merged commit df88d06 into sagemath:develop Jul 24, 2024
20 of 21 checks passed
@mkoeppe mkoeppe added this to the sage-10.5 milestone Jul 25, 2024
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.

4 participants