Exemple #1
0
#!/usr/bin/env python
import sys
import fileProcess

inputFileName = sys.argv[1]
i = int(sys.argv[2])
outputFileName = sys.argv[3]


N, amLines = fileProcess.deal_input(inputFileName)

J=list()
for j in amLines:
    ijUnion=set(N[i])|set(N[j])
    ijAnd=set(N[i])&set(N[j])
    J+=[float(len(ijAnd))/float(len(ijUnion))]

fileProcess.deal_output(amLines, J, outputFileName)
Exemple #2
0
#!/usr/bin/env python
import sys
import fileProcess

input = sys.argv[1]
output = sys.argv[2]
N, amLines = fileProcess.deal_input(input)

print 'Originally we have ' + str(len(N.keys())) + ' nodes.'
count = 0
for key in N.keys():
    if len(N[key]) == 1:
        count += 1

print str(count) + ' nodes\' N list length = 1.'

nodelist = tuple(N.keys())
for node in nodelist:
    if len(N[node]) == 1:
        del N[node]
        
for node in N.keys():
    nodelist = N[node]
    nodelist2 = nodelist
    for n in nodelist2:
        if not (N.has_key(n)):
            nodelist.remove(n)
    N[node] = sorted(nodelist)

print 'Now we have ' + str(len(N.keys())) + ' nodes.'
print 'Output link file from purned graph...'
#!/usr/bin/env python

import sys
sys.path.append('../proximity-measures')
sys.path.append('../proximity-simple')
import fileProcess
import math

#Label file
inputFileName1 = sys.argv[2]
#Link file
inputFileName2 = sys.argv[1]
outputFileName = sys.argv[3]

N, amLines = fileProcess.deal_input(inputFileName2)
C = fileProcess.deal_input2(inputFileName1)
NC = fileProcess.deal_input3(inputFileName1)
m = fileProcess.countLine(inputFileName2)
S_label = 1
S_bar_label = 0
S = tuple(C[S_label])
S_bar = tuple(C[S_bar_label])

sumadjIwithJ = 0
sumDI = 0
sumSLinks = 0
for i in S:
    nodeLine = tuple(N[i])    
    for node in nodeLine:
        #Sum the number of j in S_bar and is the neighbor of i 
        if NC[node] == S_bar_label:
#!/usr/bin/env python
import sys
import fileProcess

input = sys.argv[1]
output = sys.argv[2]
N, amLines = fileProcess.deal_input(input)

print 'Originally we have ' + str(len(N.keys())) + ' nodes.'
count = 0
for key in N.keys():
    if len(N[key]) == 1:
        count += 1

print str(count) + ' nodes\' N list length = 1.'

nodelist = tuple(N.keys())
for node in nodelist:
    if len(N[node]) == 1:
        del N[node]

for node in N.keys():
    nodelist = N[node]
    nodelist2 = nodelist
    for n in nodelist2:
        if not (N.has_key(n)):
            nodelist.remove(n)
    N[node] = sorted(nodelist)

print 'Now we have ' + str(len(N.keys())) + ' nodes.'
print 'Output link file from purned graph...'