当前位置: 首页>>代码示例>>Python>>正文


Python Graph.createNode方法代码示例

本文整理汇总了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
开发者ID:branch-not-equal,项目名称:QaidaGraph,代码行数:31,代码来源:Distort.py

示例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())
开发者ID:branch-not-equal,项目名称:QaidaGraph,代码行数:33,代码来源:link.py


注:本文中的Graph.createNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。