Cuthill-MckeeCuthill-McKee is the de-factorde facto standard for what you want to do. If you wanted to play with this method, there's an easy to use-to-use implementation of the algorithm (and its reverse) in the BOOST Graph libraryBoost Graph Library (BGL), and the documentation contains examples how to use it.