Bugfix + polishing
authoralpar
Tue, 07 Nov 2006 21:27:28 +0000
changeset 180911c6ba0e3c8
parent 179 1f436ea3ef4f
child 181 2a9f611989df
Bugfix + polishing
graph_displayer_canvas.cc
     1.1 --- a/graph_displayer_canvas.cc	Mon Nov 06 15:40:44 2006 +0000
     1.2 +++ b/graph_displayer_canvas.cc	Tue Nov 07 21:27:28 2006 +0000
     1.3 @@ -320,8 +320,6 @@
     1.4        actual_forces.setXMap(x);
     1.5        actual_forces.setYMap(y);
     1.6  
     1.7 -      lemon::dim2::Point<double> delta;
     1.8 -
     1.9        //count actual force for each nodes
    1.10        for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    1.11  	{
    1.12 @@ -330,17 +328,14 @@
    1.13  	    {
    1.14  	      if(i!=j)
    1.15  		{
    1.16 -		  delta=((mytab.mapstorage).coords[i]-(mytab.mapstorage).coords[j]);
    1.17 +		  lemon::dim2::Point<double> delta =
    1.18 +		    ((mytab.mapstorage).coords[i]-
    1.19 +		     (mytab.mapstorage).coords[j]);
    1.20  
    1.21 -		  double length_sqr=delta.normSquare();
    1.22 -		  double length=sqrt(length_sqr);
    1.23 -		  if(length_sqr<min_dist)
    1.24 -		    {
    1.25 -		      length_sqr=min_dist;
    1.26 -		    }
    1.27 +		  const double length_sqr=std::max(delta.normSquare(),min_dist);
    1.28  
    1.29  		  //normalize vector
    1.30 -		  delta/=length;
    1.31 +		  delta/=sqrt(length_sqr);
    1.32  
    1.33  		  //calculating propulsation strength
    1.34  		  //greater distance menas smaller propulsation strength
    1.35 @@ -352,43 +347,29 @@
    1.36  	  //attraction of nodes, to which actual node is bound
    1.37  	  for(OutEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei)
    1.38  	    {
    1.39 -	      delta=((mytab.mapstorage).coords[i]-(mytab.mapstorage).coords[mytab.mapstorage.graph.target(ei)]);
    1.40 -
    1.41 -	      double length_sqr=delta.normSquare();
    1.42 -	      double length=sqrt(length_sqr);
    1.43 -	      if(length_sqr<min_dist)
    1.44 -		{
    1.45 -		  length_sqr=min_dist;
    1.46 -		}
    1.47 -
    1.48 -	      //normalize vector
    1.49 -	      delta/=length;
    1.50 -
    1.51 -	      //calculating attraction strength
    1.52 -	      //greater distance means greater strength
    1.53 -	      delta*=attraction*length;
    1.54 -
    1.55 -	      actual_forces.set(i,actual_forces[i]-delta);
    1.56 +	      lemon::dim2::Point<double> delta =
    1.57 +		((mytab.mapstorage).coords[i]-
    1.58 +		 (mytab.mapstorage).coords[mytab.mapstorage.
    1.59 +					   graph.target(ei)]);
    1.60 +		
    1.61 +		//calculating attraction strength
    1.62 +		//greater distance means greater strength
    1.63 +		delta*=attraction;
    1.64 +		
    1.65 +		actual_forces.set(i,actual_forces[i]-delta);
    1.66  	    }
    1.67  	  for(InEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei)
    1.68  	    {
    1.69 -	      delta=((mytab.mapstorage).coords[i]-(mytab.mapstorage).coords[mytab.mapstorage.graph.source(ei)]);
    1.70 -
    1.71 -	      double length_sqr=delta.normSquare();
    1.72 -	      double length=sqrt(length_sqr);
    1.73 -	      if(length_sqr<min_dist)
    1.74 -		{
    1.75 -		  length_sqr=min_dist;
    1.76 -		}
    1.77 -
    1.78 -	      //normalize vector
    1.79 -	      delta/=length;
    1.80 -
    1.81 -	      //calculating attraction strength
    1.82 -	      //greater distance means greater strength
    1.83 -	      delta*=attraction*length;
    1.84 -
    1.85 -	      actual_forces.set(i,actual_forces[i]-delta);
    1.86 +	      lemon::dim2::Point<double> delta =
    1.87 +		((mytab.mapstorage).coords[i]-
    1.88 +		 (mytab.mapstorage).coords[mytab.mapstorage.
    1.89 +					   graph.source(ei)]);
    1.90 +		
    1.91 +		//calculating attraction strength
    1.92 +		//greater distance means greater strength
    1.93 +		delta*=attraction;
    1.94 +		
    1.95 +		actual_forces.set(i,actual_forces[i]-delta);
    1.96  	    }
    1.97  	}
    1.98        for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)