Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Network: set initial position for nodes, but let them wander freely afterwards #215

Closed
randombumper opened this issue Jul 12, 2014 · 14 comments

Comments

@randombumper
Copy link

Hi,

I'm, working with the Network visualization, and I'm facing a problem: I need to specify the initial position of the nodes (the random initialization doesn't work for me), but I don't want them to remain fixed forever.

I have tried this in several ways, to no avail:

  • Setting both x, y, allowedToMoveX: true and allowedToMoveY: true when defining the node set.
  • Setting x and y and later resetting them to null (nothing happens) or undefined (infinite recursion occurs, for some reason).
  • Setting x and y at definition, and later setting allowedToMoveX and allowedToMoveY to true.
  • Setting allowedToMoveX: true and allowedToMoveX: true at definition, and later setting x and y.

This all result in the same: whenever I set x and y for a node, it will stay pinned forever, no matter what I do or when I do it.

For extra background about my specific needs, I'm trying to define a network formed by three concentric rings (cycles of N nodes):

network-demo

The definition of the network itself doesn't provide enough information to render it properly, the result being variations of this:

non-concentric-cycles

If I were able to hint an initial x and y for each node and let them gravitationally wander off thereafter, I'm pretty sure I'd be able to achieve concentricity.

Any ideas? :)

Thanks and regards,

Pablo.

@AlexDM0
Copy link
Contributor

AlexDM0 commented Jul 12, 2014

Hi Pablo,

Could you make a js fiddle showing your problem? I used these settings
yesterday and as far as I know they work. If you can make an example I
might be able to pinpoint the problem.

Regards,

Alex

@randombumper
Copy link
Author

Hi, Alex. Here's one of my failed strategies: http://jsfiddle.net/97dzy/ My goal is two concentric rings of five nodes each. In this example I try setting coordinates for nodes 1–5 to (0, 0) and then releasing them.

Thanks for your reply. Regards,

Pablo.

@AlexDM0
Copy link
Contributor

AlexDM0 commented Jul 12, 2014

Hi,

Ill look into it Monday when I'm back at work.

Regards,

Alex

@AlexDM0
Copy link
Contributor

AlexDM0 commented Jul 14, 2014

Hi Pablo,

The problem was a bit different than you descibed it. Try it again with the stabilization option off.
The problem is that the edge length is the same, yet you want the outer circle to be stretched more than the inner circle. This is not the energetically favourable situation, hence the solver split your circles apart.

You can safely initialize your nodes with:

x: x, y: y, allowedToMoveX:true, allowedToMoveY: true

You do not need to release them since your problem lies with your configuration of the physics system. I have edited your fiddle: http://jsfiddle.net/97dzy/4/ and my changes are: setting rest length of the edges for the inner and outer circle, removing your release code. Adding allowedToMove to the nodes.

You can imrpove your solution by specifying the positions of all your nodes and then playing with the physics system (http://visjs.org/docs/network.html#PhysicsConfiguration) to get nice round circles.

Regards,

Alex

@randombumper
Copy link
Author

Beautiful! Thanks a lot for your detailed answer.

Regards,

Pablo.

@AlexDM0 AlexDM0 closed this as completed Jul 15, 2014
@nitin0708
Copy link

Hi,

How to stop movable of nodes for hierarchical tree ?

Thanks and Regards,

Nitin

@AlexDM0
Copy link
Contributor

AlexDM0 commented Feb 25, 2015

Hi Nitin,

I already answered this in the other issue but for completeness I'll copy it here.

You can use the freezeSimulation(true) method on stabilized to stop the simulation. You could also use the dragNodes option to disable dragging of nodes.

Alternatively, you could disable the physics simulation with

var options = {physics: {hierarchicalRepulsion: {nodeDistance: 0, springConstant: 0}}

It is not possible to lock the position of individual nodes in the hierarchical system.

Regards,

Alex

@rmasrani
Copy link

Hi Alex. Thanks for the great work. I have just started using your application, and have the following (I am afraid simple) problem. I have a network with 14,000 nodes and about 30,000 edges. I am able to create the network fine (it takes time). I saved the x/y coordinates, and created a JSON with these hard coded. Problem is that the network with the original output looks very different than the network with the x/y coordinates built in. I have tried various suggestions, but look like I am missing something simple. Physics is false. Any suggestions or links to existing docs? Thanks.

@AlexDM0
Copy link
Contributor

AlexDM0 commented Nov 12, 2015

Hi,

It could be due to a bug in the improvedLayout. Try turning that off.

Cheers!

On 12 nov. 2015, at 00:39, rmasrani [email protected] wrote:

Hi Alex. Thanks for the great work. I have just started using your application, and have the following (I am afraid simple) problem. I have a network with 14,000 nodes and about 30,000 edges. I am able to create the network fine (it takes time). I saved the x/y coordinates, and created a JSON with these hard coded. Problem is that the network with the original output looks very different than the network with the x/y coordinates built in. I have tried various suggestions, but look like I am missing something simple. Physics is false. Any suggestions or links to existing docs? Thanks.


Reply to this email directly or view it on GitHub.

@rmasrani
Copy link

Hi Alex. I did that, and I turned off physics. In fact, I tried practically every combination of manipulation I could think of – no luck.

From: Alex [mailto:[email protected]]
Sent: November 11, 2015 11:59 PM
To: almende/vis [email protected]
Cc: rmasrani [email protected]
Subject: Re: [vis] Network: set initial position for nodes, but let them wander freely afterwards (#215)

Hi,

It could be due to a bug in the improvedLayout. Try turning that off.

Cheers!

On 12 nov. 2015, at 00:39, rmasrani [email protected] wrote:

Hi Alex. Thanks for the great work. I have just started using your application, and have the following (I am afraid simple) problem. I have a network with 14,000 nodes and about 30,000 edges. I am able to create the network fine (it takes time). I saved the x/y coordinates, and created a JSON with these hard coded. Problem is that the network with the original output looks very different than the network with the x/y coordinates built in. I have tried various suggestions, but look like I am missing something simple. Physics is false. Any suggestions or links to existing docs? Thanks.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub #215 (comment) .

@AlexDM0
Copy link
Contributor

AlexDM0 commented Nov 12, 2015

Hi,

It would help a lot if I could see the code. Is it shareable? Or reproducible? Our examples do work with fixed locations.

Regards

On 12 nov. 2015, at 09:07, rmasrani [email protected] wrote:

Hi Alex. I did that, and I turned off physics. In fact, I tried practically every combination of manipulation I could think of – no luck.

From: Alex [mailto:[email protected]]
Sent: November 11, 2015 11:59 PM
To: almende/vis [email protected]
Cc: rmasrani [email protected]
Subject: Re: [vis] Network: set initial position for nodes, but let them wander freely afterwards (#215)

Hi,

It could be due to a bug in the improvedLayout. Try turning that off.

Cheers!

On 12 nov. 2015, at 00:39, rmasrani [email protected] wrote:

Hi Alex. Thanks for the great work. I have just started using your application, and have the following (I am afraid simple) problem. I have a network with 14,000 nodes and about 30,000 edges. I am able to create the network fine (it takes time). I saved the x/y coordinates, and created a JSON with these hard coded. Problem is that the network with the original output looks very different than the network with the x/y coordinates built in. I have tried various suggestions, but look like I am missing something simple. Physics is false. Any suggestions or links to existing docs? Thanks.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub #215 (comment) .


Reply to this email directly or view it on GitHub.

@rmasrani
Copy link

Can you share your email ID?

@AlexDM0
Copy link
Contributor

AlexDM0 commented Nov 12, 2015

I'd prefer to discuss this on github since multiple people may have this issue.

Regards

@rmasrani
Copy link

Ok – will do. I will try to get the code down to the core and set it up on fiddle. I wonder if it is the volume of nodes that is throwing it off. But I will experiment and let you know.

From: Alex [mailto:[email protected]]
Sent: November 12, 2015 4:30 AM
To: almende/vis [email protected]
Cc: rmasrani [email protected]
Subject: Re: [vis] Network: set initial position for nodes, but let them wander freely afterwards (#215)

I'd prefer to discuss this on github since multiple people may have this issue.

Regards


Reply to this email directly or view it on GitHub #215 (comment) .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants