Old engine for Continuous Time Bayesian Networks. Superseded by reCTBN. 🐍
https://github.com/madlabunimib/PyCTBN
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
505 B
23 lines
505 B
4 years ago
|
"""
|
||
|
===========
|
||
|
Eigenvalues
|
||
|
===========
|
||
|
|
||
|
Create an G{n,m} random graph and compute the eigenvalues.
|
||
|
"""
|
||
|
import matplotlib.pyplot as plt
|
||
|
import networkx as nx
|
||
|
import numpy.linalg
|
||
|
|
||
|
n = 1000 # 1000 nodes
|
||
|
m = 5000 # 5000 edges
|
||
|
G = nx.gnm_random_graph(n, m)
|
||
|
|
||
|
L = nx.normalized_laplacian_matrix(G)
|
||
|
e = numpy.linalg.eigvals(L.A)
|
||
|
print("Largest eigenvalue:", max(e))
|
||
|
print("Smallest eigenvalue:", min(e))
|
||
|
plt.hist(e, bins=100) # histogram with 100 bins
|
||
|
plt.xlim(0, 2) # eigenvalues between 0 and 2
|
||
|
plt.show()
|