MarkovSet is a Dictionary that contains keys pointing to WeighBags that contain objects and their probabilities. By parsing in a stream the Set "learns" what element can possibly follow another.

Part of MathLib, a diverse library of mathematical functions.

### MarkovSet.new(args, updateSeeds: false)

#### Arguments:

args |
A list of arrays that each represent one node in the set:
**[element, [next_elements], [weigths]]**
**next_elements** | The next node is searched by simple equality. If `nil` , this is a terminator node | **weights** | The array is normalized. If weigths is `nil` , equal weight is used. |
If args is `nil` , the set is created and may be trained by the other methods. |

updateSeeds |
If set to `true` , each element is always added to the seeds |

### MarkovSet.fill(length, stream)

#### Arguments:

length |
Number of items to read. |

stream |
A function or stream that returns items to read. |

### .read(prevkey, nextkey)

### .put(prevkey, nextkeys, weights, precision: 0.01)

Insert a node. Any old node is overwritten.

### .remove(key, nextKey)

### .next(prevKey)

Return a next item for the `arg`

value. If `arg`

is `nil`

, choose from seeds.

### .parse(pattern, length: inf)

Read `length`

items into the set from the stream.

Returns a stream that creates a markov chain.

### .parseFile(path, delimiter: $ , blockSize: 0, completionFunc)

### .parseIO(iostream, delimiter: $ , blockSize: 0, completionFunc, maxLength: 32)

### .seeds = collection

### .storeItemsOn(stream, itemsPerLine: 1)

### .writeHtml(argPath: "supermarkov", nPages: 5, pagelength: 60, style)

Julian Rohrhuber, 2004, 2007.