Convert dag algorithms
Update graph classes with changes in NetworkX 1.9

We should keep in sync with NetworkX 1.9, but it's probably easier to
convert the existing JS code first, rather than writing everything from
scratch.

I just updated these classes because it was simple.