node_invoked_callback=node_invoked, edge_invoked_callback=edge_invoked, node_removed_callback=node_removed, edge_removed_callback=edge_removed) # Create A new Graph using Dot layout engine qgv.new(Dot(Graph("Main_Graph"), show_subgraphs=show_subgraphs)) # Define sone graph n1 = qgv.addNode(qgv.engine.graph, "Node1", label="N1") n2 = qgv.addNode(qgv.engine.graph, "Node2", label="N2") n3 = qgv.addNode(qgv.engine.graph, "Node3", label="N3") n4 = qgv.addNode(qgv.engine.graph, "Node4", label="N4") n5 = qgv.addNode(qgv.engine.graph, "Node5", label="N5") n6 = qgv.addNode(qgv.engine.graph, "Node6", label="N6") sub = qgv.addSubgraph(qgv.engine.graph, "subgraph", qgv.engine.graph.graph_type, label="Subgraph") n7 = qgv.addNode(sub, "Node7", label="N7") n8 = qgv.addNode(sub, "Node8", label="N8") qgv.addEdge(n1, n2, {}) qgv.addEdge(n3, n2, {}) qgv.addEdge(n2, n4, {"width": 2}) qgv.addEdge(n4, n5, {"width": 4}) qgv.addEdge(n4, n6, {"width": 5, "color": "red"}) qgv.addEdge(n3, n6, {"width": 2}) # Build the graph (the layout engine organizes where the nodes and connections are) qgv.build() # Save it to a file to be loaded by Graphviz if needed qgv.save("test.gv")
fillcolor="white") n5 = qgv.addNode(qgv.engine.graph, "Node5", label="N5", shape="polygon", fillcolor="red", color="white") n6 = qgv.addNode(qgv.engine.graph, "Node6", label="N6", shape="triangle", fillcolor="blue:white:red") sub = qgv.addSubgraph(qgv.engine.graph, "sub graph", qgv.engine.graph.graph_type, label="Subgraph", fillcolor="blue:white:red") n7 = qgv.addNode(sub, "Node7", label="N7") n8 = qgv.addNode(sub, "Node8", label="N8") # Adding nodes with an image as its shape icon_path = os.path.dirname( os.path.abspath(__file__)) + r"\icon\dbicon.png" n9 = qgv.addNode(qgv.engine.graph, "Node9", label="N9", shape=icon_path) qgv.addEdge(n1, n2, {}) qgv.addEdge(n3, n2, {}) qgv.addEdge(n2, n4, {"width": 2}) qgv.addEdge(n4, n5, {"width": 4}) qgv.addEdge(n4, n6, {"width": 5, "color": "red"})