A graph problem in JS using Underscore and jQuery.