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


.. code-block:: default


    import nngt
    import nngt.plot as nplt
    from nngt.geometry import Shape


    nngt.seed(0)









Let's start by making a random exponential graph


.. code-block:: default


    shape = Shape.disk(100)

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









then we can plot the betweenness


.. code-block:: default


    nplt.betweenness_distribution(g, logx=True, show=True,
                                       legend_location='left')




.. image:: /gallery/graph_properties/images/sphx_glr_plot_betweenness_001.png
    :alt: Betweenness distribution for DR
    :class: sphx-glr-single-img





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


.. 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:: /gallery/graph_properties/images/sphx_glr_plot_betweenness_002.png
          :alt: Betweenness distribution for DR
          :class: sphx-glr-multi-img

    *

      .. image:: /gallery/graph_properties/images/sphx_glr_plot_betweenness_003.png
          :alt: Betweenness distribution for DR
          :class: sphx-glr-multi-img





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


.. code-block:: default


    nplt.draw_network(g, max_nsize=1, show_environment=False, show=True)



.. image:: /gallery/graph_properties/images/sphx_glr_plot_betweenness_004.png
    :alt: plot betweenness
    :class: sphx-glr-single-img






.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  2.094 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>`_
