Auto add virtual root to input, fix minor bugs, add some utility funcs to graph class