-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSAGD.py
More file actions
31 lines (28 loc) · 845 Bytes
/
SAGD.py
File metadata and controls
31 lines (28 loc) · 845 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
29
30
31
import numpy as np
from distances import CTD_matrix
from stats import normalize, Kruglov_distance
def SAGD(
W_i,
W_j,
laplacian_type="unnormalized",
norm_type="norm_wrt_avg_ctd"
):
"""Compute Shape-Aware Graph Distance."""
# Process Graph i
C_Gi = CTD_matrix(W=W_i, laplacian_type=laplacian_type)
triu_i = C_Gi[np.triu_indices(W_i.shape[0], k=1)]
# Assuming volume-based norm uses total weight sum
norm_i = normalize(
list_values=triu_i,
norm_type=norm_type,
Vol=np.sum(W_i)
)
# Process Graph j
C_Gj = CTD_matrix(W=W_j, laplacian_type=laplacian_type)
triu_j = C_Gj[np.triu_indices(W_j.shape[0], k=1)]
norm_j = normalize(
list_values=triu_j,
norm_type=norm_type,
Vol=np.sum(W_j)
)
return Kruglov_distance(vi=norm_i, vj=norm_j)