
"""
Demo for using COPT for graph sketching.
"""

import torch
import numpy as np
import utils
import runGraph
import graph
import time 

def align_graph(args):
    data_dim = 20
    lo_dim = 20
        
    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)
    l2, P_true = utils.create_permutation(data_dim, args.Lx.numpy(), seed_nb=2022)
    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, Ly=l2, plot=False, take_ly_exp=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__':
    t1 = time.time()
    args = utils.parse_args()
    if args.fix_seed:
        torch.manual_seed(0)
        np.random.seed(0)
    sketch_graph(args)
    t2 = time.time()
    print('Time Used: %.2f s' % (t2-t1))
