本文整理汇总了Python中Graph.createNode方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.createNode方法的具体用法?Python Graph.createNode怎么用?Python Graph.createNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.createNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import createNode [as 别名]
def main(files):
cfg = Config()
graph = Graph(cfg)
for file in files:
print file
qaida = readFromXmlPrePhrase(file)
for parta in qaida:
for matra in parta:
for i in range(len(matra)-1):
graph.createEdge(
graph.createNode(matra[i]),
graph.createNode(matra[i+1]))
# for node in graph.nodes: print node
# for edge in graph.edges: print edge
# dist = Distort(graph=graph, argo=DistortRandomSimple)
dist = Distort(graph=graph, argo=DistortRandomWeight)
patt = []
i = 0
while True:
e = dist.run()
s = EdgesToStr(e)
if s not in patt:
patt.append(s)
print "%3d %s" % (i, s)
i += 1
示例2: range
# 需要导入模块: import Graph [as 别名]
# 或者: from Graph import createNode [as 别名]
for qaida in aQaida:
# QaidaEdge's array makes one parta pattern,
# parta array makes qaida's all parta..
edges = qaida.createQaidaEdges(3, 1)
# !!! now, start link .... .... ...... !!!
for j in range(len(edges)):
print " - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
for k in range(len(edges[j])): # qaidaedge array
# print edges[j][k]
graph.createEdge(graph.createNode(edges[j][k].previous), graph.createNode(edges[j][k].next))
for e in graph.edges:
print "%20s ----> %20s : %f" % (e.previous.name, e.next.name, e.weight)
print " --- %s" % dumpEdge(graph.distortPattern())
print " --- %s" % dumpEdge(graph.distortPattern())
print " --- %s" % dumpEdge(graph.distortPattern())
print " --- %s" % dumpEdge(graph.distortPattern())
print " --- %s" % dumpEdge(graph.distortPattern())
print " --- %s" % dumpEdge(graph.distortPattern())
print " --- %s" % dumpEdge(graph.distortPattern())
print " --- %s" % dumpEdge(graph.distortPattern())
print " --- %s" % dumpEdge(graph.distortPattern())