def CreateResultGraph(sorted_list):
D = nx.DiGraph()
for i in range(len(sorted_list)-1):
D.add_edge(sorted_list[i], sorted_list[i+1])
pos = nx.spring_layout(D)
val_map = {}
val_map[sorted_list[0]] = 'green'
val_map[sorted_list[len(sorted_list)-1]] = 'red'
values = [val_map.get(node, 'blue') for node in D.nodes()]
nx.draw(D, pos, with_labels = True, node_color =values)
#takes input from the file and creates a directed graph
topological_sort.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录