-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheigen.py
More file actions
28 lines (22 loc) · 637 Bytes
/
eigen.py
File metadata and controls
28 lines (22 loc) · 637 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import networkx as nx
from numpy import linalg as LA
def define_laplacian(A):
return nx.laplacian_matrix(A)
def eig_value(A):
return LA.eig(A)
def eigh_value(A):
return LA.eigh(A)
def eigvals_value(A):
return LA.eigvals(A)
def eigvalsh_value(A):
return LA.eigvalsh(A)
def eig(A, eig_call):
A_laplace = define_laplacian(A)
A_laplace = A_laplace.todense()
switcher = {
"eig": eig_value(A_laplace),
"eigh": eigh_value(A_laplace),
"eigvals": eigvals_value(A_laplace),
"eigvalsh": eigvalsh_value(A_laplace)
}
return switcher.get(eig_call, eig_value(A_laplace))