本文整理汇总了Python中igraph.Graph.vs["age"]方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.vs["age"]方法的具体用法?Python Graph.vs["age"]怎么用?Python Graph.vs["age"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类igraph.Graph
的用法示例。
在下文中一共展示了Graph.vs["age"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Graph
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import vs["age"] [as 别名]
from igraph import Graph,plot
g = Graph([(0,1), (0,2), (0,3), (0,4), (5,2), (3,5), (5,0), (4,3), (3,6)],directed = True)
g.vs["name"] = ["Alice", "Bob", "Claire", "Dennis", "Esther", "Frank", "George"]
g.es["weight"] = [1,5,3,7,6,2,9,5,7]
g.vs["age"] = [25, 31, 18, 47, 22, 23, 50]
g.vs["gender"] = ["f", "m", "f", "m", "f", "m", "m"]
g.es["is_formal"] = [False, False, True, True, True, False, True, False, False]
layout = g.layout_fruchterman_reingold()
g.vs["label"] = g.vs["name"]
color_dict = {"m": "blue", "f": "pink"}
g.vs["color"] = [color_dict[gender] for gender in g.vs["gender"]]
# plot(g, layout = layout, bbox = (500, 500), margin = 20)
visual_style = {}
visual_style["vertex_size"] = 20
visual_style["vertex_color"] = [color_dict[gender] for gender in g.vs["gender"]]
visual_style["vertex_label"] = g.vs["name"]
visual_style["edge_width"] = [1 + 2 * int(is_formal) for is_formal in g.es["is_formal"]]
visual_style["layout"] = layout
visual_style["bbox"] = (300, 300)
visual_style["margin"] = 20
plot(g, **visual_style)
# print g