Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created January 25, 2015 19:24
Show Gist options
  • Save ramnathv/14ce82ca63220952ea07 to your computer and use it in GitHub Desktop.
Save ramnathv/14ce82ca63220952ea07 to your computer and use it in GitHub Desktop.
Data Processing in Coffeescript
{"description":"Data Processing in Coffeescript","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"nodes.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true}
source target weight
sam pris 1
roy pris 5
roy sam 1
tully pris 5
tully kim 3
tully pat 1
tully mo 3
kim pat 2
kim mo 1
mo tully 7
mo pat 1
mo pris 1
pat tully 1
pat kim 2
pat mo 5
lee al 3
edges = tributary.data
edgeHash = {}
edges.forEach (d) ->
edgeHash[d.source + "-" + d.target] = d.weight
nodes = tributary.nodes
all = ({x: a.id, y: b.id} for a in nodes for b in nodes)
console.log(JSON.stringify(all[0]))
id followers following
sam 17 500
roy 83 80
pris 904 15
tully 7 5
kim 11 50
mo 80 85
pat 150 300
lee 38 7
al 12 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment