pydot graphiz, how to set levels

Viewed 19

this is the result of my python script using pydot that tries to draw a logic gate graph, I am having trouble getting the nor gate to be drawn one level down from the andgate. I am using pydot and know that dot has some syntax for doing this. But I am trying to find the pydot equivalent. I tried setting the rankdir="TD" so it puts node that are higher rank further down, but for some reason it considered the norgate node the same rank as the andGate node. Logic-gate-graph

this is the area of my code I am using to draw this graph,

        elif '&' in subArr:
            andGate(count2)
            if subArr[1] in outputArr:
                output(subArr[1])
                graph.add_edge(pydot.Edge(f"andGate{count2}",f"{subArr[1]}", color="black", style=SOLID))
            for item in subArr:
                if item in inputArr:
                    count3 +=1
                    input(item)
                    graph.add_edge(pydot.Edge(f"{item}",f"andGate{count2}", color="black", style=SOLID))
            count2 +=1
        
        elif '~|' in subArr:
            norGate(count2)
            if subArr[1] in outputArr:
                output(subArr[1])
                graph.add_edge(pydot.Edge(f"norGate{count2}",f"{subArr[1]}", color="black", style=SOLID))
            for item in subArr:
                if item in inputArr:
                    count3 +=1
                    input(item)
                    graph.add_edge(pydot.Edge(f"{item}",f"norGate{count2}", color="black", style=SOLID))
            count2 +=1
        
0 Answers
Related