modify calcDAG try to speed up
modify test
modify calcDAG to speed up