-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inverted edge weigh in layout algorithms (e.g. ForceAtlas2,...) #1816
Comments
Hi, I guess it would not be too difficult to implement. I will take a look. |
Yes, that is how I intended (imagined) it to be - check/uncheck to change the usage of W. Thank you eduramiba |
@eduramiba , I'm trying to calculate shortest path using the shortest path feature, my data have weights and higher the weight, stronger the nodes connection. However, the shortest path in Gephi, chooses the one with lowest weight. I understand, this topic is talking about the same issue, what I didn't understand, is the resolution you provided. Can you please explain how I can achieve the shortest path using the highest weight? Thank you for you time!!! |
@worknet-bienew I think it's not implemented yet - it's added to the wishlist & maybe will be in 0.9.3. |
vlado-s thank you for your response. I believe Gephi uses Dijkstra’s algorithm to calculate the shortest path which considers lower weights to find the shortest distance. For this reason, I wish there was something called longest distance algorithm ;) Anyway, at least I know it's not possible in Gephi. Would you know what happens, when I remove the weights or make them all equal to 1, how does it calculate the shortest path? Does it consider highest degree? |
Comments:
|
Issue not exactly addressed, but note that a setting to normalize edge weights between 0 and 1 has been added to Force Atlas 2. 86ca069 |
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
The text was updated successfully, but these errors were encountered: