.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/graph_properties/plot_betweenness.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_graph_properties_plot_betweenness.py: Plot the betweenness distributions of a graph ============================================= .. GENERATED FROM PYTHON SOURCE LINES 10-27 .. code-block:: Python import nngt import nngt.plot as nplt from nngt.geometry import Shape import matplotlib.pyplot as plt plt.rcParams.update({ 'axes.edgecolor': 'grey', 'xtick.color': 'grey', 'ytick.color': 'grey', "figure.facecolor": (0, 0, 0, 0), "axes.facecolor": (0, 0, 0, 0), "axes.labelcolor": "grey", "text.color": "grey", "legend.facecolor": "none" }) nngt.seed(0) .. GENERATED FROM PYTHON SOURCE LINES 28-29 Let's start by making a random exponential graph .. GENERATED FROM PYTHON SOURCE LINES 29-35 .. code-block:: Python shape = Shape.disk(100) g = nngt.generation.distance_rule(5, shape=shape, nodes=1000, avg_deg=3) .. GENERATED FROM PYTHON SOURCE LINES 36-37 then we can plot the betweenness .. GENERATED FROM PYTHON SOURCE LINES 37-40 .. code-block:: Python nplt.betweenness_distribution(g, logx=True, show=True, legend_location='left') .. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_betweenness_001.png :alt: Betweenness distribution for DR :srcset: /gallery/graph_properties/images/sphx_glr_plot_betweenness_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 41-42 we can of course change various parameters and plot only the nodes .. GENERATED FROM PYTHON SOURCE LINES 42-48 .. code-block:: Python nplt.betweenness_distribution(g, logx=False, show=True) nplt.betweenness_distribution(g, btype="node", num_nbins="auto", alpha=0.5, show=True) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_betweenness_002.png :alt: Betweenness distribution for DR :srcset: /gallery/graph_properties/images/sphx_glr_plot_betweenness_002.png :class: sphx-glr-multi-img * .. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_betweenness_003.png :alt: Betweenness distribution for DR :srcset: /gallery/graph_properties/images/sphx_glr_plot_betweenness_003.png :class: sphx-glr-multi-img .. GENERATED FROM PYTHON SOURCE LINES 49-50 By the way, this is the graph we're looking at .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python nplt.draw_network(g, max_nsize=5, max_esize=4, ecolor="grey", eborder_color="w", curved_edges=True, show_environment=False, show=True) .. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_betweenness_004.png :alt: plot betweenness :srcset: /gallery/graph_properties/images/sphx_glr_plot_betweenness_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 19.767 seconds) .. _sphx_glr_download_gallery_graph_properties_plot_betweenness.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_betweenness.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_betweenness.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_