[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] color of nodes according to a number

From: Tamas Nepusz
Subject: Re: [igraph] color of nodes according to a number
Date: Fri, 26 May 2017 10:26:40 +0200

1) the color of nodes i and j has to be the same if array[i] == array[j]
 Use a ClusterColoringPalette and a UniqueIdGenerator -- the UniqueIdGenerator will be used to assign numeric identifiers to each of the groups of items in 'array', while the ClusterColoringPalette will be used to generate colors for them:

>>> id_gen = UniqueIdGenerator()
>>> color_indices = [id_gen.add(value) for value in array]
>>> palette = ClusterColoringPalette(len(id_gen))
>>> colors = [palette[index] for index in color_indices]
>>> graph.vs["color"] = colors

2) the color of edge ij has to be given according to this criterion:
    if( array[i] <= array[j] ):
        color_of_edge_ij = color_of_node_j
        color_of_egde_ij = color of node_j
for edge in graph.es:
    u, v = edge.tuple
    edge["color"] = colors[u if array[u] <= array[v] else v]


reply via email to

[Prev in Thread] Current Thread [Next in Thread]