I am using the below code to generate a graph with two clusters with four nodes each For some reasons when I print the graph the clusters do not show up. What am I doing wrong?
import pygraphviz as pgv
A=pgv.AGraph(bgcolor="#cccccc",layout='neato')
A.add_edge('R1','R2')
A.add_edge('R2','R3')
A.add_edge('R3','R4')
A.add_edge('R4','R5')
A.add_edge('R5','R6')
A.add_subgraph(['R1','R2','R3','R4'], 'pbd01')
A.add_subgraph(['R5','R6','R7','R8'], 'pbd02')
A.write('cluster.dot')
A.draw('Topology.png', prog='neato')
I believe there are two problems:
The following code / image was produced with the 'dot' engine and correctly clusters the nodes:
import pygraphviz as pgv
A=pgv.AGraph(bgcolor="#cccccc",layout='dot')
A.add_edge('R1','R2')
A.add_edge('R2','R3')
A.add_edge('R3','R4')
A.add_edge('R4','R5')
A.add_edge('R5','R6')
A.add_subgraph(['R1','R2','R3','R4'], name='cluster_pbd01')
A.add_subgraph(['R5','R6','R7','R8'], name='cluster_pbd02')
A.write('cluster.dot')
A.draw('Topology.png', prog='dot')