00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <test.h>
00037 #include <configuration.h>
00038 #include "network_graph.h"
00039 #include "ksection.h"
00040
00041
00042 #define MAX_SCALE 7
00043
00044
00045 int main(int argc, char *argv[])
00046 {
00047 int error = 0, i, j, k = 4;
00048 int max_scale = MAX_SCALE;
00049
00050 if (argc > 1)
00051 max_scale = atoi(argv[1]);
00052
00053 printf("\n");
00054 for (i = 2; i <= max_scale; i++) {
00055 int num_nodes = (int) pow(2.0, (double) i);
00056 FILE *file;
00057 Configuration config("WGS 84");
00058
00059 if ((file = fopen("test_tmp.cfg", "w")) == NULL) {
00060 perror("test_tmp.cfg");
00061 return -errno;
00062 }
00063
00064 fprintf(file, "<?xml version=\"1.0\"?>\n");
00065 fprintf(file, "<sensor_net>\n");
00066 fprintf(file, " <topology>\n");
00067 fprintf(file, " <name>Test %d</name>\n", i);
00068 fprintf(file, " <viewpoint>\n");
00069 fprintf(file, " <latitude>35.871334</latitude>\n");
00070 fprintf(file, " <longitude>-106.326067</longitude>\n");
00071 fprintf(file, " <range>500</range>\n");
00072 fprintf(file, " <tilt>0</tilt>\n");
00073 fprintf(file, " <heading>0</heading>\n");
00074 fprintf(file, " </viewpoint>\n");
00075 for (j = 0; j < num_nodes; j++) {
00076 fprintf(file, " <node id=\"%d\">\n", j);
00077 fprintf(file, " <random size=\"500\"/>\n");
00078 fprintf(file, " </node>\n");
00079 }
00080 fprintf(file, " </topology>\n");
00081 fprintf(file, " <network_data>\n");
00082 fprintf(file, " </network_data>\n");
00083 fprintf(file, "</sensor_net>\n");
00084 fclose(file);
00085
00086 if ((error = config.open("test_tmp.cfg")) < 0) {
00087 printf("Failed to load %d-node config.\n",
00088 num_nodes);
00089 goto end;
00090 }
00091
00092
00093 Network_graph g(&config);
00094 Ksection assignments(&g, k);
00095 printf("%d-section successfully drawn from %d-node graph.\n",
00096 k, num_nodes);
00097
00098 #if 0
00099 assignments.print();
00100 #endif
00101 }
00102
00103 end:
00104 return error;
00105 }