Darwin Help

Back to Index

Graph_Rand

Function Graph_Rand - generate a random graph

Calling Sequence  Rand(Graph)
Graph_Rand(n,m)
Parameters
NameTypeDescription

n integeroptional number of nodes/vertices
m integeroptional number of edges
Return Type  Graph
Synopsis Generate a random undirected graph with n nodes and m edges. If m is not specified, then the number of edges is <= n*ln(n). If n is not specified, a random value between 5 and 20 is chosen. The Edges are all labelled with 0.
Examples
> Rand(Graph);
Graph(Edges(Edge(0,1,2),Edge(0,1,3),Edge(0,1,9),Edge(0,1,10),Edge(0,1,13),Edge(0
,1,15),Edge(0,2,4),Edge(0,2,7),Edge(0,2,8),Edge(0,2,9),Edge(0,2,10),Edge(0,2,13)
,Edge(0,2,14),Edge(0,2,15),Edge(0,2,16),Edge(0,3,5),Edge(0,3,10),Edge(0,3,11),Ed
ge(0,3,15),Edge(0,3,16),Edge(0,4,8),Edge(0,4,9),Edge(0,4,11),Edge(0,4,13),Edge(0
,4,14),Edge(0,5,7),Edge(0,5,8),Edge(0,5,11),Edge(0,6,8),Edge(0,6,10),Edge(0,6,12
),Edge(0,7,8),Edge(0,7,12),Edge(0,7,15),Edge(0,8,14),Edge(0,9,12),Edge(0,9,14),E
dge(0,9,16),Edge(0,10,11),Edge(0,11,12),Edge(0,11,13),Edge(0,11,15),Edge(0,12,14
),Edge(0,13,15),Edge(0,14,15)),Nodes(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16))
> Graph_Rand(3,4);
Graph(Edges(Edge(0,1,2),Edge(0,1,3),Edge(0,2,3)),Nodes(1,2,3))
See also BipartiteGraph,   Clique,   DrawGraph,   Edge,   EdgeComplement,   Edges,   FindConnectedComponents,   Graph,   InduceGraph,   MaxCut,   MaxEdgeWeightClique,   MST,   Nodes,   Path,   RegularGraph,   ShortestPath,   TetrahedronGraph,   VertexCover