def plot_module_dependency_graph(graph):
"""
Plot a graph of specified yang modules. this function is used to plot
both the full dependency graph of all yang modules in the DB, or a
subgraph of dependencies for a specified module
:param graph: Graph to be plotted
:return: None
"""
# fixed_pos = { 'ietf-interfaces':(0.01,0.01) }
# fixed_nodes = fixed_pos.keys()
# pos = nx.spring_layout(graph, iterations=200,
# pos=fixed_pos, fixed=fixed_nodes)
#pos = nx.circular_layout(graph)
pos = nx.spring_layout(graph, iterations=2000)
# Draw RFC nodes (yang modules) in red
nx.draw_networkx_nodes(graph, pos=pos, nodelist=prune_graph_nodes(graph, RFC_TAG), node_size=200,
node_shape='s', node_color='red', alpha=0.5, linewidths=0.5)
# Draw draft nodes (yang modules) in green
nx.draw_networkx_nodes(graph, pos=pos, nodelist=prune_graph_nodes(graph, DRAFT_TAG), node_size=200,
node_shape='o', node_color='green', alpha=0.5, linewidths=0.5)
# Draw unknown nodes (yang modules) in orange
nx.draw_networkx_nodes(graph, pos=pos, nodelist=prune_graph_nodes(graph, UNKNOWN_TAG), node_size=200,
node_shape='^', node_color='orange', alpha=1.0, linewidths=0.5)
# Draw edges in light gray (fairly transparent)
nx.draw_networkx_edges(graph, pos=pos, alpha=0.25, linewidths=0.1, arrows=False)
# Draw labels on nodes (modules)
nx.draw_networkx_labels(graph, pos=pos, font_size=10, font_weight='bold', alpha=1.0)
评论列表
文章目录