This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

## 2018-04-14

## Channels

- # beginners (53)
- # cider (10)
- # cljs-dev (23)
- # cljsrn (25)
- # clojure (68)
- # clojure-italy (4)
- # clojure-spec (25)
- # clojure-uk (7)
- # clojurebridge-ams (1)
- # clojurescript (10)
- # cursive (20)
- # datomic (21)
- # duct (4)
- # fulcro (1)
- # graphql (4)
- # hoplon (1)
- # java (7)
- # luminus (9)
- # off-topic (111)
- # om-next (2)
- # onyx (14)
- # re-frame (3)
- # reagent (9)
- # shadow-cljs (182)
- # test-check (32)
- # tools-deps (53)
- # uncomplicate (1)
- # vim (94)
- # yada (2)

I think I've asked this before, but I'm writing some (non-shrinking) generators that rely on generating uniformly random numbers. Is there any way to get a uniformly random number generated?

I don't think it needs to be. It's a generator for a graph's adjacency matrix. It is the probability that one vertex is adjacent to another.

So an argument could be made that the most simple graph is the fully disconnected one

Are you actually trying to generate probabilities, or trying to generate the graph itself?

Generate the graph itself. I generate an adjacency matrix like this:

```
[[0.0 0.0 0.0 0.0]
[P.1 0.0 0.0 0.0]
[P.2 P.3 0.0 0.0]
[P.4 P.5 P.6 0.0]]
```

Where `P1`

-`P6` are probabilities. This adjacency matrix ends up representing a random DAG.

I map this probability matrix into a matrix where the values can be `true`

/`false` based on whether or not the probability is above `0.5`

I have another generator that takes a DAG and generates a random topological ordering from it. It's also based on random number generation using `gen/choose`

, but the range is small enough that it should be uniform.

Both are looking good:

```
(let [g (gen/generate (gen-directed-acyclic-graph (seq "ABCD")))
t (frequencies (gen/sample (gen-topological-ordering g) 1000))]
(when (not-empty g)
(println t)
(
``` (loom.graph/digraph g))))

Produced: https://www.dropbox.com/s/q0rkqfy7z0vffs6/png223331814782198197.png?dl=0
and the topological orderings:
```
{[C B D A] 122,
[D B A C] 117,
[B D A C] 115,
[D B C A] 127,
[B D C A] 135,
[C D B A] 132,
[D C B A] 137,
[B C D A] 115}
```