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


Python Graph.newGraphFromEdgesMap方法代码示例

本文整理汇总了Python中Graph.Graph.newGraphFromEdgesMap方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.newGraphFromEdgesMap方法的具体用法?Python Graph.newGraphFromEdgesMap怎么用?Python Graph.newGraphFromEdgesMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph.Graph的用法示例。


在下文中一共展示了Graph.newGraphFromEdgesMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start_samu_threadings_floyd

# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import newGraphFromEdgesMap [as 别名]
def start_samu_threadings_floyd(edges_list, threads_number, accident_location):
    if len(accident_location) == 3:
        del accident_location[:1]
    else:
        raise

    index = 0
    for edges_map in edges_list:
        # Build the graph first them send the graph to the class ambulance
        graph_mapping=Graph.newGraphFromEdgesMap(edges_map, len(edges_map) - 1)
        list_of_ambulances.append(AmbulancePositionSystem(graph=graph_mapping,
            name="ambulance_ambulancia_" + str(index),
            emergency=accident_location[index],
            localizations=[edges_map[:1][0][0], edges_map[:1][0][1]],
            algorithm_type='FLOYD'))
        index = index + 1

    # Create new threads
    index = 0
    for ambulance in list_of_ambulances:
        threads_list.append(SamuOperatorSlave(ambulance, index, "operador_samu_" + str(index)))
        index = index + 1

    # Start new Threads
    for i in range(threads_number):
        print('Reconstruction path, threading number {} working....'.format(threads_list[i].tid))
        threads_list[i].start()

    # Wait for all threads to complete
    for t in threads_list:
        t.join()

    return list_of_ambulances
开发者ID:tonussi,项目名称:grafos,代码行数:35,代码来源:app.py

示例2: testConvertEdgesListToGraph

# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import newGraphFromEdgesMap [as 别名]
    def testConvertEdgesListToGraph(self):
        edges_map = [[ 2 , 0 , 44 ],
                     [ 2 , 1 , 57 ],
                     [ 3 , 1 , 73 ],
                     [ 3 , 2 , 56 ],
                     [ 4 , 0 , 74 ],
                     [ 4 , 1 , 51 ],
                     [ 4 , 2 , 66 ],
                     [ 4 , 3 , 71 ],
                     [ 5 , 2 , 70 ],
                     [ 5 , 4 , 62 ],
                     [ 6 , 0 , 34 ],
                     [ 6 , 1 , 74 ],
                     [ 6 , 2 , 58 ],
                     [ 6 , 3 , 80 ],
                     [ 6 , 4 , 87 ],
                     [ 6 , 5 , 76 ],
                     [ 2,  4 , 0  ]]
        newGraph = Graph.newGraphFromEdgesMap(edges_map, len(edges_map))

        # this test the graph constrution from a mapping of edges with its costs
        for index in range(len(edges_map) - 1):
            v1, v2, cost = edges_map[index]
            self.assertTrue(cost == newGraph.vertexAdjacencies(v1).get(v2).getcost(),
                            'test graph\'s consistence in costs and coesion in connections')
开发者ID:tonussi,项目名称:grafos,代码行数:27,代码来源:GraphTest.py

示例3: start_samu_threadings_dijkstra

# 需要导入模块: from Graph import Graph [as 别名]
# 或者: from Graph.Graph import newGraphFromEdgesMap [as 别名]
def start_samu_threadings_dijkstra(edges_list, threads_number, accident_location):
    if len(accident_location) == 7:
        del accident_location[:1]
    else:
        raise

    index = 0
    for edges_map in edges_list:
        # Build the graph first them send the graph to the class ambulance
        graph_mapping=Graph.newGraphFromEdgesMap(edges_map, len(edges_map))
        list_of_ambulances.append(AmbulancePositionSystem(graph=graph_mapping,
            name="ambulance_ambulancia_" + str(index),
            # for each file we send the emegency localization to the APS builder
            emergency=accident_location[index],
            # each file have we build the localizations extracting the last row
            localizations=[edges_map[:1][0][0], edges_map[:1][0][1]],
            # than we choose a strategy called DIJKSTRA to process the data
            algorithm_type='DIJKSTRA'))
        index = index + 1

    # Create new threads
    index = 0
    for ambulance in list_of_ambulances:
        threads_list.append(SamuOperatorSlave(ambulance, index, "operador_samu_" + str(index)))
        index = index + 1

    # Start new Threads
    for i in range(threads_number):
        print('Reconstruction path, threading number {} working....'.format(threads_list[i].tid))
        threads_list[i].start()

    # Wait for all threads to complete
    for t in threads_list:
        t.join()

    return list_of_ambulances
开发者ID:tonussi,项目名称:grafos,代码行数:38,代码来源:app.py


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