Refactored undirected partitioning code and abstracted matrix-conversion functionality.