forked from rhythmswing/DP-Spectral
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
44 lines (36 loc) · 1.03 KB
/
main.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
37
38
39
40
41
42
43
44
#!/usr/bin/python3 -W ignore
import sys
import getopt
from laplacian import *
if __name__ == '__main__':
longs = ['input=', 'output=', 'beta=', 'dim=']
shorts = ':'
beta = 0
input = ''
algorithm = ''
dimension = 50
output = ''
opts, args = getopt.getopt(sys.argv[1:], shorts, longs)
for o, a in opts:
if o == '--input':
input = a
if o == '--beta':
beta = float(a)
if o == '--dim':
dimension = int(a)
if o == '--output':
output = a
if input == '':
print('graph input unspecified')
exit()
if output == '':
output = 'embedding.txt'
if beta == '':
print('beta unspecified; default: beta=0')
beta = 0
heading, edgelist = load_edgelist(input)
adj = edgelist_to_adjacency_sparse(edgelist, heading)
print('beta = {0}'.format(beta))
embed, W = laplacian_eigenmap_sparse(adj, dimension, beta)
heading = [heading[0], dimension]
write_embedding(embed, heading, output)