这是“政治博客圈和2004年美国大选”中的政治博客网络图,但是边缘束是使用随机块模型确定的(注:下图与图相同(即,布局和数据相同))。 Tiago论文中的5-我只是在上面放了一个黑色背景 。
边缘配色方案与Adamic和Glance的原始论文中的相同,即每个节点对应一个博客URL,颜色反映政治取向,红色代表保守派,蓝色代表自由派。橙色边从自由派博客到保守派博客,紫色边从保守派到自由派(参见Adamic和Glance中的图1)。
need-to-insert-img
原图:
部分代码片段:
0) and (v.in_degree() > 0) )\ng.purge_vertices()\n\nprint(g.num_vertices(), g.num_edges())\n\n#use 1->Republican, 2->Democrat\nred_blue_map = {1:(1,0,0,1),0:(0,0,1,1)}\nplot_color = g.new_vertex_property('vector')\ng.vertex_properties['plot_color'] = plot_color\nfor v in g.vertices():\n plot_color[v] = red_blue_map[g.vertex_properties['value'][v]]\n\n \n\ngt.graph_draw(g, pos=pos, vertex_fill_color=g.vertex_properties['plot_color'],\n vertex_color=g.vertex_properties['plot_color'],\n edge_control_points=cts,\n vertex_size=10,\n vertex_text=g.vertex_properties['label'],\n vertex_text_rotation=g.vertex_properties['text_rot'],\n vertex_text_position=1,\n vertex_font_size=9,\n edge_color=g.edge_properties['edge_color'],\n vertex_anchor=0,\n bg_color=[0,0,0,1],\n output_size=[4024,4024],\n output='polblogs_blockmodel.png')","classes":[]}" data-cke-widget-upcasted="1" data-cke-widget-keep-attr="0" data-widget="codeSnippet"># -*- coding: utf-8 -*- import graph_tool.all as gt import math g = gt.collection.data["polblogs"] # http://www2.scedu.unibo.it/roversi/SocioNet/AdamicGlanceBlogWWW.pdf print(g.num_vertices(), g.num_edges()) #reduce to only connected nodes g = gt.GraphView(g,vfilt=lambda v: (v.out_degree() > 0) and (v.in_degree() > 0) ) g.purge_vertices() print(g.num_vertices(), g.num_edges()) #use 1->Republican, 2->Democrat red_blue_map = {1:(1,0,0,1),0:(0,0,1,1)} plot_color = g.new_vertex_property('vector') g.vertex_properties['plot_color'] = plot_color for v in g.vertices(): plot_color[v] = red_blue_map[g.vertex_properties['value'][v]] gt.graph_draw(g, pos=pos, vertex_fill_color=g.vertex_properties['plot_color'], vertex_color=g.vertex_properties['plot_color'], edge_control_points=cts, vertex_size=10, vertex_text=g.vertex_properties['label'], vertex_text_rotation=g.vertex_properties['text_rot'], vertex_text_position=1, vertex_font_size=9, edge_color=g.edge_properties['edge_color'], vertex_anchor=0, bg_color=[0,0,0,1], output_size=[4024,4024], output='polblogs_blockmodel.png')
网友评论