资源简介
用C++ 写的 SIS疾病传播模型
直接读取路径下的 TXT文件
TXT文件中只要存储边就可以了

代码片段和文件信息
#include
#include
#include
using namespace std;
#define MAX 10000
#define SIZE 4194 // define the total number of edges
#define V 1000
#define infected 0 //different status
#define fine 1
#define InPro 250
#define RePro 10
#define T 1000 // how many wave of infection
#define Tmax 50000 // ten thousand random numbers
static int infectNumber[T]; // define the total number of infected people
int random[Tmax]; //the random number array
long int rcount;
/* now i need to define a class to run the whole program*/
struct node
{
int status; //infected or not infected
struct node* next; //next pointer
int nodeId; // illustrate the node‘s ID
};
typedef struct node N;
typedef N* nptr;
class Model
{
private:
int edge[SIZE];
node verticle[V]; //array of verticle
nptr work[V]; // working pointer add node or scan node
public:
Model(); //construction and release function
~Model();
int Iprobability(int k int s); //k means the probability needed return 1 or 0
int Fprobability(int k int s); //k means the probability to recover from disease
void update(int time); //update the network
void output(); //output the result
void Run(); // whole running function
};
Model::Model()
{
for(int i=0 ; i< T ; i++)
{
infectNumber[T] = 0;
}
/* initiate pointer and other */
for(int i=0; i < V ; i++)
{
verticle[i].status= fine ;
verticle[i].next= NULL; //pointer initiation
verticle[i].nodeId= i ;
work[i]= NULL;
}
/* this block has be verified to read data*/
/* data is stored in a[i] maybe i should split it into two part*/
ifstream fin(“edgeout.txt“);
int edge[SIZE]; // the total number of data is SIZE
for(int i = 0; i < SIZE ; i++)
{
fin>>edge[i]; //save the data
}
fin.close();
/* this block has be verified to read data*/
/* build the verticle table */
for(int i=0 ; i < SIZE ; i++)
{
if( i % 2== 0 ) //judge even or odd
{
if ( work[edge[i]] == NULL )
{
work[edge[i]] = &verticle[edge[i]]; // if hasn‘t been created create it
nptr s= new N;
s->nodeId = edge[i+1];
s->status=fine;
s->next=NULL;
work[edge[i]]->next= s ;
work[edge[i]] = s ;
}
else
{
nptr s= new N;
s->nodeId = edge[i+1];
s->stat
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 18882 2013-06-13 23:30 src\BAedge.txt
文件 7372 2013-06-14 00:27 src\main.cpp
文件 244495 2013-06-13 17:00 src\newRandom.txt
文件 58492 2013-06-13 21:16 src\NWedge.txt
文件 39018 2013-06-12 22:36 src\random.txt
文件 4997 2013-06-14 00:27 src\result.txt
文件 163 2013-06-14 15:46 src\说明.txt
目录 0 2013-06-22 21:09 src
----------- --------- ---------- ----- ----
373419 8
- 上一篇:高仿QQ截图
- 下一篇:socket应用二 用C语言写远程屏幕监视程序 源代码
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- c++ 画图(14Qt-XPS)
- c++多边形交并差运算
评论
共有 条评论