
.. 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

        Click :ref:`here <sphx_glr_download_gallery_graph_properties_plot_betweenness.py>`
        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 24-41

.. code-block:: default


    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 42-43

Let's start by making a random exponential graph

.. GENERATED FROM PYTHON SOURCE LINES 43-49

.. code-block:: default


    shape = Shape.disk(100)

    g = nngt.generation.distance_rule(5, shape=shape, nodes=1000, avg_deg=3)









.. GENERATED FROM PYTHON SOURCE LINES 50-51

then we can plot the betweenness

.. GENERATED FROM PYTHON SOURCE LINES 51-54

.. code-block:: default


    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 55-56

we can of course change various parameters and plot only the nodes

.. GENERATED FROM PYTHON SOURCE LINES 56-62

.. code-block:: default


    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 63-64

By the way, this is the graph we're looking at

.. GENERATED FROM PYTHON SOURCE LINES 64-67

.. code-block:: default


    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  5.275 seconds)


.. _sphx_glr_download_gallery_graph_properties_plot_betweenness.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_betweenness.py <plot_betweenness.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: plot_betweenness.ipynb <plot_betweenness.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
