Skip to content

Commit

Permalink
converted to python3
Browse files Browse the repository at this point in the history
  • Loading branch information
SofiaPapakostopoulou committed Nov 16, 2021
1 parent 588cdc4 commit 0c67c0e
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def compare_communities(self,):
self.inclusions = {}
window_id = 'TF%s -> TF%s' % (index,index+1)
Dhypergraph = nx.DiGraph(window=window_id)
print 'Initialize inclusions dict start...'
print ('Initialize inclusions dict start...')
Dhypergraph = self.initialize_inclusions(index,Dhypergraph)
print 'Initialize inclusions dict finish...'
print ('Initialize inclusions dict finish...')

for ic,community_t in enumerate(interval):

Expand Down Expand Up @@ -88,12 +88,12 @@ def analyze_results(self,):
'forming', 'no_event']
events = [e['resulted_event'] for e in self.results]
for name in events_names:
print name, events.count(name)
print (name, events.count(name))

if __name__=='__main__':
if len(sys.argv) != 2:
print 'Usage: Tracker.py <inputfile.json>'
print 'Exiting with code 1'
print ('Usage: Tracker.py <inputfile.json>')
print ('Exiting with code 1')
exit(1)
start_time = time.time()
graphs = preprocessing.getGraphs(sys.argv[1])
Expand All @@ -102,6 +102,6 @@ def analyze_results(self,):
with open('ged_results.csv','w')as f:
for hypergraph in tracker.hypergraphs:
hypergraph.calculateEvents(f)
print "--- %s seconds ---" %(time.time() - start_time)
print ("--- %s seconds ---" %(time.time() - start_time))


Binary file added __pycache__/config.cpython-310.pyc
Binary file not shown.
Binary file added __pycache__/event.cpython-310.pyc
Binary file not shown.
Binary file added __pycache__/hypergraph.cpython-310.pyc
Binary file not shown.
Binary file added __pycache__/inclusion.cpython-310.pyc
Binary file not shown.
Binary file added __pycache__/preprocessing.cpython-310.pyc
Binary file not shown.
9 changes: 4 additions & 5 deletions inclusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ def find_group_quantity(self, intersection, g1):
float(g1.number_of_nodes()))

def find_group_quality(self, intersection, g1):
intersection_sum = sum([g1.node[node]['centrality'] for node in intersection])
intersection_sum = sum([g1._node[node]['centrality'] for node in intersection])
g1_sum = sum([d['centrality'] for node,d in g1.nodes(data=True)])
if (not g1_sum):
return 0
if (not g1_sum): return 0
return intersection_sum / g1_sum


Expand Down Expand Up @@ -86,8 +85,8 @@ def __init__(self, g1, g2):
def find_degree(self, initial_graph):
#degrees_dict = nx.pagerank(initial_graph, alpha=0.9)
degrees_dict = nx.degree_centrality(initial_graph)
for node, value in degrees_dict.iteritems():
initial_graph.node[node]['centrality'] = value
for node, value in degrees_dict.items():
initial_graph._node[node]['centrality'] = value
return initial_graph

def find_inclusions(self, g1, g2):
Expand Down
4 changes: 2 additions & 2 deletions preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def getGraphs(communitiesfile):
with open(communitiesfile) as f:
data = json.load(f)
except:
print "Cannot load %s file. Expecting <input>.json file" % communitiesfile
print "Exiting with code 1\n"
print ("Cannot load %s file. Expecting <input>.json file" % communitiesfile)
print ("Exiting with code 1\n")
exit(1)
graphs = createGraphs(data)
return graphs
Expand Down

0 comments on commit 0c67c0e

Please sign in to comment.