.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "sphinx_gallery_output/plot_12_multicomponent_graphs.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_sphinx_gallery_output_plot_12_multicomponent_graphs.py: Graphs with Multiple Components =============================== For each component, netgraph computes the node and edge layouts separately, and then arranges the individual components with respect to each other using `rectangle packing`__. .. __ : https://github.com/Penlect/rectangle-packer .. GENERATED FROM PYTHON SOURCE LINES 12-36 .. image-sg:: /sphinx_gallery_output/images/sphx_glr_plot_12_multicomponent_graphs_001.png :alt: plot 12 multicomponent graphs :srcset: /sphinx_gallery_output/images/sphx_glr_plot_12_multicomponent_graphs_001.png :class: sphx-glr-single-img .. code-block:: default import matplotlib.pyplot as plt from itertools import combinations from netgraph import Graph edge_list = [] # add 15 2-node components edge_list.extend([(ii, ii+1) for ii in range(30, 60, 2)]) # add 10 3-node components for ii in range(60, 90, 3): edge_list.extend([(ii, ii+1), (ii, ii+2), (ii+1, ii+2)]) # add a couple of larger components n = 90 for ii in [10, 20, 30]: edge_list.extend(list(combinations(range(n, n+ii), 2))) n += ii nodes = list(range(n)) Graph(edge_list, nodes=nodes, node_size=1, edge_width=0.3, node_layout='circular') plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.262 seconds) .. _sphx_glr_download_sphinx_gallery_output_plot_12_multicomponent_graphs.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_12_multicomponent_graphs.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_12_multicomponent_graphs.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_