(mark_groups, clustering)
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.
Handles the mark_groups=... keyword argument in plotting methods of
    clusterings.
Handles the mark_groups = ... keyword argument in plotting methods of clusterings .
def _handle_mark_groups_arg_for_clustering(mark_groups, clustering):
    """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.
    """
    # Handle the case of mark_groups = True, mark_groups containing a list or
    # tuple of cluster IDs, and and mark_groups yielding (cluster ID, color)
    # pairs
    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__"):
        # Lists, tuples
        try:
            first = mark_groups[0]
        except Exception:
            # Hmm. Maybe not a list or tuple?
            first = None
        if first is not None:
            # Okay. Is the first element of the list a single number?
            if isinstance(first, int):
                # Yes. Seems like we have a list of cluster indices.
                # Assign color indices automatically.
                group_iter = ((group, color) for color, group in enumerate(mark_groups))
            else:
                # No. Seems like we have good ol' group-color pairs.
                group_iter = mark_groups
        else:
            group_iter = mark_groups
    elif hasattr(mark_groups, "__iter__"):
        # Iterators etc
        group_iter = mark_groups
    else:
        group_iter = {}.iteritems()

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

    return cluster_index_resolver()
def _handle_mark_groups_arg_for_clustering ( mark_groups , clustering ) : # Handle the case of mark_groups = True, mark_groups containing a list or # tuple of cluster IDs, and and mark_groups yielding (cluster ID, color) # pairs 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__" ) : # Lists, tuples try : first = mark_groups [ 0 ] except Exception : # Hmm. Maybe not a list or tuple? first = None if first is not None : # Okay. Is the first element of the list a single number? if isinstance ( first , int ) : # Yes. Seems like we have a list of cluster indices. # Assign color indices automatically. group_iter = ( ( group , color ) for color , group in enumerate ( mark_groups ) ) else : # No. Seems like we have good ol' group-color pairs. group_iter = mark_groups else : group_iter = mark_groups elif hasattr ( mark_groups , "__iter__" ) : # Iterators etc group_iter = mark_groups else : group_iter = { } . iteritems ( ) def cluster_index_resolver ( ) : for group , color in group_iter : if isinstance ( group , int ) : group = clustering [ group ] yield group , color return cluster_index_resolver ( )