Skip to content

Commit

Permalink
Work but need some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dassire committed Feb 6, 2024
1 parent b7734f6 commit 2eb25f3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions scripts/CityGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def write_to_file(self, file_path : str) -> None :
if "weight" in e.keys():
weights.append(e["weight"])
elif "maxspeed" in e.keys():
weights.append(int(e["length"]*100000)/int(e["maxspeed"])); # TODO Remove this cast
weights.append(int(e["length"]*100000)/cast_tmp(e["maxspeed"])); # TODO Remove this cast
else:
d.append(e["length"])
if(len(weights)==0):
Expand Down Expand Up @@ -112,8 +112,9 @@ def write_to_file(self, file_path : str) -> None :
i+=1;
"""

f=open(file, "w");
f.write("%d %d %d\n".format(len(V), len(csr.indices), len(csr.indptr)));
f=open(file_path, "w");
# f.write("%d %d %d\n".format(len(V), len(csr.indices), len(csr.indptr)));
f.write(" ".join([str(x) for x in (len(V), len(csr.indices), len(csr.indptr))])+"\n") # TODO change this line
for i in V:
f.write(str(i)+" ");
f.write("\n");
Expand All @@ -128,6 +129,15 @@ def write_to_file(self, file_path : str) -> None :

f.close();

def cast_tmp(var):
"""TODO : Change this function"""
if(type(var)==int):
return var
elif((type(var)==float) or (type(var)==str)):
return int(var)
elif((type(var)==list) or (type(var)==tuple)):
return np.min([cast_tmp(x) for x in var])

# Exemple utilisation
graph = CityGraph("Sainte")
graph.write_to_file("../../result.txt");

0 comments on commit 2eb25f3

Please sign in to comment.