Skip to content

RandomGraph ​

A uniformly-chosen simple undirected Graph with n vertices and exactly m edges.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageRandomGraph✓
RandomGraph({n, m})n vertices, m edges, no self-loop or parallel edge; unevaluated if m exceeds C(n, 2).
Typed signatures
TypePackageApplies
(any) random -> valuecombinatoricsalways

Domain: Collections

Details
  • Drawn by a Fisher-Yates shuffle of the C(n, 2) possible edges, taking the first m -- from the SAME seeded stream RandomInteger uses (see list-frontier.ts), reseeded together by SeedRandom. NOT Wolfram's own generator or algorithm: only VertexCount / EdgeCount / simplicity are guaranteed to match, the same divergence RandomInteger's own reference entry documents.

Examples

Basic #
live ↗
InLast([SeedRandom(9),VertexCount(RandomGraph([6,8]))])\mathrm{Last}(\bigl\lbrack\mathrm{SeedRandom}(9), \mathrm{VertexCount}(\mathrm{RandomGraph}(\bigl\lbrack6, 8\bigr\rbrack))\bigr\rbrack)Out66
About
Examples1
Checked againstWolfram Language 1 agree
CrosswalkWolfram Language

See also: RandomInteger, SeedRandom