.. 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 :ref:`Go to the end ` 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 10-27 .. code-block:: Python 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 28-29 Let's start by making a random exponential graph .. GENERATED FROM PYTHON SOURCE LINES 29-35 .. code-block:: Python shape = Shape.disk(100) g = nngt.generation.distance_rule(5, shape=shape, nodes=1000, avg_deg=20) .. GENERATED FROM PYTHON SOURCE LINES 36-37 Let's plot the distances .. GENERATED FROM PYTHON SOURCE LINES 37-40 .. code-block:: Python 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 41-42 We then compute the betweenness and see how it correlates with the distance .. GENERATED FROM PYTHON SOURCE LINES 42-51 .. code-block:: Python 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 52-53 Let's check the correlations between various node properties and their degree .. GENERATED FROM PYTHON SOURCE LINES 53-59 .. code-block:: Python 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 35.405 seconds) .. _sphx_glr_download_gallery_graph_properties_plot_attributes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_attributes.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_attributes.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_