Commit bf555062 authored by Pascal Engélibert's avatar Pascal Engélibert 🚴
Browse files

Update fa2rs

parent 6e1de3a4
......@@ -107,6 +107,7 @@ Options:
-C <int> Number of communities
--ns Disable strict mode (ignore incoherent data)
--fa2rs Use fa2rs implementation
--it <int> Number of iterations for layout
--csv <file> Export WoT graph to CSV (for Gephi)
-v Verbose
......@@ -120,6 +121,7 @@ Default options:
-m 604800 (7 days)
-M img/logo-g1.png
-C 30
--it 50 (3000 with --fa2rs)
--csv ~/wotmap/data/wot.csv""")
......@@ -360,13 +362,15 @@ Default options:
if gencoords:
log("Updating coords...")
if "--fa2rs" in sys.argv:
niters = int(getargv("--it", 3000))
import fa2rs
layout = fa2rs.Layout.from_graph(graph.edges, len(graph.nodes), fa2rs.Settings(kr=0.002, kg=0.001, ka=0.01, dissuade_hubs=False, barnes_hut=None, strong_gravity=False, prevent_overlapping=False, jitter_tolerance=0.1))
for i in range(1000):
print("{} / 1000".format(i), end="\r")
layout = fa2rs.Layout.from_graph(graph.edges, fa2rs.Settings(kr=1, kg=1, ka=1, dissuade_hubs=False, barnes_hut=None, strong_gravity=False, prevent_overlapping=False, speed=0.01), nb_nodes=len(graph.nodes))
for i in range(niters):
print("{} / {}".format(i, niters), end="\r")
#print(min(layout.points, key=lambda x:min(x)), max(layout.points, key=lambda x:max(x)), max(layout.points, key=lambda x:math.sqrt(x[0]**2+x[1]**2)))
# TODO ça plante à layout.points
i = 0
for point in layout.points:
outdata_wot["nodes"][i]["x"] = point[0]
......@@ -379,7 +383,7 @@ Default options:
layout = forceatlas2.forceatlas2_networkx_layout(graph, niter=10)
layout = networkx.layout.fruchterman_reingold_layout(graph)
layout = networkx.layout.fruchterman_reingold_layout(graph, iterations=int(getargv("--it", 50)))
i = 0
for dot in layout:
outdata_wot["nodes"][i]["x"] = layout[dot][0]
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