Refactor init() and calculate().

Do the initialization of the type parameter in the root class, and make
calculate() return the node map.