Cuthill-Mckee is the de-factor standard for what you want to do. If you wanted to play with this method, there's an easy to use implementation of the algorithm (and its reverse) in the BOOST Graph library, and the documentation contains examples how to use it.
Wolfgang Bangerth
- 56.8k
- 60
- 120