def _handle_mark_groups_arg_for_clustering(mark_groups, clustering):
    "Handles the mark_groups=... keyword argument in plotting methods of\n    clusterings.\n\n    This is an internal method, you shouldn't need to mess around with it.\n    Its purpose is to handle the extended semantics of the mark_groups=...\n    keyword argument in the C{__plot__} method of L{VertexClustering} and\n    L{VertexCover} instances, namely the feature that numeric IDs are resolved\n    to clusters automatically.\n    "
    if (mark_groups is True):
        group_iter = ((group, color) for (color, group) in enumerate(clustering))
    elif isinstance(mark_groups, dict):
        group_iter = mark_groups.iteritems()
    elif (hasattr(mark_groups, '__getitem__') and hasattr(mark_groups, '__len__')):
        try:
            first = mark_groups[0]
        except:
            first = None
        if (first is not None):
            if isinstance(first, (int, long)):
                group_iter = ((group, color) for (color, group) in enumerate(mark_groups))
            else:
                group_iter = mark_groups
        else:
            group_iter = mark_groups
    elif hasattr(mark_groups, '__iter__'):
        group_iter = mark_groups
    else:
        group_iter = {}.iteritems()

    def cluster_index_resolver():
        for (group, color) in group_iter:
            if isinstance(group, (int, long)):
                group = clustering[group]
            (yield (group, color))
    return cluster_index_resolver()
Handles the mark_groups=... keyword argument in plotting methods of
clusterings.

This is an internal method, you shouldn't need to mess around with it.
Its purpose is to handle the extended semantics of the mark_groups=...
keyword argument in the C{__plot__} method of L{VertexClustering} and
L{VertexCover} instances, namely the feature that numeric IDs are resolved
to clusters automatically.
def _handle_mark_groups_arg_for_clustering(mark_groups, clustering):
    "Handles the mark_groups=... keyword argument in plotting methods of\n    clusterings.\n\n    This is an internal method, you shouldn't need to mess around with it.\n    Its purpose is to handle the extended semantics of the mark_groups=...\n    keyword argument in the C{__plot__} method of L{VertexClustering} and\n    L{VertexCover} instances, namely the feature that numeric IDs are resolved\n    to clusters automatically.\n    "
    if (mark_groups is True):
        group_iter = ((group, color) for (color, group) in enumerate(clustering))
    elif isinstance(mark_groups, dict):
        group_iter = mark_groups.iteritems()
    elif (hasattr(mark_groups, '__getitem__') and hasattr(mark_groups, '__len__')):
        try:
            first = mark_groups[0]
        except:
            first = None
        if (first is not None):
            if isinstance(first, (int, long)):
                group_iter = ((group, color) for (color, group) in enumerate(mark_groups))
            else:
                group_iter = mark_groups
        else:
            group_iter = mark_groups
    elif hasattr(mark_groups, '__iter__'):
        group_iter = mark_groups
    else:
        group_iter = {}.iteritems()

    def cluster_index_resolver():
        for (group, color) in group_iter:
            if isinstance(group, (int, long)):
                group = clustering[group]
            (yield (group, color))
    return cluster_index_resolver()