Fixing the output positions in sfdp layout
Hi I am trying to fix the layout that I get every time that I re-run my script. I gave input pos to sfdp a propertymap that initializes all positions to [1,1]. However, the output pos that I am getting is slightly different every time. Any solutions? Thanks! -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 22.03.2016 03:57, Kimon wrote:
I am trying to fix the layout that I get every time that I re-run my script.
I gave input pos to sfdp a propertymap that initializes all positions to [1,1]. However, the output pos that I am getting is slightly different every time.
If you put all vertices on the same position, the repulsive force between them will be undefined. What the algorithm does in this case, is to push the vertices apart in random directions. To avoid this, you should put them initially in different positions. Furthermore, you should disable parallel processing with OpenMP which will introduce another source of non-determinism. You can do this by calling: openmp_set_num_threads(1) Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Hi Tiago, Thanks for the reply. I still have the same issue. I am running the following code in Jupyter prop = g.new_vertex_property("vector<double>") for i in xrange(n): prop[i] = [1 + i,1 + i] #openmp_set_num_threads(1) pos = sfdp_layout(g, gamma=10.0, mu=10.0, mu_p=10.0, verbose = False, pos=prop) I disabled the openmp command because it gives me an error that it's not enabled anyway: "OpenMP was not enabled during compilation". Every time that I press shift + enter in Jupyter to re-run the above piece of code (without running anything else in-between) I get a different pos output. Kimon -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 22.03.2016 13:55, Kimon wrote:
Hi Tiago,
Thanks for the reply. I still have the same issue. I am running the following code in Jupyter
prop = g.new_vertex_property("vector<double>") for i in xrange(n): prop[i] = [1 + i,1 + i]
#openmp_set_num_threads(1)
pos = sfdp_layout(g, gamma=10.0, mu=10.0, mu_p=10.0, verbose = False, pos=prop)
I disabled the openmp command because it gives me an error that it's not enabled anyway: "OpenMP was not enabled during compilation".
Every time that I press shift + enter in Jupyter to re-run the above piece of code (without running anything else in-between) I get a different pos output.
I cannot reproduce this. Can you please provide a short, complete and self-contained example that shows the problem? Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Sure. I attached two files. A .pynb file for the code and senate.txt for the data. senate-unrolled.txt <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/n4026506/senate-unrolled.txt> test_kimon.ipynb <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/n4026506/test_kimon.ipynb> -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
test_kimon.ipynb <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/n4026507/test_kimon.ipynb> senate-unrolled.txt <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/n4026507/senate-unrolled.txt> -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
Any news in that front? I tried various things but every time I get different result. Is the method deterministic? If not how can I initialize its seed? Kimon -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
On 28.03.2016 23:19, Kimon wrote:
Any news in that front? I tried various things but every time I get different result. Is the method deterministic? If not how can I initialize its seed?
It should be deterministic, but it is not. This is a bug and will be fixed. In the mean time you can make it deterministic by seeding the RNG before calling graph_draw(): numpy.random.seed(42) graph_tool.seed_rng(42) Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Ok thanks Tiago. I made a hack by saving the pos variable and loading it back when I need. I will try your solution which sounds easier. Kimon -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
participants (2)
-
Kimon -
Tiago de Paula Peixoto