Skip to content
  1. API
  2. Ogma

Ogma.generate

Graph generators: functions to generate graphs with specific properties to test algorithms or display features.

ogma.generate.balancedTree([options])

Generates a simple balanced tree. Source: https://github.com/gka/randomgraph.js (license: public domain)

Arguments

  • options(optional) object
    • children(optional) number[=2] The number of children each node has.
    • height(optional) number[=3] The height of the tree.

Returns

ogma.generate.barabasiAlbert([options])

Generates a scale-free graph using preferntial-attachment mechanism. See Barabási–Albert model (Wikipedia)

Arguments

  • options(optional) object
    • m(optional) number[=1] M > 0 && m <= m0
    • m0(optional) number[=5] M0 > 0 && m0 < nodes
    • nodes(optional) number[=40] Number of nodes in the graph.
    • scale(optional) number[=100] Scale > 0 Scale of the space used by graph.

Returns

ogma.generate.erdosRenyi([options])

Generates an Erdős–Rényi graph. Call it with options (n,p) or (n,m). Source: https://github.com/gka/randomgraph.js (license: public domain) See Erdős–Rényi model (Wikipedia)

Arguments

  • options(optional) object
    • edges(optional) number The number of edges. If specified, p must not be specified.
    • nodes(optional) number[=20] The number of nodes.
    • p(optional) number[=0.1] The probability [0..1] of a edge between any two nodes. If specified, edges must not be specified.

Returns

ogma.generate.grid([options])

Generates a grid.

Arguments

  • options(optional) object
    • columnDistance(optional) number[=20] Distance between two columns of nodes
    • columns(optional) number[=4] The number of columns in the graph.
    • rowDistance(optional) number[=20] Distance between two rows of nodes
    • rows(optional) number[=4] The number of rows in the graph.
    • xmin(optional) number[=0] Start X coordinate for the grid
    • ymin(optional) number[=0] Start Y coordinate for the grid.

Returns

ogma.generate.path([options])

Generates a path.

Arguments

  • options(optional) object
    • length(optional) number[=5] Number of nodes.

Returns

ogma.generate.random([options])

Generates a random graph.

Arguments

  • options(optional) object
    • edges(optional) number[=10] Number of edges.
    • nodes(optional) number[=10] Number of nodes.

Returns

ogma.generate.randomTree([options])

Generates a random tree graph.

Arguments

  • options(optional) object
    • height(optional) number[=100] Height of the space to generate graph in
    • nodes(optional) number[=50] Number of nodes.
    • width(optional) number[=100] Width of the space to generate graph in
    • x(optional) number[=0] X of the center
    • y(optional) number[=0] Y of the center

Returns