123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import networkx as nx
- import matplotlib.pyplot as plt
- def show_system(system_graph):
- '''
- Show one system by pyplot.
- :param system_graph:
- :return:
- '''
- g=nx.Graph()
- for e in system_graph.system_edges:
- #g.add_edge(e.start_vertex.system_data.source_id,e.end_vertex.system_data.source_id)
- g.add_edge(e.start_vertex, e.end_vertex)
- nx.draw(g,with_labels=True)
- plt.show()
- def show_floor(floor_graph):
- '''
- Show all system in this floor
- :param floor_graph:
- :return:
- '''
- for s in floor_graph.system_graphs:
- show_system(s)
- def show_project(project_graph):
- '''
- Show all grouped system in project.
- :param project_graph:
- :return:
- '''
- for g in project_graph.groupedsystemgraphs:
- show_groupedsystem(g)
- def show_groupedsystem(grouped_system_graph):
- '''
- Show one grouped system.
- :param grouped_system_graph:
- :return:
- '''
- g=nx.Graph()
- for s in grouped_system_graph.systemgraphs:
- for e in s.system_edges:
- g.add_edge(e.start_vertex, e.end_vertex)
- for e in grouped_system_graph.connectedges:
- g.add_edge(e.start_vertex, e.end_vertex)
- nx.draw(g,with_labels=True)
- plt.show()
|