Skip to content

Commit

Permalink
Some docs I missed earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
ifsmirnov committed Feb 6, 2018
1 parent 26a58b9 commit 6d4329b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions doc/array.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ yields edges of a random graph with 10 vertices and 20 edges, possibly containin
* Example:
```cpp
TArray<std::string>::randomf(
10,
[](const char* pattern) { return rnd.next(pattern); },
"[a-z]{5}")
10,
[](const char* pattern) { return rnd.next(pattern); },
"[a-z]{5}")
```
yields an array of 10 strings of 5 letters each.
Expand Down
8 changes: 8 additions & 0 deletions doc/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ All graph generators return graph with sorted edges to make tests more human-rea
* Description: first a random tree on *n* vertices with given *elongation* (see [tree docs](/tree.md)) is generated. Then remaining *m*-*n*+*1* edges are added. One endpoint of an edge is selected at random. The second is a result of jumping to a tree parent of the first endoint a random number of times, from 0 to *spread*, inclusive.
* If the graph is directed, the direction of each edge is selected at random, unless it is acyclic: in this case the direction of all edges is down the tree.

#### randomBipartite(int n1, int n2, int m)
* Returns: a random bipartite graph with *n1* vertices in one part, *n2* vertices in another part and *m* edges. Vertices from *1* to *n1* belong to the first part.
* Available modifiers: *connected*, *allowMulti*.

#### completeBipartite(int n1, int n2)
* Returns: a complet bipartite graph with *n1* vertices in one part and *n2* vertices in another part. Vertices from *1* to *n1* belong to the first part.
* Available modifiers: none.

### Modifiers
All options are unset by default. If the generator contradicts some option (like *randomStretched*, which always produces a connected graph), it is ignored.
#### connected(bool value = true)
Expand Down
6 changes: 5 additions & 1 deletion doc/random.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Default initialized *Random* is seeded with some hardware-generated random value
* pattern followed by *{n}* is the same as the pattern repeated *n* times;
* pattern followed by *{l,r}* is the same as the pattern repeated random number of times from *l* to *r*, inclusive;
* "|" character yields either a pattern to its left or the pattern to its right equiprobably;
* several "|" characters between patterns yield any pattern between them equiprobably, e.g. *(a|b|c){100}* yields a string of length 100 with almost equal number of *a*'s, *b*'s and *c*'s;
* several "|" characters between patterns yield any pattern between them equiprobably, e.g. *(a|b|c|z){100}* yields a string of length 100 with almost equal number of *a*'s, *b*'s, *c*'s and *z*'s;
* parentheses "()" are used for grouping.
* examples:
* `rnd.next("[1-9][0-9]{1,2}")`: random 2- or 3-digit number (note that the distribution on numbers is not uniform);
Expand All @@ -54,6 +54,10 @@ Default initialized *Random* is seeded with some hardware-generated random value
* Returns: random element of a range or of a container, respectively.
* Note: *Container* may be *any* STL container, including *std::set*. In general case the runtime of this function is *O(container.size())*. However, if *Iterator* is a random-access iterator, the runtime is constant.

#### template<typename N> size_t nextByDistribution(const std::vector<N>& distribution)
* Returns: a random integer from *0* to *distribution.size() - 1*, where probability of *i* is proportional to *distribution[i].
* Example: *rnd.nextByDistribution({1, 1, 100})* will likely return 2, but roughly each 50-th iteration will return 0 or 1.

### Seeding
#### void seed(uint32_t seed)
#### void seed(const std::vector&lt;uint32_t>& seed)
Expand Down
3 changes: 3 additions & 0 deletions doc/tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Note that all generators return trees with sorted edges to make tests more human
* Returns: a complete *k*-ary tree with *size* vertices.
* Numeration: parent of vertex *i* is *(i-1)/k*, *0* is root.

#### Tree fromPruferSequence(const Array& code)
* Returns: a tree with given [Prüfer sequence](https://en.wikipedia.org/wiki/Pr%C3%BCfer_sequence). The tree contains *code.size() + 2* vertices.

### Tree methods

#### Tree& shuffle()
Expand Down

0 comments on commit 6d4329b

Please sign in to comment.