本文整理汇总了Python中igraph.Graph.vs['name']方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.vs['name']方法的具体用法?Python Graph.vs['name']怎么用?Python Graph.vs['name']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类igraph.Graph
的用法示例。
在下文中一共展示了Graph.vs['name']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildGraph
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import vs['name'] [as 别名]
def buildGraph(taskList, tsize, eList):
G = Graph(tsize + len(eList), directed=False)
G.vs['name'] = taskList.keys() + eList
G.vs['type'] = 0
G.vs[tsize:]['type'] = 1
for task, entityList in taskList.iteritems():
for entity, score in entityList.iteritems():
#a dict -- entity: score
#print task, entity
G[task, entity] = score
#print G
#print G.is_bipartite()
return G
示例2: extract_hash_tags_re
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import vs['name'] [as 别名]
def extract_hash_tags_re(s):
return set(re.findall('(?i)(?<=\#)\w+', s))
def seconds_since_epoch(date_str):
#fri oct 30 15:29:45 +0000 2015
timeSinceEpoch = int(time.mktime(time.strptime(date_str,"%a %b %d %H:%M:%S +0000 %Y")))
return timeSinceEpoch
#defining graph object
g= Graph()
#defining attributes for nodes and edges
g.vs['updated_ts'] = [] #seconds since epoch
g.vs['name'] = [] #list without nodes
g.es['updated_ts'] = [] #seconds since epoch
#Test vars
tryCount = 0
uCount = 0
keyErrorCount = 0
noJsonCount = 0
line_generator = open(input_file_str, 'r')
ft2 = open(output_file_str, 'w')
for line in line_generator:
try:
line_object = json.loads(line)
tryCount = tryCount + 1