.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_gallery_graph_properties_plot_degrees.py>`     to download the full example code
    .. rst-class:: sphx-glr-example-title

    .. _sphx_glr_gallery_graph_properties_plot_degrees.py:


Plot the degree distributions of a graph
========================================


.. code-block:: default


    import nngt
    import nngt.plot as nplt


    nngt.seed(0)









First, let's create a scale-free network


.. code-block:: default


    g = nngt.generation.random_scale_free(2.1, 3.2, nodes=1000, avg_deg=100)









Plot the degree distribution


.. code-block:: default


    nplt.degree_distribution(g, deg_type=["in", "out"], show=True)




.. image:: /gallery/graph_properties/images/sphx_glr_plot_degrees_001.png
    :alt: Degree distribution for RandomSF
    :class: sphx-glr-single-img





It's not bad... but we don't see much! Let's move a more relevant scale


.. code-block:: default


    nplt.degree_distribution(g, deg_type=["in", "out"], logy=True, show=True)





.. image:: /gallery/graph_properties/images/sphx_glr_plot_degrees_002.png
    :alt: Degree distribution for RandomSF
    :class: sphx-glr-single-img





Or we can use Bayesian binning


.. code-block:: default


    nplt.degree_distribution(g, deg_type=["in", "out"], num_bins="bayes",
                             show=True)



.. image:: /gallery/graph_properties/images/sphx_glr_plot_degrees_003.png
    :alt: Degree distribution for RandomSF
    :class: sphx-glr-single-img






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

   **Total running time of the script:** ( 0 minutes  0.749 seconds)


.. _sphx_glr_download_gallery_graph_properties_plot_degrees.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_degrees.py <plot_degrees.py>`



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

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


.. only:: html

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

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