Я думаю, что лучший инструмент для рисования сети - это библиотека networkx.В приведенном ниже коде я воспроизвожу 1/2 вашего примера всего за пару попыток, чтобы правильно выбрать цветовые узлы.
import networkx as nx
locations = {
0:(4,4),
1:(2,8),
2:(8,8),
3:(0,7),
4:(1,7),
5:(5,6),
6:(7,6),
7:(3,6),
8:(6,5),
}
edges = [
(0, 8, {'vehicle': '0'}),
(8, 6, {'vehicle': '0'}),
(6, 2, {'vehicle': '0'}),
(2, 5, {'vehicle': '0'}),
(5, 0, {'vehicle': '0'}),
(0, 7, {'vehicle': '1'}),
(7, 1, {'vehicle': '1'}),
(1, 4, {'vehicle': '1'}),
(4, 3, {'vehicle': '1'}),
(3, 0, {'vehicle': '1'}),
]
G=nx.DiGraph()
G.add_edges_from(edges)
plt.figure(figsize=(15,10))
#vehicle 0
temp = [e for e in edges if e[2]['vehicle'] == '0'] #temporary list that filters the path of vehicle 0
nx.draw_networkx_nodes(G, locations, nodelist=[x[0] for x in temp], node_color='b')
nx.draw_networkx_edges(G, locations, edgelist=temp,
width=2, edge_color='b', style='dashed')
#vehicle 1
temp = [e for e in edges if e[2]['vehicle'] == '1']
nx.draw_networkx_nodes(G, locations, nodelist=[x[0] for x in temp], node_color='r')
nx.draw_networkx_edges(G, locations, edgelist=temp,
width=2, edge_color='r', style='dashed')
#let's color the node 0 in black
nx.draw_networkx_nodes(G, locations, nodelist=[0], node_color='k')
# labels
nx.draw_networkx_labels(G, locations, font_color='w', font_size=12, font_family='sans-serif')
#print out the graph
plt.axis('off')
plt.show()
Это вывод: