Skip to content

Instantly share code, notes, and snippets.

@saulshanabrook
Last active August 2, 2016 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saulshanabrook/49be0e801d102641bd179d37aeaba61c to your computer and use it in GitHub Desktop.
Save saulshanabrook/49be0e801d102641bd179d37aeaba61c to your computer and use it in GitHub Desktop.
run on github.com/saulshanabrook/search-in-clojure
(require '[search.core])
(require 'plumbing.fnk.schema)
(require 'plumbing.fnk.pfnk)
(require '[plumbing.graph :as g])
(require 'rhizome.viz)
(require '[search.utils :as utils])
(def g_ (:final-graph (g/run search.core/config->run-graph (search.core/->config {:graph-symbols '(search.graphs.problems.push-sr/plus-six-graph search.graphs.algorithms.genetic/graph)}))))
(defn graph-edges [g]
(for [[k node] g
parent (keys (plumbing.fnk.schema/explicit-schema-key-map (plumbing.fnk.pfnk/input-schema node)))]
[parent k]))
(defn save-graph [g_ name]
(def edges (graph-edges g_))
(def es (reduce (fn [m [parent child]] (assoc m parent (conj (or (parent m) #{}) child ))) {} edges))
(rhizome.viz/save-graph
(set (mapcat set (conj (vals es) (keys es))))
es
:node->descriptor (fn [n] {
:label n
:style (if (contains? (set (plumbing.fnk.pfnk/input-schema-keys g_)) n) "dashed" "solid")
})
:filename name))
(defn save-symbol [s]
(save-graph
(utils/symbol->value s)
(str (clojure.string/replace s "/" " ") ".png")))
(map
save-symbol
'(
search.graphs.algorithms.genetic/graph
search.graphs.algorithms.hill-climb/graph
search.graphs.problems.factorial/graph
search.graphs.problems.factorial/clojush-graph
search.graphs.problems.list/graph
search.graphs.problems.push-sr/double-graph
search.graphs.problems.push-sr/double-graph
search.graphs.push/graph
search.graphs.push-sr/graph
search.graphs.seq/graph
search.graphs.testcases/graph
)
)
;; (save-graph g_ "final.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment