-
Notifications
You must be signed in to change notification settings - Fork 0
/
synthetic1_motifcreate_allfiles.py
46 lines (40 loc) · 1.29 KB
/
synthetic1_motifcreate_allfiles.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
45
46
from igraph import *
for index in range(15,101):
filename="artificial_random_1m_"+str(index)+"_lcc.txt"
inputfile=open(filename,"r")
lines=inputfile.readlines()
inputfile.close()
templist=[]
lines=lines[2:]
maxvalue=0
for i in lines:
i=i[:-1]
words=i.split("\t\t\t")
templist.append((int(words[0]),int(words[1])))
if int(words[0])>maxvalue:
maxvalue=int(words[0])
if int(words[1])>maxvalue:
maxvalue=int(words[1])
g=Graph()
g.add_vertices(maxvalue+1)
g.add_edges(templist)
outputname="synthetic1_"+str(index)+"_motif.txt"
outputfile = open(outputname, "a")
motifs_3=g.motifs_randesu(3)
motifs_4=g.motifs_randesu(4)
outputfile.write("\t")
outputfile.write(str(motifs_3[2]))
outputfile.write("\t")
outputfile.write(str(motifs_3[3]))
outputfile.write("\t")
outputfile.write(str(motifs_4[6]))
outputfile.write("\t")
outputfile.write(str(motifs_4[7]))
outputfile.write("\t")
outputfile.write(str(motifs_4[8]))
outputfile.write("\t")
outputfile.write(str(motifs_4[9]))
outputfile.write("\t")
outputfile.write(str(motifs_4[10]))
outputfile.write("\n")
outputfile.close()