systemgraph_display.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import networkx as nx
  2. import matplotlib.pyplot as plt
  3. def show_system(system_graph):
  4. '''
  5. Show one system by pyplot.
  6. :param system_graph:
  7. :return:
  8. '''
  9. g=nx.Graph()
  10. for e in system_graph.system_edges:
  11. #g.add_edge(e.start_vertex.system_data.source_id,e.end_vertex.system_data.source_id)
  12. g.add_edge(e.start_vertex, e.end_vertex)
  13. nx.draw(g,with_labels=True)
  14. plt.show()
  15. def show_floor(floor_graph):
  16. '''
  17. Show all system in this floor
  18. :param floor_graph:
  19. :return:
  20. '''
  21. for s in floor_graph.system_graphs:
  22. show_system(s)
  23. def show_project(project_graph):
  24. '''
  25. Show all grouped system in project.
  26. :param project_graph:
  27. :return:
  28. '''
  29. for g in project_graph.groupedsystemgraphs:
  30. show_groupedsystem(g)
  31. def show_groupedsystem(grouped_system_graph):
  32. '''
  33. Show one grouped system.
  34. :param grouped_system_graph:
  35. :return:
  36. '''
  37. g=nx.Graph()
  38. for s in grouped_system_graph.systemgraphs:
  39. for e in s.system_edges:
  40. g.add_edge(e.start_vertex, e.end_vertex)
  41. for e in grouped_system_graph.connectedges:
  42. g.add_edge(e.start_vertex, e.end_vertex)
  43. nx.draw(g,with_labels=True)
  44. plt.show()