main = Graph(name="main") main.add_node(x=0.0, y=0.0, name="A", ll="bottom") main.add_node(x=1.0, y=0.0, name="B", ll="right") main.add_node(x=1.0, y=1.0, name="C", ll="top") main.add_node(x=0.0, y=1.0, name="D", ll="left") main.connect("A", "B", name="1", ll="top", la=45.0, lp=1.0) main.connect("B", "C", name="2", ll="top", la=45.0, lp=1.0) main.connect("C", "D", name="3", ll="top", la=45.0, lp=1.0) main.connect("D", "A", name="4", ll="top", la=45.0, lp=1.0) main.anchor_graph() print("Nodes are anchored:", main.anchored) print(main.general_info(), "\n") print(main) graphs = [] graphs.append(main) graphs.append(main.copy(-1.0, 0.0)) graphs[-1].reflect("y") graphs.append(main.copy(0.0, -1.0)) graphs[-1].reflect("x") CAN = Canvas(border_thickness=0.05, grid=True) for graph in graphs: CAN.add_graph(graph)
main = Graph(name = 'main') main.add_node(x=0.0, y=0.0, name = 'A', ll = 'bottom') main.add_node(x=1.0, y=0.0, name = 'B', ll = 'right') main.add_node(x=1.0, y=1.0, name = 'C', ll = 'top') main.add_node(x=0.0, y=1.0, name = 'D', ll = 'left') main.connect('A', 'B', name = '1', ll = 'top', la = 0.0) main.connect('B', 'C', name = '2', ll = 'top', la = 0.0) main.connect('C', 'D', name = '3', ll = 'top', la = 0.0) main.connect('D', 'A', name = '4', ll = 'top', la = 0.0) main.anchor_graph() print 'Nodes are anchored:', main.anchored print main.general_info(), '\n' print main graphs = [] displacement = 3.0 for i in range(2): graphs.append( main.copy(i * displacement, 0.0) ) graphs[-1].rotate(i * 45.0) CAN = Canvas(border_thickness = 0.05, grid = True) for graph in graphs: CAN.add_graph(graph) CAN.draw(save_file = 'test.pdf', display = True, print_information = False)
GRAPH.add_node(x=0.75, y=-1.5, name='B', ll='bottom') GRAPH.add_node(x=-1.5, y=-0.75, name='C', ll='left') GRAPH.add_node(x=1.5, y=-0.75, name='D', ll='right') GRAPH.add_node(x=-0.75, y=-1.5, name='E', ll='bottom') # Add Connections GRAPH.connect('A', 'B', name="I", directional=False, ll='top') GRAPH.connect('C', 'A', name="II", ll='top') GRAPH.connect('A', 'D', name="III", ll='top') GRAPH.connect('A', 'E', name="IV", directional=False, ll='top') GRAPH.connect('B', 'C', name="V", directional=False, ll='top') GRAPH.connect('D', 'B', name="VI", ll='bottom') GRAPH.connect('B', 'E', name="VII", ll='bottom') GRAPH.connect('C', 'D', name="VIII", directional=False, ll='top') GRAPH.connect('E', 'C', name="IX", ll='bottom') GRAPH.connect('D', 'E', name="X", directional=False, ll='top') GRAPH.anchor_graph() print('Nodes are anchored:', GRAPH.anchored) print(GRAPH.general_info(), '\n') print(GRAPH) # plot CAN = Canvas(border_thickness=0.05, grid=True) CAN.add_graph(GRAPH) CAN.draw(save_file='test.pdf', display=True, print_information=False)
main = Graph(name='main') main.add_node(x=0.0, y=0.0, name='A', ll='bottom') main.add_node(x=1.0, y=0.0, name='B', ll='right') main.add_node(x=1.0, y=1.0, name='C', ll='top') main.add_node(x=0.0, y=1.0, name='D', ll='left') main.connect('A', 'B', name='1', ll='top', la=45.0, lp=1.0) main.connect('B', 'C', name='2', ll='top', la=45.0, lp=1.0) main.connect('C', 'D', name='3', ll='top', la=45.0, lp=1.0) main.connect('D', 'A', name='4', ll='top', la=45.0, lp=1.0) main.anchor_graph() print('Nodes are anchored:', main.anchored) print(main.general_info(), '\n') print(main) graphs = [] graphs.append(main) graphs.append(main.copy(-1.0, 0.0)) graphs[-1].reflect('y') graphs.append(main.copy(0.0, -1.0)) graphs[-1].reflect('x') CAN = Canvas(border_thickness=0.05, grid=True) for graph in graphs: CAN.add_graph(graph)
# LEFT left = Graph(name = 'left') left.add_node(x=-1.0, y=0.5, name = 'angled name [y]', ll = 'left', la = 45.0) left.add_node(x=-1.0, y=0.5, name = 'angled (ref) [y]', ll = 'left', la = 45.0, ref = 'y') left.add_node(x=-2.0, y=0.5, name = 'angled name [x]', ll = 'left', la = 45.0) left.add_node(x=-2.0, y=0.5, name = 'angled (ref) [x]', ll = 'left', la = 45.0, ref = 'x') GRAPH = Graph(name = 'graph', graphs = [main, left, right, top, bottom]) GRAPH.anchor_graph() print 'Nodes are anchored:', GRAPH.anchored print GRAPH.general_info(), '\n' print GRAPH CAN = Canvas(border_thickness = 0.05, grid = True) CAN.add_graph(GRAPH) CAN.draw(save_file = 'test.pdf', display = True, print_information = False)
GRAPH.add_node(x=0.75, y=-1.5, name = 'B', ll = 'bottom') GRAPH.add_node(x=-1.5, y=-0.75, name = 'C', ll = 'left') GRAPH.add_node(x=1.5, y=-0.75, name = 'D', ll = 'right') GRAPH.add_node(x=-0.75, y=-1.5, name = 'E', ll = 'bottom') # Add Connections GRAPH.connect('A', 'B', name = "I", directional = False, ll = 'top') GRAPH.connect('C', 'A', name = "II", ll = 'top') GRAPH.connect('A', 'D', name = "III", ll = 'top') GRAPH.connect('A', 'E', name = "IV", directional = False, ll = 'top') GRAPH.connect('B', 'C', name = "V", directional = False, ll = 'top') GRAPH.connect('D', 'B', name = "VI", ll = 'bottom') GRAPH.connect('B', 'E', name = "VII", ll = 'bottom') GRAPH.connect('C', 'D', name = "VIII", directional = False, ll = 'top') GRAPH.connect('E', 'C', name = "IX", ll = 'bottom') GRAPH.connect('D', 'E', name = "X", directional = False, ll = 'top') GRAPH.anchor_graph() print('Nodes are anchored:', GRAPH.anchored) print(GRAPH.general_info(), '\n') print(GRAPH) # plot CAN = Canvas(border_thickness = 0.05, grid = True) CAN.add_graph(GRAPH) CAN.draw(save_file = 'test.pdf', display = True, print_information = False)
main = Graph(name = 'main') main.add_node(x=0.0, y=0.0, name = 'A', ll = 'bottom') main.add_node(x=1.0, y=0.0, name = 'B', ll = 'right') main.add_node(x=1.0, y=1.0, name = 'C', ll = 'top') main.add_node(x=0.0, y=1.0, name = 'D', ll = 'left') main.connect('A', 'B', name = '1', ll = 'bottom') main.connect('B', 'C', name = '2', ll = 'bottom') main.connect('C', 'D', name = '3', ll = 'bottom') main.connect('D', 'A', name = '4', ll = 'bottom') main.anchor_graph() print('Nodes are anchored:', main.anchored) print(main.general_info(), '\n') print(main) graphs = [] displacement = 3.0 for i in range(2): graphs.append( main.copy(i * displacement, 0.0) ) graphs[-1].rotate(i * 45.0) CAN = Canvas(border_thickness = 0.05, grid = True) for graph in graphs: CAN.add_graph(graph) CAN.draw(save_file = 'test.pdf', display = True, print_information = False)