Implement graph command (#448, #339)

- Refactor graph dumping to be more resuable
- Add graph command to CLI