Macaulay2 » Documentation
Packages » NautyGraphs :: generateRandomGraphs
next | previous | forward | backward | up | index | toc

# generateRandomGraphs -- generates random graphs on a given number of vertices

- Usage:
    `G = generateRandomGraphs(n, num)`
    `G = generateRandomGraphs(n, num, pq)`
    `G = generateRandomGraphs(n, num, pz)`
- Inputs:
  - n, an integer, the number of vertices of the graphs, must be positive (see caveat)
  - num, an integer, the number of random graphs to generate
  - pq, a rational number, the edge probability (between 0 and 1)
  - pq, a real number, the edge probability (between 0 and 1)
  - pz, an integer, the reciprocal of the edge probability (positive)
- Optional inputs:
  - RandomSeed => an integer, default value null, the specified random seed is passed to nauty
- Outputs:
  - G, a list, the randomly generated graphs

## Description

This method generates a specified number of random graphs with a given number of vertices. Note that some graphs may be isomorphic.

If the input $pq$ is included, then the edges are chosen to be included with probability $pq$. If the input $pz$ is included and is positive, then the edges are chosen to be included with probability $1/pz$.

    i1 : generateRandomGraphs(5, 5, RandomSeed => 314159)

    o1 = {DDO, Dx_, Dlw, Dx{, D_K}

    o1 : List

    i2 : generateRandomGraphs(5, 5)

    o2 = {DSG, DI?, Di?, D_O, D]w}

    o2 : List

    i3 : generateRandomGraphs(5, 5, RandomSeed => 314159)

    o3 = {DDO, Dx_, Dlw, Dx{, D_K}

    o3 : List

## Caveat

The number of vertices $n$ must be positive as nauty cannot handle graphs with zero vertices. Further, if the probability $pq$ is included, then it is rounded to a precision of one-hundred millionth.

## See also

- Example: Generating and filtering graphs
- generateRandomRegularGraphs -- generates random regular graphs on a given number of vertices

## Ways to use generateRandomGraphs:

- `generateRandomGraphs(ZZ,ZZ)`
- `generateRandomGraphs(ZZ,ZZ,QQ)`
- `generateRandomGraphs(ZZ,ZZ,RR)`
- `generateRandomGraphs(ZZ,ZZ,ZZ)`

## For the programmer

The object generateRandomGraphs is a method function with options.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/NautyGraphs.m2:1065:0.