Plot the betweenness distributions of a graph#

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

import matplotlib.pyplot as plt

    'axes.edgecolor': 'grey', 'xtick.color': 'grey', 'ytick.color': 'grey',
    "figure.facecolor": (0, 0, 0, 0), "axes.facecolor": (0, 0, 0, 0),
    "axes.labelcolor": "grey", "axes.titlecolor": "grey", "text.color": "grey",
    "legend.facecolor": "none"


Let’s start by making a random exponential graph

shape = Shape.disk(100)

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

then we can plot the betweenness

nplt.betweenness_distribution(g, logx=True, show=True,
Betweenness distribution for DR

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

nplt.betweenness_distribution(g, logx=False, show=True)

nplt.betweenness_distribution(g, btype="node", num_nbins="auto",
                                   alpha=0.5, show=True)
  • Betweenness distribution for DR
  • Betweenness distribution for DR

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

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

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

Gallery generated by Sphinx-Gallery