mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 06:32:55 -04:00
improved clustering effect with a non linear edge length
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3739 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0fcc298801
commit
c5a8d25067
3 changed files with 23 additions and 27 deletions
|
@ -138,16 +138,26 @@ void Node::calculateForces(const double *map,int width,int height,int W,int H,fl
|
|||
yforce = REPULSION_FACTOR * dej/25.0;
|
||||
|
||||
// Now subtract all forces pulling items together
|
||||
double weight = (edgeList.size() + 1) ;
|
||||
double weight = (n_edges() + 1) ;
|
||||
|
||||
foreach (Edge *edge, edgeList) {
|
||||
QPointF pos;
|
||||
double w2 ; // This factor makes the edge length depend on connectivity, so clusters of friends tend to stay in the
|
||||
// same location.
|
||||
//
|
||||
if (edge->sourceNode() == this)
|
||||
{
|
||||
pos = mapFromItem(edge->destNode(), 0, 0);
|
||||
w2 = sqrtf(std::min(n_edges(),edge->destNode()->n_edges())) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = mapFromItem(edge->sourceNode(), 0, 0);
|
||||
w2 = sqrtf(std::min(n_edges(),edge->sourceNode()->n_edges())) ;
|
||||
}
|
||||
|
||||
float dist = sqrtf(pos.x()*pos.x() + pos.y()*pos.y()) ;
|
||||
float val = dist - graph->edgeLength() ;
|
||||
float val = dist - graph->edgeLength() * w2 ;
|
||||
|
||||
xforce += 0.01*pos.x() * val / weight;
|
||||
yforce += 0.01*pos.y() * val / weight;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue