printlogo
http://www.ethz.ch/index_EN
CBRG - Computational Biochemistry Research Group
 
print
  

How to produce random and standard graphs

Random graphs

Random graphs, in the sense that the edges are chosen randomly between the set of all possible edges, can be generated with the command:

RandomGraph(10,20);

where the first argument (in this example 10) indicates the number of nodes to be generated and the second (in the example 20) is the number of edges. If the second argument is omitted, n ln n edges are generated. If both arguments are omitted, then the number of nodes is chosen to be a random number between 5 and 20. To avoid generating the same random graph again and again, the random number generator may be initialized with the command   SetRand( integer ). For example:

SetRand( 12345 );
RandomGraph( 20 );

will generate a random graph with 20 nodes, and 20*ln(20) edges (59 edges).

Predefined graphs

There are some common graphs which are accessible from the Darwin library.

BipartiteGraph(n1,n2,e); 

A bipartite graph with n1+n2 vertices and e edges connecting between the first set of vertices (n1) and the second set (n2). The edges are otherwise randomly chosen. A complete bipartite graph can be generated by requesting it to have n1n2 edges, i.e. BipartiteGraph(n1,n2,n1*n2);.

Complete(n); 

A complete graph with n vertices and n(n-1)/2 edges.

Regular polyhedra

The regular polyhedra (composed of identical faces) in 3-dimensional euclidean space.

CubeGraph();
Cube. 
TetrahedronGraph(); 

Tetrahedron.

HexahedronGraph(); 

Regular hexahedron. (another name for the cube graph).

OctahedronGraph();

Regular octahedron.

IcosahedronGraph(); 

Regular icosahedron.

DodecahedronGraph(); 

Regular dodecahedron.

PetersenGraph(); 

A graph having ten vertices and fifteen edges, which may be drawn as a pentagram (5 spike star) disposed symmetrically within a pentagon, each vertex of the latter being joined by an edge to the nearest vertex of the former.

RegularGraph(n,e); 

A graph having n vertices and ne/2 edges, where each vertex has e incident edges. ne must be even. The edges are otherwise randomly chosen. 

 

Wichtiger Hinweis:
Diese Website wird in älteren Versionen von Netscape ohne graphische Elemente dargestellt. Die Funktionalität der Website ist aber trotzdem gewährleistet. Wenn Sie diese Website regelmässig benutzen, empfehlen wir Ihnen, auf Ihrem Computer einen aktuellen Browser zu installieren. Weitere Informationen finden Sie auf
folgender Seite.

Important Note:
The content in this site is accessible to any browser or Internet device, however, some graphics will display correctly only in the newer versions of Netscape. To get the most out of our site we suggest you upgrade to a newer browser.
More information

© 2012 ETH Zurich | Imprint | Disclaimer | 4 October 2005
top