import numpy as np # Load the library a = np.linspace(-np.pi, np.pi, 100) # Create even grid from -π to π b = np.cos(a) # Apply cosine to each element of a c = np.sin(a) # Apply sin to each element of a b @ c from scipy.stats import norm from scipy.integrate import quad ϕ = norm() value, error = quad(ϕ.pdf, -2, 2) # Integrate using Gaussian quadrature value %matplotlib inline import networkx as nx import matplotlib.pyplot as plt plt.rcParams['figure.figsize'] = (10,6) np.random.seed(1234) # Generate a random graph p = dict((i, (np.random.uniform(0, 1), np.random.uniform(0, 1))) for i in range(200)) g = nx.random_geometric_graph(200, 0.12, pos=p) pos = nx.get_node_attributes(g, 'pos') # Find node nearest the center point (0.5, 0.5) dists = [(x - 0.5)**2 + (y - 0.5)**2 for x, y in list(pos.values())] ncenter = np.argmin(dists) # Plot graph, coloring by path length from central node p = nx.single_source_shortest_path_length(g, ncenter) plt.figure() nx.draw_networkx_edges(g, pos, alpha=0.4) nx.draw_networkx_nodes(g, pos, nodelist=list(p.keys()), node_size=120, alpha=0.5, node_color=list(p.values()), cmap=plt.cm.jet_r) plt.show()