Python networkx: grouping nodes based on a node attribute
<p>I am drawing a network topology diagram (Telecoms related) from an adjacency matrix.  I have a numpy adjacency matrix from which I generate a networkx graph (G).  </p>

<p>At a particular Site (City) I have multiple nodes, that may or may not be interconnected.  The site name can be determined from the Node name (label).  </p>

<p>Is it possible to cluster the nodes at the same site together (and ideally draw a box around them), while displaying the individual nodes within the site?  I consider this like grouping nodes based on some node attribute such as node name.</p>

<p>I the diagram Site A shows the desired output for the diagram.<a href="https://i.stack.imgur.com/dC9vw.jpg" rel="nofollow noreferrer">Example graph</a></p>

<p>I believe I could get a solution if I created dummy edges between nodes at the same site, and gave them a high weight using spring layout to ensure the same nodes at a site are close together, however this does not seem like an optimum solution.</p>

<p>Any advice appreciated!!  Thanks in Advance.  Also note it is not essential to use numpy, networkx I am open to suggestions.</p>