Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在MPLS单张图中可视化Networkx图形_Python_Networkx - Fatal编程技术网

Python 在MPLS单张图中可视化Networkx图形

Python 在MPLS单张图中可视化Networkx图形,python,networkx,Python,Networkx,我有一个车辆路径(VRP)模型输出,目前使用networkx可视化。此外,我想知道是否有一种方法可以使用诸如MPLS这样的包在真实世界的地图上进一步添加networkx图 下面是代码的networx部分和图表 def DrawNetwork(): G = nx.DiGraph() locations = DataProblem()._locations # print(locations) x = 0 for vehicle_id in vlist:

我有一个车辆路径(VRP)模型输出,目前使用networkx可视化。此外,我想知道是否有一种方法可以使用诸如MPLS这样的包在真实世界的地图上进一步添加networkx图

下面是代码的networx部分和图表

def DrawNetwork():
    G = nx.DiGraph()
    locations = DataProblem()._locations
    # print(locations)
    x = 0
    for vehicle_id in vlist:
        n = 0
        e = []
        node = []
        cl=PickupColor(x)

        for i in vehicle_id:
            G.add_node(i, pos=(locations[i][0], locations[i][1]))
            if n > 0:
                u = (vehicle_id[n - 1], vehicle_id[n])
                e.append(u)
                node.append(i)
                G.add_edge(vehicle_id[n - 1], vehicle_id[n])
                nx.draw(G, nx.get_node_attributes(G, 'pos'), nodelist=node, edgelist=e, with_labels=True,
                        node_color=cl, width=2, edge_color=cl,
                        style='dashed', font_color='w', font_size=12, font_family='sans-serif')
            n += 1
        x += 1
    # let's color the node 0 in black
    nx.draw_networkx_nodes(G, locations, nodelist=[0], node_color='k')
    plt.axis('on')
    # plt.show()