How to plot Community-based graph using igraph for python -


i have graph extract communities using louvain-algorithm implementation:

clusters = g.community_multilevel( weights=none, return_levels=false) 

i apply different colouring each community:

new_cmap = ['#'+''.join([random.choice('0123456789abcdef') x in range(6)]) z in range(len(clusters))] colors = {v: new_cmap[i] i, c in enumerate(clusters) v in c} g.vs["color"] = [colors[e] e in g.vs.indices] 

finally plot graph:

visual_style["layout"] = g.layout_fruchterman_reingold(weights=g.es["weight"], maxiter=1000, area=n ** 3, repulserad=n ** 3) igraph.plot(g, **visual_style) 

i bellow result: enter image description here

  • my question :

    1. instead of mixed-up graph, there way using specific layout, plot every of 4 community grouped itself? separate every community in different area of graph increasing visibility of inner structure few edges higher betweenness-centrality connecting communities?

    2. i have used contract-vertices function helped me visualise, oversimplification group every community in single point , doesn't allow visualise inner structure of each community. using 'contract-vertices' in best way?

thanks.

i found solution being drastically increase weight of edges belong community (3 times number of vertices in below example):

clusters = g.community_multilevel( weights=none, return_levels=false) member = clusters.membership new_cmap = ['#'+''.join([random.choice('0123456789abcdef') x in range(6)]) z in range(len(clusters))]  vcolors = {v: new_cmap[i] i, c in enumerate(clusters) v in c} g.vs["color"] = [vcolors[v] v in g.vs.indices]  ecolors = {e.index: new_cmap[member[e.tuple[0]]] if member[e.tuple[0]]==member[e.tuple[1]] else "#e0e0e0" e in g.es} eweights = {e.index: (3*g.vcount()) if member[e.tuple[0]]==member[e.tuple[1]] else 0.1 e in g.es} g.es["weight"] = [eweights[e.index] e in g.es] g.es["color"] = [ecolors[e] e in g.es.indices]  visual_style["layout"] = g.layout_fruchterman_reingold(weights=g.es["weight"], maxiter=500, area=n ** 3, repulserad=n ** 3) igraph.plot(g, **visual_style) 

i assume need 'drastically increase' edges weight within communities due fact graph composed of vertices represent less 2% of number of vertices have more 80% of edges connected them though belong different communities. in below graph many edges outside communities in light grey:

enter image description here


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -