Skip to content

Instantly share code, notes, and snippets.

Created Dec 13, 2013
What would you like to do?
Create random network on Cytoscape.
; Node Names - sequence of integers.
(def nodenames (take 500 (range)))
; Create new network and register it to manager
(def newnet(. (. cyAppAdapter getCyNetworkFactory) createNetwork))
(.. newnet (getRow newnet) (set "name" "Random Network Created by Clojure Script"))
(.. cyAppAdapter (getCyNetworkManager) (addNetwork newnet))
; Create nodes
(doseq [nodename nodenames]
(.. newnet (getRow (. newnet addNode))
(set "name" (str nodename))))
; Add random edges
(def nodes (. newnet getNodeList))
(doseq [node nodes]
(. newnet addEdge node (rand-nth nodes) false))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment