Skip to content

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

@github-actions
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
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