Adds .gitignore.
Small improvement to error checking in node.js.
Refactors graph.js to improve Graph constructors.