Break mst into multiple MSTs by removing one node i.

    Parameters
    ----------
    mst : symmetrical square matrix
    i : index of the mst where to break

    Returns
    -------
    list of dictionarys ('mst' and 'strokes' are the keys)

def break_mst(mst, i):
    """
    Break mst into multiple MSTs by removing one node i.

    Parameters
    ----------
    mst : symmetrical square matrix
    i : index of the mst where to break

    Returns
    -------
    list of dictionarys ('mst' and 'strokes' are the keys)
    """
    for j in range(len(mst['mst'])):
        mst['mst'][i][j] = 0
        mst['mst'][j][i] = 0
    _, components = scipy.sparse.csgraph.connected_components(mst['mst'])
    comp_indices = {}
    for el in set(components):
        comp_indices[el] = {'strokes': [], 'strokes_i': []}
    for i, comp_nr in enumerate(components):
        comp_indices[comp_nr]['strokes'].append(mst['strokes'][i])
        comp_indices[comp_nr]['strokes_i'].append(i)

    mst_wood = []

    for key in comp_indices:
        matrix = []
        for i, line in enumerate(mst['mst']):
            line_add = []
            if i not in comp_indices[key]['strokes_i']:
                continue
            for j, el in enumerate(line):
                if j in comp_indices[key]['strokes_i']:
                    line_add.append(el)
            matrix.append(line_add)
        assert len(matrix) > 0, \
            ("len(matrix) == 0 (strokes: %s, mst=%s, i=%i)" %
             (comp_indices[key]['strokes'], mst, i))
        assert len(matrix) == len(matrix[0]), \
            ("matrix was %i x %i, but should be square" %
             (len(matrix), len(matrix[0])))
        assert len(matrix) == len(comp_indices[key]['strokes']), \
            (("stroke length was not equal to matrix length "
              "(strokes=%s, len(matrix)=%i)") %
             (comp_indices[key]['strokes'], len(matrix)))
        mst_wood.append({'mst': matrix,
                         'strokes': comp_indices[key]['strokes']})
    return mst_wood