CoCalc Public FilesPlanar plot.sagewsOpen with one click!
Author: Dominique Laurain
Views : 59
Compute Environment: Ubuntu 18.04 (Deprecated)
# Draw example planar graph for vertices : split obtuse triangle into seven triangles Graph_1 = Graph({'A':['D','E','I'],'B':['F','D'],'C':['E','G'],'D':['A','B','F','I'],'E':['A','C','G','I'],'F':['B','D','G','I'],'G':['C','E','F','I'],'I':['A','D','E','F','G']},sparse=True) pos_dict = Graph_1.layout(layout="planar", save_pos=True) pl = Graph_1.plot(pos=pos_dict,vertex_size=1000,vertex_shape="h",graph_border=True) pl.show(axes=True,aspect_ratio=True) # Plot is driven by embedding Graph_1.is_planar(set_embedding=True) Graph_1.get_embedding() # Embedding ok : # {'A': ['E', 'I', 'D'], 'C': ['G', 'E'], 'B': ['D', 'F'], 'E': ['C', 'G', 'I', 'A'], 'D': ['A', 'I', 'F', 'B'], 'G': ['F', 'I', 'E', 'C'], 'F': ['B', 'D', 'I', 'G'], 'I': ['A', 'E', 'G', 'F', 'D']} Graph_1.faces() # Faces : # [[('F', 'B'), ('B', 'D'), ('D', 'A'), ('A', 'E'), ('E', 'C'), ('C', 'G'), ('G', 'F')], [('G', 'E'), ('E', 'I'), ('I', 'G')], [('I', 'A'), ('A', 'D'), ('D', 'I')], [('A', 'I'), ('I', 'E'), ('E', 'A')], [('G', 'I'), ('I', 'F'), ('F', 'G')], [('E', 'G'), ('G', 'C'), ('C', 'E')], [('F', 'D'), ('D', 'B'), ('B', 'F')], [('I', 'D'), ('D', 'F'), ('F', 'I')]]
True {'A': ['E', 'I', 'D'], 'C': ['G', 'E'], 'B': ['D', 'F'], 'E': ['C', 'G', 'I', 'A'], 'D': ['A', 'I', 'F', 'B'], 'G': ['F', 'I', 'E', 'C'], 'F': ['B', 'D', 'I', 'G'], 'I': ['A', 'E', 'G', 'F', 'D']} [[('F', 'B'), ('B', 'D'), ('D', 'A'), ('A', 'E'), ('E', 'C'), ('C', 'G'), ('G', 'F')], [('G', 'E'), ('E', 'I'), ('I', 'G')], [('I', 'A'), ('A', 'D'), ('D', 'I')], [('A', 'I'), ('I', 'E'), ('E', 'A')], [('G', 'I'), ('I', 'F'), ('F', 'G')], [('E', 'G'), ('G', 'C'), ('C', 'E')], [('F', 'D'), ('D', 'B'), ('B', 'F')], [('I', 'D'), ('D', 'F'), ('F', 'I')]]