• Main Page
  • Data Structures
  • Files
  • File List
  • Globals

ne_evo.c

00001 /*===========================================================================
00002  NetEvo Foundation Library
00003  Copyright (C) 2009, 2010 Thomas E. Gorochowski <tgorochowski@me.com>
00004  Bristol Centre for Complexity Sciences, University of Bristol, Bristol, UK
00005  ---------------------------------------------------------------------------- 
00006  NetEvo is a computing framework designed to allow researchers to investigate 
00007  evolutionary aspects of dynamical complex networks. By providing tools to 
00008  easily integrate each of these factors in a coherent way, it is hoped a 
00009  greater understanding can be gained of key attributes and features displayed 
00010  by complex systems.
00011  
00012  NetEvo is open-source software released under the Open Source Initiative 
00013  (OSI) approved Non-Profit Open Software License ("Non-Profit OSL") 3.0. 
00014  Detailed information about this licence can be found in the COPYING file 
00015  included as part of the source distribution.
00016  
00017  This library is distributed in the hope that it will be useful, but
00018  WITHOUT ANY WARRANTY; without even the implied warranty of
00019  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
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 

Generated on Thu Aug 26 2010 11:04:24 for NetEvo by  doxygen 1.7.1