# This file is part of MAMMULT: Metrics And Models for Multilayer Networks # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import networkx as nx import sys if __name__ == "__main__": if len(sys.argv) < 6: print "Usage: %s " % sys.argv[0] sys.exit(1) filename_a = sys.argv[1] filename_b = sys.argv[2] intervals=int(sys.argv[3]) minvalue=float(sys.argv[4]) maxvalue=float(sys.argv[5]) tot_a = [] pos_a = [] for t in range (intervals): tot_a.append(0) pos_a.append(0) fa=open(filename_a, 'r') Ga=nx.read_adjlist(fa) fb=open(filename_b, 'r') Gb=nx.read_weighted_edgelist(fb) for u,v in Gb.edges(): Gbw=Gb[u][v]['weight'] for i in range (intervals): a=minvalue+float(maxvalue-minvalue)*float(i)/intervals b=minvalue+float(maxvalue-minvalue)*float(i+1)/intervals if (Gbw>a and Gbw0): freq_a.append(float(pos_a[i])/tot_a[i]) else: freq_a.append(0) print "#bin_minvalue bin_maxvalue frequence" for i in range (intervals): a=minvalue+float(maxvalue-minvalue)*float(i)/intervals b=minvalue+float(maxvalue-minvalue)*float(i+1)/intervals print a, b, freq_a[i]