@classmethod
def FromAttribute(cls, graph, attribute, intervals=None, params=None):
    'Creates a vertex clustering based on the value of a vertex attribute.\n\n        Vertices having the same attribute will correspond to the same cluster.\n\n        @param graph: the graph on which we are working\n        @param attribute: name of the attribute on which the clustering\n            is based.\n        @param intervals: for numeric attributes, you can either pass a single\n            number or a list of numbers here. A single number means that the\n            vertices will be put in bins of that width and vertices ending up\n            in the same bin will be in the same cluster. A list of numbers\n            specify the bin positions explicitly; e.g., C{[10, 20, 30]} means\n            that there will be four categories: vertices with the attribute\n            value less than 10, between 10 and 20, between 20 and 30 and over 30.\n            Intervals are closed from the left and open from the right.\n        @param params: additional parameters to be stored in this object.\n\n        @return: a new VertexClustering object\n        '
    from bisect import bisect

    def safeintdiv(x, y):
        'Safe integer division that handles None gracefully'
        if (x is None):
            return None
        return int((x / y))

    def safebisect(intervals, x):
        'Safe list bisection that handles None gracefully'
        if (x is None):
            return None
        return bisect(intervals, x)
    try:
        _ = iter(intervals)
        iterable = True
    except TypeError:
        iterable = False
    if (intervals is None):
        vec = graph.vs[attribute]
    elif iterable:
        intervals = list(intervals)
        vec = [safebisect(intervals, x) for x in graph.vs[attribute]]
    else:
        intervals = float(intervals)
        vec = [safeintdiv(x, intervals) for x in graph.vs[attribute]]
    idgen = UniqueIdGenerator()
    idgen[None] = None
    vec = [idgen[i] for i in vec]
    return cls(graph, vec, None, params)
Creates a vertex clustering based on the value of a vertex attribute.

Vertices having the same attribute will correspond to the same cluster.

@param graph: the graph on which we are working
@param attribute: name of the attribute on which the clustering
    is based.
@param intervals: for numeric attributes, you can either pass a single
    number or a list of numbers here. A single number means that the
    vertices will be put in bins of that width and vertices ending up
    in the same bin will be in the same cluster. A list of numbers
    specify the bin positions explicitly; e.g., C{[10, 20, 30]} means
    that there will be four categories: vertices with the attribute
    value less than 10, between 10 and 20, between 20 and 30 and over 30.
    Intervals are closed from the left and open from the right.
@param params: additional parameters to be stored in this object.

@return: a new VertexClustering object
@classmethod
def FromAttribute(cls, graph, attribute, intervals=None, params=None):
    'Creates a vertex clustering based on the value of a vertex attribute.\n\n        Vertices having the same attribute will correspond to the same cluster.\n\n        @param graph: the graph on which we are working\n        @param attribute: name of the attribute on which the clustering\n            is based.\n        @param intervals: for numeric attributes, you can either pass a single\n            number or a list of numbers here. A single number means that the\n            vertices will be put in bins of that width and vertices ending up\n            in the same bin will be in the same cluster. A list of numbers\n            specify the bin positions explicitly; e.g., C{[10, 20, 30]} means\n            that there will be four categories: vertices with the attribute\n            value less than 10, between 10 and 20, between 20 and 30 and over 30.\n            Intervals are closed from the left and open from the right.\n        @param params: additional parameters to be stored in this object.\n\n        @return: a new VertexClustering object\n        '
    from bisect import bisect

    def safeintdiv(x, y):
        'Safe integer division that handles None gracefully'
        if (x is None):
            return None
        return int((x / y))

    def safebisect(intervals, x):
        'Safe list bisection that handles None gracefully'
        if (x is None):
            return None
        return bisect(intervals, x)
    try:
        _ = iter(intervals)
        iterable = True
    except TypeError:
        iterable = False
    if (intervals is None):
        vec = graph.vs[attribute]
    elif iterable:
        intervals = list(intervals)
        vec = [safebisect(intervals, x) for x in graph.vs[attribute]]
    else:
        intervals = float(intervals)
        vec = [safeintdiv(x, intervals) for x in graph.vs[attribute]]
    idgen = UniqueIdGenerator()
    idgen[None] = None
    vec = [idgen[i] for i in vec]
    return cls(graph, vec, None, params)