// Generated by CoffeeScript 1.10.0 (function() { window.Graph = Backbone.Model.extend({ defaults: { graph: { nodes: [], links: [] }, selected: null }, update: function(graph) { var index; index = {}; graph.nodes.forEach(function(n) { return index[n.id] = n; }); graph.links.forEach(function(l) { l.id = l.source + (l.directed ? '->' : '--') + l.target; l.source = index[l.source]; return l.target = index[l.target]; }); return this.set('graph', graph); }, select: function(id) { if (id === this.get('selected')) { return this.set('selected', null); } else { return this.set('selected', id); } } }); }).call(this);