00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "ne_evo.h"
00024 #include <stdio.h>
00025
00026
00027 ne_err_code_t ne_evo_initial (ne_sys_t *sys, FILE *evoFile)
00028 {
00029 int i, nodes, edges;
00030 char curStrBuffer[100];
00031
00032 nodes = ne_sys_nodes(sys);
00033 edges = ne_sys_nodes(sys);
00034
00035 for (i=0; i<nodes; i++) {
00036 ne_evo_add_node(curStrBuffer, 0);
00037 fprintf(evoFile, "%s", curStrBuffer);
00038 }
00039
00040 for (i=0; i<edges; i++) {
00041 ne_evo_add_edge(curStrBuffer, (ne_int_t)IGRAPH_FROM(sys->graph, i),
00042 (ne_int_t)IGRAPH_TO(sys->graph, i), 0);
00043 fprintf(evoFile, "%s", curStrBuffer);
00044 }
00045
00046 fprintf(evoFile, "%s", ne_evo_step(NE_STEP_PAUSE));
00047 fflush(evoFile);
00048
00049 return NE_SUCCESS;
00050 }
00051
00052
00053 ne_err_code_t ne_evo_add_node (char *str, ne_int_t type)
00054 {
00055 sprintf(str, "N+,%i\n", (int)type);
00056 return NE_SUCCESS;
00057 }
00058
00059
00060 ne_err_code_t ne_evo_del_node (char *str, ne_int_t node)
00061 {
00062 sprintf(str, "N-,%i\n", (int)node);
00063 return NE_SUCCESS;
00064 }
00065
00066
00067 ne_err_code_t ne_evo_add_edge (char *str, ne_int_t startNode, ne_int_t endNode, ne_int_t type)
00068 {
00069 sprintf(str, "E+,%i,%i,%i\n", (int)startNode, (int)endNode, (int)type);
00070 return NE_SUCCESS;
00071 }
00072
00073
00074 ne_err_code_t ne_evo_del_edge (char *str, ne_int_t startNode, ne_int_t endNode)
00075 {
00076 sprintf(str, "E-,%i,%i\n", (int)startNode, (int)endNode);
00077 return NE_SUCCESS;
00078 }
00079
00080
00081 ne_err_code_t ne_evo_set_node_type (char *str, ne_int_t node, ne_int_t type)
00082 {
00083 sprintf(str, "N!,%i,%i\n", (int)node, (int)type);
00084 return NE_SUCCESS;
00085 }
00086
00087
00088 ne_err_code_t ne_evo_set_edge_type (char *str, ne_int_t startNode, ne_int_t endNode, ne_int_t type)
00089 {
00090 sprintf(str, "E!,%i,%i,%i\n", (int)startNode, (int)endNode, (int)type);
00091 return NE_SUCCESS;
00092 }
00093
00094
00095 char * ne_evo_step (ne_evo_step_t type)
00096 {
00097 if (type == NE_STEP_PAUSE) return "---\n";
00098 else if (type == NE_STEP_DYN) return "-\n";
00099 else if (type == NE_STEP_EVO) return "--\n";
00100 else return "";
00101 }
00102