-
-
Save ashnur/af62ecc560ed167248f47b9037e99955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns combo-network.graph) | |
(defn seed | |
[init-nodes-count] | |
(range 0 init-nodes-count)) | |
;; initial-contacts (select-random seed-nodes) | |
;; secondary-contact (select) | |
(defn grow-step [graph] | |
(let [nodes (:nodes graph) | |
edges (:edges graph)] | |
{:nodes (conj nodes (+ (apply max nodes) 1)) | |
:edges edges})) | |
(defn grow [& args] | |
(apply (fn step [pred x] | |
(let [y (grow-step x)] | |
(js/console.log (pred y) y) | |
(if (pred y) | |
(fn [] (step pred y)) | |
y))) args)) | |
(defn grow-graph-to-size [graph final-size] | |
(trampoline grow #(> final-size (count (:nodes %))) graph)) | |
(defn graph [init-nodes-count final-size] | |
(let [seed-nodes (seed init-nodes-count)] | |
(grow-graph-to-size {:nodes seed-nodes :edges []} final-size))) | |
(js/console.log (graph 1 5)) ;; {:nodes (4 3 2 1 0) , :edges []} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment