
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/graph_properties/plot_attributes.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_attributes.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_graph_properties_plot_attributes.py:


Plot various graph properties
=============================

.. 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"
    })


    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=20)









.. GENERATED FROM PYTHON SOURCE LINES 50-51

Let's plot the distances

.. GENERATED FROM PYTHON SOURCE LINES 51-54

.. code-block:: default


    nplt.edge_attributes_distribution(g, "distance", show=True)




.. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_attributes_001.png
   :alt: Distance distribution for DR
   :srcset: /gallery/graph_properties/images/sphx_glr_plot_attributes_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 55-56

We then compute the betweenness and see how it correlates with the distance

.. GENERATED FROM PYTHON SOURCE LINES 56-65

.. code-block:: default


    nbetw, ebetw = nngt.analysis.betweenness(g)

    g.new_edge_attribute("betweenness", "float", values=ebetw)

    nplt.correlation_to_attribute(g, "distance", "betweenness",
                                  attribute_type="edge", show=True)





.. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_attributes_002.png
   :alt: DR, Distance vs betweenness
   :srcset: /gallery/graph_properties/images/sphx_glr_plot_attributes_002.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 66-67

Let's check the correlations between various node properties and their degree

.. GENERATED FROM PYTHON SOURCE LINES 67-73

.. code-block:: default


    g.new_node_attribute("betweenness", "float", values=nbetw)

    attr = ["betweenness", "clustering", "in-degree", "subgraph_centrality"]

    nplt.correlation_to_attribute(g, "out-degree", attr, show=True)



.. image-sg:: /gallery/graph_properties/images/sphx_glr_plot_attributes_003.png
   :alt: DR, Out-degree vs betweenness, Out-degree vs clustering, Out-degree vs in-degree, Out-degree vs subgraph_centrality
   :srcset: /gallery/graph_properties/images/sphx_glr_plot_attributes_003.png
   :class: sphx-glr-single-img






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

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


.. _sphx_glr_download_gallery_graph_properties_plot_attributes.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_attributes.py <plot_attributes.py>`



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

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


.. only:: html

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

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