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


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









Let's plot the distances


.. code-block:: default


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




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





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


.. 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:: /gallery/graph_properties/images/sphx_glr_plot_attributes_002.png
    :alt: DR, Distance vs betweenness
    :class: sphx-glr-single-img





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


.. 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:: /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
    :class: sphx-glr-single-img






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

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