# HG changeset patch # User bornea # Date 1508355169 14400 # Node ID 7dc4b20f59745ba06240da2ecef13fda8f372381 # Parent 9b42fbe3faba8d8745b798149d528ad453a43fa0 Uploaded diff -r 9b42fbe3faba -r 7dc4b20f5974 plot_edge_bundling.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot_edge_bundling.py Wed Oct 18 15:32:49 2017 -0400 @@ -0,0 +1,218 @@ +import sys +def readTab(infile): # read in txt file + with open(infile, 'r') as input_file: + # read in tab-delim text + output = [] + for input_line in input_file: + input_line = input_line.strip() + temp = input_line.split('\t') + output.append(temp) + return output +def network2JSON(node_attr_file,edge_file): + nodes = readTab(node_attr_file) + edges = readTab(edge_file) + + connections = {} + communities = {} + for i in nodes[1:]: + communities[i[0]] = i[1] + for i in nodes[1:]: + temp = [] + for j in edges: + if i[0] in j: + if i[0] != j[0]: + temp.append(str(communities[j[0]]) + "." + str(j[0])) + if i[0] != j[1]: + temp.append(str(communities[j[1]])+"."+str(j[1])) + connections[i[0]] = temp + json = "[" + for i in nodes[1:]: + json = json + '{"name":"' + i[1] + '.' + str(i[0]) + '" ,"imports":'+str(connections[i[0]])+'},' + json = json[:-1] + json = json + "]" + json = json.replace("'",'"') + return json +############################################ +top = """ + + +
+ +""" +############################################ +with open(sys.argv[3],"w") as x: + x.write(top + middle + bottom)