Inverted edge weigh in layout algorithms (e.g. ForceAtlas2,...) #1816
Description
Current Behavior
Currently the interpretation of the edge weight (W) in Gephi (or at least in the ForceAtlas2 layout algorithm) is such, that higher W is interpreted as "stronger connection" and is reflected also in the thickness of the line representing the edge. However other algorithms often interpret W in a inverse fashion, where W is the cost/penalty for "going through" the edge, e.g. when searching for shortest paths (notably the NetworkX routines). Neither way is right or wrong - it is more a "philosophical" question which interpretation will be canonical. But this discrepancy results in some counter-intuitive consequences, such as e.g. when I obtain the shortest path from NetworkX and look at it in Gephi (after node distribution with ForceAtlas2), then it passes through distant nodes connected by thin lines.
It would be therefore beneficial to include an option that would make it possible to obtain a graph layout with the inverse interpretation of W.
Expected Behavior
The expected behaviour would be such, that nodes connected via edges with smaller W would have stronger attraction than those with larger W. Also the line thickness should be inverted to current state.
Possible Solution
I have discussed this (via e-mail) with Mathieu Jacomy, who confirmed the above mentioned interpretation. He suggested that I may create a pull. However, I’m afraid I’m not confident enough to modify someone’s else’s code and resume responsibility for it working correctly. There are however two simple solutions for addressing this issue that come to mind:
-
Use the inverse of W in the calculation of the attractive force between connected nodes (eq. 6 in the ForceAtlas2 paper, https://doi.org/10.1371/journal.pone.0098679). So F_attr ~ 1/W. Here also the display of the edge (line thickness) would have to be modded.
-
Rescale all W in such way, that the ones with largest W become the ones wit smallest W. i.e. idetify edge with largest W (W_max) and smallest W (W_min) and calculate new edge weights as:
W_new = W_max - W_current + W_min
(W_min is added just so the originally strongest edge will not become 0, thus deleted) In this case obviously the original concept of F_attr ~ W will be kept. Here the display of the edge (line thickness) would not need to be modded.
In principle either of the two options could be included as a clickable option that can be selected/de-selected in the option menu for ForceAtlas2 where other parameters are set.
There is currently a pull by astraey to rescale edge weights when negative W is in the graph (#1733). So he already knows what to modify in case of scenario 2.
Could be useful for many people, since NetworkX has now the option to dump graphs into .gexf format by one command https://networkx.github.io/documentation/stable/reference/readwrite/gexf.html but it obviously writes the weight that are used in NetworkX.
I would really appreciate if this could be solved ;) Thanks'.
Steps to Reproduce
Context
Your Environment
- Version used: Gephi 0.9.2
- Java version:
- Operating System: