0
我在如何在這裏爲特定邊添加顏色而掙扎。比方說,我希望從邊緣到邊緣都有藍色,而不必重寫其他egdes?另外,我想知道如果我們可以有一個箭頭從一個節點指向另一個,而不是直線的邊緣?python networkX爲特定邊添加顏色
最佳
皮特
import networkx as nx
import matplotlib.pyplot as plt
G = nx.Graph()
class obj(object):
def __init__(self,N,P):
self.N = N
self.P = P
one = obj(1,0.5)
two = obj(2,0.4)
three = obj(3,0.3)
four = obj(4,0.2)
G.add_node(one.N)
G.add_node(two.N)
G.add_node(three.N)
G.add_node(four.N)
G.add_edge(one.N,two.N)
G.add_edge(two.N,three.N)
G.add_edge(two.N,four.N)
G.add_edge(four.N,one.N)
nx.draw(G)
plt.show()