Fix bug in the constructor of TopologyGraph

- The constructor wasn't fixed during the previous refactoring
- Add helper methods
- Add more test cases