-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo.py
36 lines (28 loc) · 898 Bytes
/
demo.py
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
32
33
34
35
36
"""
Demo for using COPT for graph sketching.
"""
import torch
import numpy as np
import utils
import runGraph
import graph
def sketch_graph(args):
data_dim = 20
lo_dim = 5
g1 = utils.create_graph(data_dim, 'random_regular')
#args.n_epochs = 300 <--parameters like this can be set here or in command line
args.Lx = utils.graph_to_lap(g1)
args.m = len(args.Lx)
args.n = lo_dim
# sketch graphs of lo_dim.
# Returns optimization loss, transport plan P, and Laplacian of sketched graph
loss, P, Ly = graph.graph_dist(args, plot=False)
print('sketched graph Laplacian {}'.format(Ly))
#can convert Ly to a networkx graph with utils.lap_to_graph(Ly)
return loss, P, Ly
if __name__ == '__main__':
args = utils.parse_args()
if args.fix_seed:
torch.manual_seed(0)
np.random.seed(0)
sketch_graph(args)