Generation

Graph Generation

The Graph constructor can be used directly to generate random regular graphs:

julia> using Graft

julia> # Generate a graph with 10 vertices and no edges.
       Graph(10)
Graph(10 vertices, 0 edges, Symbol[] vertex properties, Symbol[] edge properties)

julia> # Generate a graph with 10 vertices and (approximately) 50 edges
       Graph(10, 50)
Graph(10 vertices, 48 edges, Symbol[] vertex properties, Symbol[] edge properties)

julia> # Generate a labelled graph with 10 vertices
       # labelled "1" through "10" and no edges
       Graph(10, map(string, 1 : 10))
Graph(10 vertices, 0 edges, Symbol[] vertex properties, Symbol[] edge properties)

julia> # Generate a labelled graph with 10 vertices
       # and (approximately) 50 edges
       Graph(10, map(string, 1 : 10), 50)
Graph(10 vertices, 49 edges, Symbol[] vertex properties, Symbol[] edge properties)

julia> # Generate graph from an adjacency matrix (may cause self loops)
       Graph(sprand(Int, 10, 10, .3))
Graph(10 vertices, 28 edges, Symbol[] vertex properties, Symbol[] edge properties)

completegraph can be used to generate a complete graph

julia> using Graft

julia> # Generate a complete graph with 10 vertices
       g = completegraph(10)
Graph(10 vertices, 90 edges, Symbol[] vertex properties, Symbol[] edge properties)

randgraph can be used to generate a complete graph, with floating point vertex and edge properties:

julia> using Graft

julia> # Generate a graph with 10 vertices, 90 edges, 2 vertex properties and 2 edge properties
       g = propgraph(10, [:p1,:p2], [:p1,:p2])
Graph(10 vertices, 90 edges, Symbol[:p1,:p2] vertex properties, Symbol[:p1,:p2] edge properties)

Detailed documentation:

# Graft.GraphMethod.

Build an empty graph with nv vertices

source

# Graft.GraphMethod.

Build a graph with nv vertices and (approximately)ne edges

source

# Graft.GraphMethod.

Build an empty graph with nv labelled vertices

source

# Graft.GraphMethod.

Build a graph with nv labelled vertices and (approximately)ne edges

source

# Graft.GraphMethod.

Build a graph using the input adjacency matrix

source

# Graft.completegraphFunction.

Build a complete graph with nv vertices

source

# Graft.randgraphFunction.

Build a graph with nv vertices and (approximately)ne edges

source

Build a graph with nv vertices and a random number of edges

source

# Graft.propgraphFunction.

Returns a small completegraph with properties(for doc examples)

source