本文整理汇总了Python中igraph.Graph.vs['hands']方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.vs['hands']方法的具体用法?Python Graph.vs['hands']怎么用?Python Graph.vs['hands']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类igraph.Graph
的用法示例。
在下文中一共展示了Graph.vs['hands']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enumerate
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import vs['hands'] [as 别名]
pid_to_id = {}
names = ''
for index, (pid, page) in enumerate(pid_to_page.items()):
id_to_page[index] = page
pid_to_id[pid] = index
# g.add_vertex()
label = page.name
pos = label.find('(')
if pos >= 0:
label = label[:pos]
g.add_vertex(name=label)
names += ',' + label
logger.debug('link_num=%s' % (len(links),))
g.add_edges(
[[
pid_to_id[r['id_from']],
pid_to_id[r['id_to']]
] for r in links])
g.vs['hands'] = [len(v.neighbors()) for v in g.vs]
method_to_comm = get_method_to_comm(g)
# for method, c in method_to_comm.items():
# save_cluster(c, method, box=(10000, 10000))
# cl = as_clustering_if_not(c)
# logger.debug(
# 'len = %s, mod = %s %s' % (
# len(cl.subgraphs()),
# cl.q,
# method))
示例2: enumerate
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import vs['hands'] [as 别名]
names = ''
for index, (pid, page) in enumerate(pid_to_page.items()):
index_to_page[index] = page
pid_to_index[pid] = index
# g.add_vertex()
label = page.name
pos = label.find('(')
if pos >= 0:
label = label[:pos]
g.add_vertex(name=label)
names += ',' + label
logger.debug('link_num=%s' % (len(links),))
g.add_edges(
[[
pid_to_index[pair[0]],
pid_to_index[pair[1]]
] for pair in holder.get_multi_pairs()])
g.vs['hands'] = [
index_to_page[i].linknum
for i, v in enumerate(g.vs)]
method_to_comm = get_method_to_comm(g)
for method, c in method_to_comm.items():
save_cluster(c, method, box=(10000, 10000))
cl = as_clustering_if_not(c)
logger.debug(
'len = %s, mod = %s %s' % (
len(cl.subgraphs()),
cl.q,
method))