adolfoalvarez / Force-Atlas-2

R implementation of the Force Atlas 2 algorithm
11 stars 2 forks source link

node_ids? #1

Open supersambo opened 9 years ago

supersambo commented 9 years ago

Hi, I was looking for an implementation of ForceAtlas2 for a long time. Thank you for this valuable work!

However I'm not sure if I use this the right way. The functions just returns positions and I'am not sure which positions correspond to which node. I changed the outcome of the function to:

position <- as.data.frame(position)
ids <- data.frame(id=sort(unique(c(PairedData[,1],PairedData[,2]))))
position <- cbind(ids, position) 
return(position)

is this returning the right ids? Line 2 comes from AdjacencyMatrix function inside forceatlas2.

Best, stephan

adolfoalvarez commented 9 years ago

Hi Stephan, thank you for the suggestion. To be honest, this is a very preliminar code and there are still many improvements to incorporate, some of them are done and I hope soon I will upload those changes.

Regarding the "ids", I agree that incorporating the ids can make the output more clear, although we are planning to make this compatible with the igraph layouts (http://www.inside-r.org/packages/cran/igraph/docs/layout ), where just positions are returned.

Thank you very much!

supersambo commented 9 years ago

Hi again, good to know that you are planning to connect this to igraph! I would be great if the function would take igraph objects as input. Then its not necessary to return ids since the coordinates would correspond to the Vertex sequence V(g) of the igraph object, like the builtin layout-functions of this library.

I was just confused because now the input is an edgelist and I didn't see how to get to the correct Vertex Sequence, in order to attach the results to my Nodes table. The code snippet I provided wasn't really meant to be a suggestion. I just wanted to verify if I'am interpreting the results in the correct manner?

After all, being just very preliminary code this is working quite well already. I'm very looking forward to your updates and I'm really appreciating this work. I use Gephi mainly because of this algorithm but I'd prefer to do all my workflow in R.

Best, stephan

adolfoalvarez commented 9 years ago

Hi Stephan, I have updated the function, now should be a bit faster and igraph compatible. Please let me know if it works with your data. Thanks!

supersambo commented 9 years ago

Hi Adolfo, thank you for the update. It works great. I like the updating plot! I Tested it with les miserables but I'm going to try out larger networks from my own work in the next days!