def draw_graph(BR,endpoint,workbook): import networkx import matplotlib.pyplot as plt import fetch import layout lables = {} lables["BR"]= "BR" graph_obj = networkx.DiGraph() nodes = fetch.get_motes(BR,endpoint) graph_obj.add_node("BR") for node in nodes: graph_obj.add_node(node) edges = fetch.get_routes(BR,endpoint) for edge in edges: edge = edge.split('->') source = edge[1] destination = edge[0] Name = get_name(edge[0],workbook) lables[edge[0]]= Name if source == destination: graph_obj.add_edge("BR",destination) else: graph_obj.add_edge(source,destination) pos = layout.get_pos(graph_obj) networkx.draw_networkx_labels(graph_obj, pos,labels=lables,font_color="black", font_size=8,font_weight='bold') networkx.draw(graph_obj, pos,nodelist = ["BR"], node_color="Blue", node_size=2000,node_shape="p") networkx.draw(graph_obj, pos,nodelist = nodes, node_color="green",node_size=1000,node_shape="s") plt.show()
def get_motes_with_name(BR,endpoint,workbook): import fetch motes = fetch.get_motes(BR,endpoint) for mote in motes: Name = get_name(mote,workbook) print("Mote IPv6 : " + mote + "\tMote Name : " + Name) print "\n"