Commit 0fcddee9 authored by Interdonato Roberto's avatar Interdonato Roberto
Browse files

Update utilities.py

parent ef6ef559
No related merge requests found
Showing with 21 additions and 0 deletions
+21 -0
......@@ -51,6 +51,22 @@ def multilayer_format_geo2net(net_dir,outname,w_inter=0.5,wheuristic=True,weight
fout.write("%s %s %s %s %f \n" % (vals[1],vals[0],vals[3].strip(),vals[2],w_inter))
fout.close()
def flatten_network(input_path,output_path,out_sl):
fout = open(output_path,'w')
fsl = open(out_sl,'w')
f = open(input_path, 'r')
for line in f:
vals = line.split(" ")
u = int(vals[1].strip())
v = int(vals[3].strip())
w = float(vals[4].strip())
fout.write("%d %d %d %d %f\n" % (1,u,1,v,w))
fsl.write("%d %d %f\n" % (u,v,w))
fout.close()
fsl.close()
# writes a qml style file starting from a infomap clustering solution in .clu format
def qml_from_clu(clu_file, outname):
fout = open(outname, 'w')
......@@ -84,3 +100,8 @@ def qml_from_clu(clu_file, outname):
fout.write(r'</colorPalette></rasterrenderer><brightnesscontrast brightness="0" contrast="0"/><huesaturation colorizeGreen="128" colorizeOn="0" colorizeRed="255" colorizeBlue="128" grayscaleMode="0" saturation="0" colorizeStrength="100"/><rasterresampler maxOversampling="2"/></pipe><blendMode>0</blendMode></qgis>')
fout.close()
if __name__=='__main__':
#multilayer_format_geo2net('nets_K10_flat_0_tps_ilweights','mlnet_K10_cmeans_ilweights.ncol',weighted_input=True)
qml_from_clu(".\\output\\infomap\\mlnet_K10_cmeans_pc50_sl.clu","mlnet_K10_cmeans_pc50_sl.qml")
#os.chdir("D:\\Mes Donnees\\Amoris\\geo2net-master\\geo2net-master\\ml_nets\\")
#flatten_network("mlnet_K10_cmeans_pc50.ncol","mlnet_K10_cmeans_pc50_flattened.ncol","mlnet_K10_cmeans_pc50_sl.ncol")
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment