The dataset is currently empty. Upload or create new data files. Then, you will be able to explore them in the Dataset Viewer.

import networkx as nx import matplotlib.pyplot as plt import numpy as np

Create a graph with approximately 40 nodes

num_nodes = 40 graph = nx.Graph() graph.add_nodes_from(range(num_nodes))

Adjust the graph so that the probability of two nodes being connected is 10%

Use networkx.erdos_renyi_graph (ER) model

probability = 0.1 graph = nx.erdos_renyi_graph(num_nodes, probability)

Calculate the degree of each node

degrees = dict(graph.degree()) degree_values = list(degrees.values())

Create a histogram of the degrees

plt.hist(degree_values, bins=range(max(degree_values) + 2)) # Adjust bins as needed plt.title("Histogram of Node Degrees") plt.xlabel("Degree") plt.ylabel("Frequency")

To see the output, run the code.

Downloads last month
2