简体   繁体   中英

Graph to draw community structure with graph-tool

I need to draw community structure of a brain network. Similar to the attached images. I am using graph-tool python tool box. Any help to create this would be highly appreciated.

https://www.ncbi.nlm.nih.gov/pubmed/19027073 . http://journal.frontiersin.org/article/10.3389/fnins.2016.00394/full

So if G is your graph, you can fit standard stochastic block model (ie the one without degree corrections) to obtain the community structure as:

state = gt.minimize_blockmodel_dl(G, deg_corr=False)

After this, you can use draw method which is simply a wrapper to the graph_draw() as:

state.draw(pos=g.vp.pos, output="my_graph.pdf")

Hope this helps.

vprop_int = g.new_vertex_property("int")
vprop[g1.vertex(0)] = 5
...

then you will get property for all vertice in your case, you might assign different number then when you are drawing

graph_draw(g, vertex_text=g.vertex_index, vertex_font_size=80
           , vertex_fill_color=vprop_int
           , edge_pen_width=20, edge_color=eprop_int
           , output_size=(20000, 20000), output="test.png")

the part you decide the color of vertice i put

vertex_fill_color=vprop_int

I hope this will help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM