jacomyal / sigma.js

A JavaScript library aimed at visualizing graphs of thousands of nodes and edges
https://www.sigmajs.org/
MIT License
11.25k stars 1.59k forks source link

ForceAtlas2 - node spacing #613

Closed ekkis closed 2 years ago

ekkis commented 9 years ago

I'm using the ForceAtlas2 layout and have looked through its documentation looking for a way to indicate a minimum distance between nodes. currently the algorithm lays the nodes out too tightly together such that they over lap and can't be read so I'd like a little more sparsity. is there a way to do it?

apitts commented 9 years ago

@ekkis - please see the below related issue: https://github.com/jacomyal/sigma.js/issues/107

Short answer, no but there is some guidance in that issue on how to do it (I myself have not attempted it yet).

Yomguithereal commented 9 years ago

Hello @ekkis. You should indeed try the solution explained in #107 and see whether this can fix your problem. Tell me whether you have issues implementing it.

ekkis commented 9 years ago

thank you both. I read through the solution but it isn't clear to me how to proceed. is line 149 in the code shown what I'm supposed to change to? or is the suggestion that I need to change that to something else (left unspecified)? when I look at my version of the file, I see nodes[i].size

ekkis commented 9 years ago

just for kicks I tried setting it to 8 * nodes[i].size but it doesn't help much, though I did notice that turning adjustSizes on seems to help a little but frankly, whatever algo the built-in display from Neo4j is so much nicer

Yomguithereal commented 9 years ago

Yes, first you should use adjustSizes. Secondly, you have to understand that you should give the size as they are rendered by your main renderer to the layout algorithm to see the anti-collision work better (by default, the anti-collision will work on the nodes' absolute size, not the rendered one, hence your problem).

I really need to add an option to do this easily but I currently lack time unfortunately.

Yomguithereal commented 9 years ago

You can try:

nodes[i]['cam0:size']
// or
nodes[i]['renderer0:size']

for instance, if you don't have any precise renderer or camera instantiated through addCamera/addRenderer.

Or check the properties of you nodes to find a fitting size.

ekkis commented 9 years ago

wow. that substantially changed the way the graph gets laid out. unfortunately, for the worse, for example I have nodes that are linked to large numbers of otherwise unconnected nodes. they used to cluster around their one connection in a big circle which got separated from the rest of the graph, now it all remains scattered with long edges

Yomguithereal commented 9 years ago

Are you going to apply the layout on a single specific graph or on any one in a tool? Typically, what people tend to do when applying a scientific layout algorithm such as ForceAltas2 is to let the graph spatialize without anti-collision then apply anti-collision at the end of the very end of process only, for legibility purposes.

Side question: are you familiar with Gephi?

ekkis commented 9 years ago

@Yomguithereal, I'm not yet certain how exactly I will use the graph (this is the first project I work on with a graph database). the first thought is just get all the data out there in a graph and let the user look around, but ultimately that will be less useful than other approaches, so we envision using filters and creating a number of pre-canned queries to answer specific questions that get answered with a graph.

I also like the way the graphs built into Neo4j work where a graph may display a subset of nodes but the user can double-click to discover neighbours. that way we don't overwhelm the user with a huge graph but they can work their way in the direction of interest. I have yet to research how that could be implemented in Linkurious

for now I've been working my way towards a lot of the functionality in the examples - I want all that richness in a single graph. in my view it would be better to have 1 example with all the features, rather than all these various examples. there's a lot about the documentation that isn't clear for the newbie like multiple ways to create node shapes, the presence of legacy modules that have been replaced by better code and not much clarity on basic structure and the myriad options that can be turned on.

so this has been much lengthier challenge for me than I would have expected.

and, no, I've not looked into Gephi. it looks like a competitor to Linkurious but substantially more complex. can I use it with Neo4j data sources?

ekkis commented 9 years ago

to let the graph spatialize without anti-collision then apply anti-collision at the end of the very end of process only

is there guidance on how this would be accomplished with Linkurious?

emergingdzns commented 9 years ago

I know this is an old issue/thread, but I want to throw my hat in here too. When force atlas runs, it causes all kinds of overlap, both with nodes and with labels. It does seem as though the node center point isn't overlapping any other node, but their circles do overlap. The labels are terrible. I've been trying to find a solution, but I'm at a loss. Has anyone found a solution to this?

rangeonnicolas commented 8 years ago

Hello!

Here is how I fixed it :

1/ before instancing the sigma class : sigma.settings.nodesPowRatio = 1; sigma.settings.autoRescale = false;

2/ Then I corrected the file /plugins/sigma.layout.forceAltas2/worker.js: I replaced all occurrences of adjustSize ) by adjustSizes ) (see https://github.com/rangeonnicolas/sigma.js/commit/3c8a1e63291e3de7d201693d11f198ab8ea84712 )

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.