Fix static_matrix.py for paths containing duplicate edges.