@@ -68,41 +68,40 @@ public void CalculteAllNodesEnergy(ConnectionType connectionType, Dictionary<Poi
68
68
break ;
69
69
70
70
case ConnectionType . PP_to_Route :
71
+ Start_PP_ToRoute ( cluster , stationHeight , routeList ) ;
71
72
break ;
72
73
}
73
74
}
74
75
}
75
76
77
+ public void Start_PP_ToRoute ( List < Point > cluster , int stationHeight , List < Point > routeList ) {
78
+ Point center = Calculator . findCentroid ( cluster ) ;
79
+ List < Point > routeFragment = Calculator . getRouteFragment ( center , routeList ) ;
80
+
81
+ }
82
+
76
83
public void Start_PP_Protocol ( List < Point > cluster , int stationHeight ) {
77
84
78
- Console . WriteLine ( "Start PP" ) ;
79
85
Point center = Calculator . findCentroid ( cluster ) ;
80
86
81
- //if (cluster.Count == 1)
82
- // PPConnection(cluster[0], center, stationHeight);
83
- //else
84
- foreach ( Point point in cluster )
85
- {
86
- Point currentPoint = point ;
87
-
88
- while ( ! currentPoint . Equals ( center ) )
89
- {
90
- Point closer = Calculator . FindCloserPoint ( currentPoint , cluster ) ;
91
- Console . WriteLine ( "cur - closer " + currentPoint + "-" + closer ) ;
92
- double distPCE = Calculator . calcDistance ( currentPoint , center ) ; //point - center
93
- double distPCL = Calculator . calcDistance ( currentPoint , closer ) ; //point - closer
94
-
95
- if ( distPCE <= distPCL )
96
- {
97
- currentPoint = center ;
98
- PPConnection ( point , center , stationHeight ) ;
99
- }
100
- else
101
- {
102
- PPConnection ( point , closer , 0 ) ;
103
- currentPoint = closer ;
87
+ for ( int i = 0 ; i < cluster . Count ; i ++ ) {
88
+
89
+ Point closer = center ;
90
+ double dist_i_to_center = Calculator . calcDistance ( cluster [ i ] , center ) ;
91
+ double dist_to_closer = dist_i_to_center ;
92
+
93
+ for ( int j = 0 ; j < cluster . Count ; j ++ ) {
94
+ if ( i != j ) {
95
+ double dist_to_node = Calculator . calcDistance ( cluster [ i ] , cluster [ j ] ) ;
96
+ double dist_j_to_center = Calculator . calcDistance ( cluster [ j ] , center ) ;
97
+ if ( dist_to_node < dist_to_closer && dist_j_to_center < dist_i_to_center ) {
98
+ closer = cluster [ j ] ;
99
+ dist_to_closer = dist_to_node ;
100
+ }
104
101
}
105
102
}
103
+
104
+ PPConnection ( cluster [ i ] , closer , 0 ) ; // high!!!
106
105
}
107
106
}
108
107
@@ -157,7 +156,7 @@ public int PPConnection(Point node, Point station, int stationHeight) { // trans
157
156
158
157
if ( dist < d0 ) {
159
158
E_transmission = package * E_elec + package * E_fs * Math . Pow ( dist , 2 ) ; // nJ
160
- graphic . DrawLine ( node , station , Color . LightGreen ) ;
159
+ graphic . DrawLine ( node , station , Color . Olive ) ;
161
160
}
162
161
else
163
162
//E_transmission = package * E_elec + package * E_mp * Math.Pow(dist, 4); // nJ
0 commit comments