(cls, graph, attribute, intervals=None, params=None)
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
Creates a vertex clustering based on the value of a vertex attribute.
Creates a vertex clustering based on the value of a vertex attribute .
def FromAttribute(cls, graph, attribute, intervals=None, params=None):
        """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
        """
        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)
def FromAttribute ( cls , graph , attribute , intervals = None , params = None ) : 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 )