Force-directed graphing

拈花ヽ惹草 提交于 2019-12-06 15:45:31

问题


I'm trying to write a force-directed or force-atlas code base for a graphing application I'm building for myself. Here is an example of what I'm attempting: http://sawamuland.com/flash/graph.html

I managed to find some pseudo code to accomplish what I'd like on the Wiki Force-atlas article. I've converted this into ActionScript 3.0 code since it's a Flash application. Here is my source:

var timestep:int = 0;
var damping:int  = 0;
var total_kinetic_engery:int = 0;

for (var node in list) {
 var net_force:int = 0;
 for (var other_node in list) {
  net_force += coulombRepulsion(node, other_node, nodeList);
 }
 for (var spring in list[node].relations) {
  net_force += hookeAttraction(node, spring, nodeList);
 }
 list[node].velocity += (timestep * net_force) * damping;
 list[node].position += timestep * list[node].velocity;
 total_kinetic_engery += list[node].mass * (list[node].velocity) ^ 2;
}

The problem now is finding pseudo code or a function to perform the the coulomb repulsion and hooke attraction code. I'm not exactly sure how to accomplish this.

Does anyone know of a good reference I can look at...understand and implement quickly?

Best.


回答1:


There are links to these in the same article. Hooke's is the spring force between end-nodes of a link, while Coulomb's force repels nearby nodes away.

The question is not really the expressions, but the constants applied inside them. I would read the original article, google for "Fruchterman, T. M. J., & Reingold, E. M. (1991). Graph Drawing by Force-Directed Placement. Software: Practice and Experience, 21(11)." and read through the pdf to see what the authors suggest.

Btw, your vars may have to be floats, not integers.




回答2:


have you looked at flare? there is a demo with a force-directed graph.



来源:https://stackoverflow.com/questions/1494452/force-directed-graphing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!