rgn: creates a pseudo-random gn object


Creates a gn object which characteristics are randomly generated following the requirements of the call. Also positions illuminating the struture are proposed. Normally the produced gn is connected and without cycles. When the request is not possible, a warning is issued and some compatible option is provided. Using this function with the same set.seed starting point (and the same request) must produce identical gn.
Different types of gn are possible, their characteristics are given by arguments and pseudo-randomness. The type argument describes the structure of the links without care about the directions (as edges). The possible types are:


All nodes are aligned in a simple chain. So a relationship exists between nno and nar: nno = nar +1. Then nno will be drawn and nar deduced.


Like the chain type but a cycle is done with the relationships and nno = nar.


A hierarchy in the sense that the nodes can be disposed in a dendrogram structure; a particular case of this is the "star" structure when there only a branching point and the branches can comprise several nodes.


A hierarchy with two levels. For this specific case, 'nno' is the number of grouping levels and 'nar' is the number of terminal nodes for each grouping levels. Names of nodes are determined accordingly.


Not so simple to describe. Nodes are placed in the cell of square matrix and edges between nodes respects this structure. Arcs (including their number) are deduced from the node positions. Run some cases and you will understand seing the plot.


Four of the nodes are on the vertices of a tetrahedron and the other nodes are on its edges.


The maximum number of arcs, nno*(nno-1)/2, is provided. So nar will not be considered.

It is suggested that the seed be initialized before calling this function.


rgn(des, type="hier", nno=c(5, 10), nar=c(10, 20), nom=LETTERS,
	  dire="nat", lev=1)



Either the name or the description (preferably) for the newly created gn.


type of the gn, see the description field for details


range within which must be the number of nodes. Of course the range can be null, in that case the number of nodes is directly provided by the user. If not, it is drawn according to a uniform distribution (one integer from nno[1] to nno[2]).
Single values are repeated, e.g 5 becomes c(5,5). When audit, it gives the number of grouping nodes.


range within which must be the number of arcs. Similar to nno but nno being fixed nar must satisfy some constraints. These constraints may also depend on the type of /gn/.
When audit, it gives the number of nodes for each grouping nodes.
Single values are repeated, e.g 5 becomes c(5,5).


vector of names to be used for the nodes.


indicates the directions of the arcs between the nodes of a /gn/. There are two possibilities: "nat" for natural directions and "ran" for random under the restriction of no cycles.
For 'audit' the two choices are 'nat' for putting the first node as root else it will be the synthesis.
No effect when type ="ring".


maximum level of hierarchy; only used when type is "hier".


Of course if too much arcs are ordered, the probability of a non-cycle graph may be very small, even null.
To prevent this, a local nb\_trial limits the number of draws, if this limit is reached then a fatal error is issued.
For some type (e.g. "square"), the ordered number of arcs and nodes may not be respected for some reasons.


 g4n3k("RESET"); # needed only for R checking, to be forgotten
 r1 <- rgn(char2des("r1"), type="hier");
 r2 <- rgn(char2des("r2"), type="square");

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.