refactor node and graph related things into their own classes

also allow executing with jruby