Esempio n. 1
0
void
getNet_from_config(char* dirname, 
                                     char * degfilename, 
                                     char * graphfilename,
                                     int nodeNum )
{
	int i;
	int j;
	int adj;
	int node;
	struct network* target;
	char path1[200];
	int *degree;
	FILE * graphFile;
	FILE * netFile;
	int error;
	
	// 1) read the network data from the degfilename file 
	
	strcpy(path1,dirname);
	strcat(path1,degfilename);
	
	getDegreeSequence(path1, nodeNum, &degree);

	printf("herere  ---- \n");
	target=(struct network *)mem_alloc(sizeof(struct network));
	initNetwork(target, nodeNum, 0);

	strcpy(path1,dirname);
	strcat(path1,graphfilename);

	graphFile = fopen(path1, "r");
	i=1;
	while(1)
	{
		error=fscanf(graphFile, "%d ", &node);
		if(error==-1)
		{
				break;
		}
		for(j=1;j<=degree[i];j++)
		{
			error=fscanf(graphFile, "%d ", &adj);
			error=0;
			error+=addLinkToNetwork(target, node+1, adj+1, 1.0);
			error+=addLinkToNetwork(target, adj+1, node+1, 1.0);
			
		}
		i++;
	}
	 fclose(graphFile);

	 strcat(path1,"_net.txt");
	 netFile=fopen(path1,"w");
	 outputNetwork(target, netFile);

	 fclose(netFile);
	 freeNetwork(target);
	 mem_free(degree);
}
Esempio n. 2
0
void
getNet_from_DegS(char* dirname, char * degfilename, int nodeNum)
{

	struct network* target;
	char path1[200];
	int *degree;
	FILE * netFile;
	
	// 1) read the network data from the raw-data file 
	
	strcpy(path1,dirname);
	strcat(path1,degfilename);
	
	getDegreeSequence(path1, nodeNum, &degree);

	printf("herere  ---- \n");
	target=(struct network *)mem_alloc(sizeof(struct network));
	configModel(target,nodeNum, degree);	

       
	 strcat(path1,"_net.txt");
	 netFile=fopen(path1,"w");
	 outputNetwork(target, netFile);

	 fclose(netFile);
	 freeNetwork(target);
	 mem_free(degree);
}
Esempio n. 3
0
void 
kshell_test()
{
	int *shell;
	struct network * target;
	int i;

	target=NULL;
	target=(struct network *)mem_alloc(sizeof(struct network));
	
	initNetwork(target, 3, UN_DIRECT_UN_WEIGHT);

	//  link info
	addLinkToNetwork(target,1,2,1.0);

	addLinkToNetwork(target,2,1,1.0);
	addLinkToNetwork(target,2,3,1.0);

	addLinkToNetwork(target,3,2,1.0);
	
	shell=(int *)mem_alloc((1+target->nodeNum)*sizeof(int));


	
	getKshell(target, shell);

	for(i=1;i<=target->nodeNum;i++)
	{
		printf("node %d : shell %d \n",i,shell[i]);
	}

	freeNetwork(target);
	mem_free(shell);
	
}
Esempio n. 4
0
void ba_pk()
{
	int i;
	int m0,m,N;
	FILE * pFile_pk;
	char file_name[20];
	int name_size;
	struct network * target;

		
	m0=2;
	m=2;
	N=100000;
	name_size=20;
	
	for(i=1;i<=5;i++)
	{
		memset(file_name,0, name_size);
		sprintf(file_name, "pk_ba_%d.txt",i);
		pFile_pk=fopen(file_name, "a");
		target=(struct network *)mem_alloc(sizeof(struct network));			
		baModel(target, m0, m, N);

	
		outputpk(target, pFile_pk);

		fclose(pFile_pk);
		freeNetwork(target);
	}
		
	
}
Esempio n. 5
0
void readRouter()
{
	////FILE * datafile;
	FILE * outfile;
	struct network* target;
	////int id1;
	////int id2;
	////double weight;
	////int error;
	////int totalNum;
	struct netInfo* netinfo;
	struct CLSTS* clsts;
	FILE * pFile_node;
	FILE * pFile_pajek;

	// 2) analyze the properties
	target=NULL;
	outfile=fopen("./realdata/Router_net.txt", "r");
	inputNetwork(&target, outfile);
	fclose (outfile);

	printf("\n %d %d \n", target->nodeNum, target->linkNum);

	// getNetwork Info
	netinfo=(struct netInfo*)mem_alloc(sizeof(struct netInfo));
	initNetInfo(netinfo, target);
	getBasicNetInfo(target, netinfo);
	clsts=NULL;
	getCLSTS(target,&clsts);
	getClstNetInfo(target, clsts, netinfo); 

	pFile_node=fopen("Router_node.txt", "w");
	outputNodeInfo(netinfo, pFile_node);
	fclose (pFile_node);
	// statis info

	pFile_pajek=fopen("Router_pajek.txt", "w");
	outputNetwork_pajek( target, pFile_pajek);
	fclose (pFile_pajek);
	
	printf(" %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f \n",
		    			netinfo->av_k,
					netinfo->max_k,
					netinfo->av_coef,
					netinfo->e_loc, 
					netinfo->S_size, 
					netinfo->av_s, 
					netinfo->S_avspl, 
					netinfo->S_maxspl, 			 		   
					netinfo->e_glob_active,	
					netinfo->S_e_glob); 
	
	freeNetwork(target);
	freeCLSTS(clsts);
	freeNetInfo(netinfo);

}
Esempio n. 6
0
void
getKshell(struct network* target, int *shell)
{

	int   Mn;
	int i;
	int j;
	int ks;
	int k;
	struct network * targetA;
	int *delNodes;
	int   delN;

	targetA=NULL;
	copyNetwork(target, &targetA);
	delNodes=(int *)mem_alloc((1+targetA->nodeNum)*sizeof(int));
	for(i=1;i<=targetA->nodeNum;i++)
	{
		shell[i]=-1;
	}
	
	Mn=0;
	ks=1;
	k=1;
	while(Mn!=targetA->nodeNum)
	{
		while(1)
		{
			delN=0;
			for(i=1;i<=targetA->nodeNum;i++)
			{
				if (shell[i]== -1 && targetA->nodes[i].numadj<=k)
				{
					shell[i]=ks;	
					Mn++;
					delN++;
					delNodes[delN]=i;				
				}			
			}
			if(delN==0) 
			{ 
				break;
			}else{
				for(j=1;j<=delN;j++)
				{
					delNodeFromNetwork(targetA, delNodes[j]);
				}			
			}
		}
		ks++;
		k++;		
	}	
	freeNetwork(targetA);
	mem_free(delNodes);	
}
Esempio n. 7
0
int
readSCN(char * netfile) /*input: name of file recording network information*/

{
    int error;
    FILE *infile;
    time_t time_begin,time_end;
    struct tm * TM ;
    char dir_p[10];
    int name_size;
    static struct network * scn;
    /* 1) from files,  get the header dependency network and filelist*/
    error=0;
    name_size=30;
    infile=fopen(netfile, "r");
    if(infile==NULL)
    {
        printf("file \" %s \" not exist!\n", netfile);
        return 1;
    }
    inputNetwork(&scn, infile);
    fclose(infile);

    /* 2) get statistical properties of the network, and record all the information into output files */
    //   create ouput directories
    time(&time_begin);
    TM=localtime(&time_begin);
    strftime(dir_p, name_size, "%y%m%d%H%M", TM);
    strcat(dir_p,"/");
#if defined(_WIN32)
    error=_mkdir(dir_p);
#else
    error=mkdir(dir_p, 0777);
#endif

    analyzeSCN(scn,dir_p);

    time(&time_end);
    printf("\n exhausted time: %ld \n",time_end-time_begin);

    //showNetwork(file_net);
    /* 3) free file network, file list and other memory*/
    freeNetwork(scn);

    printf("\n ok! \n");
    return error;
}
Esempio n. 8
0
/*
 	oba test: get network property
*/
void
oba_iter_lck()
{
	int i, m0,m,step,iter;
	double l_sum, c_sum, k_sum, e_sum, maxk_sum, maxl_sum;
	struct network * target;
	struct connectedNetInfo * pro;
	time_t time_begin,time_end;
	FILE *pFile_lck;

	step=10000;
    m0=m=2;
    iter=3;
    
	time(&time_begin);
	target=NULL;
	pro=NULL;

	l_sum=0.0;
       c_sum=0.0;
       k_sum=0.0;
       e_sum=0.0;
       maxk_sum=0.0;   
       maxl_sum=0.0;
        for(i=1;i<=iter;i++)
        {
        	target=(struct network *)mem_alloc(sizeof(struct network));
	       baModel_o(target, m0,m, step);
	       getConnectedNetInfo(target, &pro);	
		l_sum+=pro->av_l;
		c_sum+=pro->av_c;
		k_sum+=pro->av_k;
		maxk_sum+=pro->max_k;
		maxl_sum+=pro->max_l;
		e_sum+=pro->e_glob;
		freeNetwork(target);
		mem_free(pro);
        }
	pFile_lck = fopen("oba_lck.txt","a");
      	fprintf(pFile_lck," %.5f   %.5f  %.5f   %.5f  %.5f  %.5f \n", 
				  l_sum/(double)iter, c_sum/(double)iter, k_sum/(double)iter, 
				  maxk_sum/(double)iter, maxl_sum/(double)iter, e_sum/(double)iter); 
 	fclose(pFile_lck);
	time(&time_end);
      	printf("\n exhausted time: %ld \n",time_end-time_begin);
}
Esempio n. 9
0
void 
readSNAP_arclist(char *infilename, 
			 int    nodeNum, 
                    char  *outfilename)
{
	FILE * datafile;
	FILE * outfile;
	struct network* target;
	////struct netInfo* netinfo;
	////struct CLSTS* clsts;
	////FILE * pFile_node;
	int totalNum;
	int id1;
	int id2;
	int error;
	
	// 1) read the network data from the raw-data file 
	target=(struct network *)mem_alloc(sizeof(struct network));

	totalNum=nodeNum;
	initNetwork(target, totalNum, UN_DIRECT_UN_WEIGHT);

	datafile = fopen(infilename, "r");
	while(1)
	{
		error=fscanf(datafile, "%d %d \n", &id1, &id2);
		// use (id1 id2) to construct  a network
		//printf(" %d (%d , %d) %f \n",error, id1,id2,weight);
		//getchar();
		if(error==-1)
			break;
		error=addLinkToNetwork(target, id1+1, id2+1, 1.0);
		error=addLinkToNetwork(target, id2+1, id1+1, 1.0);
	}
	fclose(datafile);
	
	outfile=fopen(outfilename, "w");
	outputNetwork(target, outfile);
	fclose (outfile);
	
	freeNetwork(target);
}
Esempio n. 10
0
void price_pk()
{
	int i;
	int m0,m,N;
	double gamma[6];
	FILE * pFile_pk;
	char file_name[20];
	int name_size;
	struct network * target;

		
	m0=2;
	m=2;
	N=100000;

	gamma[1]=2.5;
	gamma[2]=3.0;
	gamma[3]=5.0;
	gamma[4]=7.0;
	gamma[5]=10.0;

	name_size=20;
	for(i=1;i<=5;i++)
	{
		memset(file_name,0, name_size);
		sprintf(file_name, "pk_price_%.2f.txt",gamma[i]);
		pFile_pk=fopen(file_name, "a");
		target=(struct network *)mem_alloc(sizeof(struct network));			
		priceModel(target, m0, m, gamma[i], N);

	
		outputpk(target, pFile_pk);

		fclose(pFile_pk);
		freeNetwork(target);
	}
		
	
}
Esempio n. 11
0
void 
assort_ba()
{
	int m0,m,N;
	FILE * pFile_pk;
	FILE * pFile_link;
	int name_size;
	struct network * target;
	double rr;
		
	m0=2;
	m=2;
	N=100000;
	name_size=20;

	//memset(file_name,0, name_size);
	//sprintf(file_name, "pk_ba.txt",i);
	pFile_pk=fopen("pk_ba.txt", "a");
	target=(struct network *)mem_alloc(sizeof(struct network));			
	baModel(target, m0, m, N);

	
	outputpk(target, pFile_pk);

	rr=0.0;	
	
	rr=getAssortativityCoeffient(target);

	printf("after compute: assort_coef = %f \n", rr);

	pFile_link=fopen("pFile_link.txt", "a");
	outputkikj(target,pFile_link);

	fclose(pFile_pk);
	fclose(pFile_link);
	freeNetwork(target);
}
Esempio n. 12
0
void
loadTest()
{
	int step;
	time_t time_begin,time_end;
	FILE * pFile_lck;
	struct network * target=NULL;
	struct connectedNetInfo * pro=NULL;
//	double maxNB,maxLB;
	int m, m0;

	time(&time_begin);
	
	m=2;
	m0=2;
	step=10;
	target=NULL;
	pro=NULL;
	target=(struct network *)mem_alloc(sizeof(struct network));
	baModel_o(target, m0, m,  step);
	getConnectedNetInfo(target, &pro);	

	showNetwork(target);

	pFile_lck = fopen("lck.txt","w");
	outputConnectedNetInfo(pro, pFile_lck);
	
//	getNodeLinkLoad(target,&maxNB,&maxLB,NULL,NULL);

	time(&time_end);
      	printf("\n exhausted time: %ld \n",time_end-time_begin);
      	
	fclose(pFile_lck);
      	freeNetwork(target);
	mem_free(pro);
}
Esempio n. 13
0
void 
netToPajek(char * netfile, char * pajekfile)
{

	FILE * outfile;
	FILE * pFile_pajek;
	struct network* target;

	// 1) input network and analyze the properties
	target=NULL;
	outfile=fopen(netfile, "r");
	inputNetwork(&target, outfile);
	fclose (outfile);

	printf("\n %d %d \n", target->nodeNum, target->linkNum);
	
	// 2) to pajek file
	pFile_pajek=fopen(pajekfile, "w");
	outputNetwork_pajek_frac( target, pFile_pajek);
	fclose (pFile_pajek);
	
	freeNetwork(target);

}
Esempio n. 14
0
void
read_AS_caida()
{
	FILE * datafile;
	FILE * outfile;
	struct network* target;
	int id1;
	int id2;
	double weight;
	int error;
	int totalNum;
	struct netInfo* netinfo;
	struct CLSTS* clsts;
	FILE * pFile_node;

	
	// 1) read the network data from the raw-data file "AS_oregon2.txt"
	target=(struct network *)mem_alloc(sizeof(struct network));

	totalNum=11461;
	initNetwork(target, totalNum, UN_DIRECT_UN_WEIGHT);

	datafile = fopen("./realdata/AS_oregon2.txt", "r");
	while(1)
	{
		error=fscanf(datafile, "%d %d \n", &id1, &id2, &weight);
		// use (id1 id2 weight) to construct  a network
		//printf(" %d (%d , %d) %f \n",error, id1,id2,weight);
		//getchar();
		if(error==-1)
			break;
		error=addLinkToNetwork(target, id1, id2, 1.0);
		error=addLinkToNetwork(target, id2, id1, 1.0);
	}
	fclose(datafile);
	
	outfile=fopen("./realdata/AS_oregon2_net.txt", "w");
	outputNetwork(target, outfile);
	fclose (outfile);

	freeNetwork(target);

	// 2) analyze the properties
	target=NULL;
	outfile=fopen("./realdata/AS_oregon2_net.txt", "r");
	inputNetwork(&target, outfile);
	fclose (outfile);

	printf("\n %d %d \n", target->nodeNum, target->linkNum);

	// getNetwork Info
	netinfo=(struct netInfo*)mem_alloc(sizeof(struct netInfo));
	initNetInfo(netinfo, target);
	getBasicNetInfo(target, netinfo);
	clsts=NULL;
	getCLSTS(target,&clsts);
	getClstNetInfo(target, clsts, netinfo); 

	pFile_node=fopen("AS_oregon2_node.txt", "w");
	outputNodeInfo(netinfo, pFile_node);
	fclose (pFile_node);
	// statis info

	printf(" %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f \n",
		    			netinfo->av_k,
					netinfo->max_k,
					netinfo->av_coef,
					netinfo->e_loc, 
					netinfo->S_size, 
					netinfo->av_s, 
					netinfo->S_avspl, 
					netinfo->S_maxspl, 			 		   
					netinfo->e_glob_active,	
					netinfo->S_e_glob); 
	
	freeNetwork(target);
	freeCLSTS(clsts);
	freeNetInfo(netinfo);

}
Esempio n. 15
0
int main (int argc, char* argv[])
{
    if (argc == 1)
    {
        srand(time(NULL));

        struct neural_network *network = createNetwork(3, 3, 2);

        int loopCount = 0, count = 1, proceed = 0;
        double out00, out01, out10, out11;
        do
        {
            do
            {
                loopCount++;
                setInput(1,1, network);
                out11 = getOutput(network);
                learn(network, 0);
                setInput(0,0, network);
                out00 = getOutput(network);
                learn(network, 0);
                setInput(0,1,network);
                out01 = getOutput(network);
                learn(network, 1);
                setInput(1,0, network);
                out10 = getOutput(network);
                learn(network, 1);

                printf("0xor0: %f 0xor1: %f 1xor0: %f 1xor1: %f\n",out00, out01,
                        out10, out11);

            }while ((out00 > 0.05 || out01 < 0.95 || out10 < 0.95 ||
                        out11 > 0.05) && loopCount < 200000);
            proceed = loopCount == 200000;
            if(proceed)
            {
                printf("creating new network\n");
                resetWeights(network);
                printf("weights reset");
                count++;
                loopCount = 0;
            }
        }while(proceed);


        freeNetwork(network);
        printf("Network freed.\n");
        printf("Loop count : %i\n",(count - 1)*200000 + loopCount);
        printf("Everything went fine. Exiting...\n");
        _Exit(0);
    }

    else if (argc == 2)
    {
        IplImage *img = load(argv[1]);
        if(img != NULL)
        {
            const char* window_title = "Perfect Image";
            cvNamedWindow (window_title, CV_WINDOW_AUTOSIZE);
            cvShowImage (window_title, img);
            cvWaitKey(0);
            char path[] = "result.bmp";
            cvSaveImage(&path[0], img, NULL);
            cvDestroyAllWindows();
            cvReleaseImage(&img);
            printf("Everything went fine. Exiting...\n");
            return 0;
        }
        else
        {
            printf("Error loading image.\n");
            return -1;
        }
    }
    else
    {
        printf("Argument issue. Exiting...\n");
        return -1;
    }

}
Esempio n. 16
0
void 
ER1Test()
{
	int i;
	int nodeNum, linkNum;

	FILE * pFile_lck;
	//FILE * pFile_node;
	FILE * pFile_net;

      FILE * pFile_pk;
	struct network * target;
	struct netInfo *  netinfo;
	struct CLSTS *   clsts;

	double av_k;
	double      max_k;
	double av_coef ;
	double e_loc ;
	double S_size ; 
	double av_s;
	double S_avspl ;
	double 	S_maxspl ;				 		   
	double	e_glob_active  ;
	double	S_e_glob  ;		
	
	target=NULL;
	netinfo=NULL;
	clsts=NULL;
	
	pFile_lck = fopen("er1_lck.txt","a");
		
	//nodeNum = 332;
	//linkNum = 2126;	

	nodeNum = 20000;
	linkNum = 50000;	
	
	i=0;
	av_k      = 0;
	max_k     = 0;
	av_coef   = 0;
	e_loc       = 0;
	S_size     = 0;
	av_s        = 0;
	S_avspl   = 0;
	S_maxspl  = 0;		 		   
	e_glob_active   = 0;
	S_e_glob  = 0;
	while(1)
	{
		if(i==1)
		{
			break;
		}
		printf(" i = %d  ..............................  \n", i);
		target=(struct network *)mem_alloc(sizeof(struct network));
		erModel_1(target, nodeNum, linkNum);

		pFile_net=fopen("er1_net.txt", "w");
		pFile_pk=fopen("er1_pk.txt","w");
		outputNetwork(target, pFile_net);
		outputpk(target,  pFile_pk);
		fclose (pFile_net);
		fclose (pFile_pk);
/*
		// getNetwork Info
		netinfo=(struct netInfo*)mem_alloc(sizeof(struct netInfo));
		initNetInfo(netinfo, target);
		getBasicNetInfo(target, netinfo);
		clsts=NULL;
		getCLSTS(target,&clsts);
		getClstNetInfo(target, clsts, netinfo); 

		pFile_node=fopen("er1_node.txt", "w");
		outputNodeInfo(netinfo, pFile_node);
		fclose (pFile_node);

		
		
		// statis info
	
		av_k      += netinfo->av_k ;
		max_k    += netinfo->max_k;
		av_coef  += netinfo->av_coef;
		e_loc      += netinfo->e_loc;
		S_size     +=  netinfo->S_size; 
		av_s       +=  netinfo->av_s;
		S_avspl   +=    netinfo->S_avspl;
		S_maxspl +=     netinfo->S_maxspl;				 		   
		e_glob_active  +=   netinfo->e_glob_active;
		S_e_glob        +=   netinfo->S_e_glob;		
		
		printf(" %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f \n",
		    			netinfo->av_k,
					netinfo->max_k,
					netinfo->av_coef,
					netinfo->e_loc, 
					netinfo->S_size, 
					netinfo->av_s, 
					netinfo->S_avspl, 
					netinfo->S_maxspl, 			 		   
					netinfo->e_glob_active,	
					netinfo->S_e_glob); 
		
		fprintf(pFile_lck, " %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f \n",
		    			netinfo->av_k,
					netinfo->max_k,
					netinfo->av_coef,
					netinfo->e_loc, 
					netinfo->S_size, 
					netinfo->av_s, 
					netinfo->S_avspl, 
					netinfo->S_maxspl, 			 		   
					netinfo->e_glob_active,	
					netinfo->S_e_glob); 
		
		
*/
		i++;
		freeNetwork(target);
		freeCLSTS(clsts);
		freeNetInfo(netinfo);
	}
	/*
	av_k/=i;
	max_k/=i;
	av_coef/=i;
	e_loc/=i; 
	S_size/=i; 
	av_s/=i; 
	S_avspl/=i; 
	S_maxspl/=i; 			 		   
	e_glob_active/=i; 	
	S_e_glob/=i; 	
	
      fprintf(pFile_lck, " %.5f  %.5f %.5f  %.5f  %.5f  %.5f  %.5f  %.5f  %.5f  %.5f \n",
		    			av_k,
					max_k,
					av_coef,
					e_loc, 
					S_size, 
					av_s, 
					S_avspl, 
					S_maxspl, 			 		   
					e_glob_active,	
					S_e_glob); 	
	*/
      	
	fclose(pFile_lck);      

}
Esempio n. 17
0
/*
	multi-time test:
	for contiually increasing network size (each time increasing iterN , from 0 to N), investigate the relationship between m, M and 
	1) statistical properties, 
	2) coupling matrix, 
	3) connectivity distributionp(k)
*/
int
lwe_m_M_iterN_iter(int *m,            /*input: array containing different m0=m=m1*/
				              int m_num,     /*/*input: number of elements in m */
						 int *M,            /*input: array containing different local-world size*/
			   			 int M_num,     /*input: number of elements in M*/
			   			 int N,              /*input: final network size*/
		   			        int iterN,         /*input: each time to get a network with size iterN*/
			                     int iter,           /*input: iterative times*/
			   			 int sp1,             /*input: if get the statistical properties of the final network with size N: 0: no; >0: yes*/
			   			 int sp2,             /*input: if get the statistical properties of with network size increasing at iterN each step: 0: no; >0: yes*/
						 int pk,		    /*input: if get the connectivity distribution: 0: no; >0: yes*/
 			                     int cm,         /*input: if get the coupling matrix: 0: no; >0: yes*/				 
 			                     int nb)         /*input: if get the node betweennews centrality: 0: no; >0: yes*/				 
{ 
       int i,j,l,step;
       double l_sum = 0.0, c_sum = 0.0, k_sum = 0.0, e_sum = 0.0, maxk_sum = 0.0, maxl_sum = 0.0,maxnb_sum = 0.0;
	int error;

	struct network * target;
	struct connectedNetInfo * pro;
	FILE* pFile_pk;
	FILE* pFile_cm;
	FILE* pFile_nb;
	FILE* pFile_lb;
	FILE *pFile_lck;
	FILE *pFile_lck_N;
	char dir_p[100];
	char dir_m[100];
	char dir_M[100];
	char file_name[100];
	char re_path[100];
	int name_size;
	time_t time_begin,time_end;
	struct tm * TM ;
	double  max_NB = 0.0 ;
	//double  max_LB;//ûÓÃ
	target=NULL;
	pro=NULL;
	pFile_pk =NULL;
	pFile_cm =NULL;
	pFile_nb =NULL;
	pFile_lb =NULL;
	pFile_lck = NULL;
	pFile_lck_N = NULL;
	name_size=100;
	TM =NULL;

	//  validity check of the input parameters - very important, however, skipped at present 
	if(iterN<=0)
	{
		iterN=100; //default value
	}
	if (iterN>N)
	{
		iterN=N;
	}
	time(&time_begin);	
	TM=localtime(&time_begin);
	strftime(dir_p, name_size, "%y%m%d%H%M", TM);
	strcat(dir_p,"/");
	//   create ouput directories
    #if defined(_WIN32)
	error=_mkdir(dir_p);
    #else
	error=mkdir(dir_p, 0777);
    #endif
    
    for(i=1;i<=m_num;i++)
	{
		if(m[i]>=N)
		{
			continue;
		}
	//	par.m=m[i];
	//	par.m0=m[i];
		sprintf(dir_m, "m_%d/",m[i]);
		strcat(re_path,dir_p);
		strcat(re_path,dir_m);
        #if defined(_WIN32)
        error=_mkdir(re_path);
        #else
		error=mkdir(re_path, 0777);
        #endif
		memset(re_path,0, name_size);
		if(sp1>0)
		{
			strcat(re_path,dir_p);
			sprintf(file_name, "m_%d_N_%d.txt", m[i],N);
			strcat(re_path,file_name);	
			pFile_lck_N=fopen(re_path,"a");
			memset(file_name, 0, name_size);
			memset(re_path,0, name_size);	
		}
		for(j=1;j<=M_num;j++)
       	{
       		if(M[j]<m[i])
       		{
       			continue;
       		}
    //   		par.M=M[j];
			sprintf(dir_M, "M_%d/",M[j]);
			strcat(re_path,dir_p);
			strcat(re_path,dir_m);
			strcat(re_path,dir_M);
            #if defined(_WIN32)
			error=_mkdir(re_path);
            #else
            error=mkdir(re_path, 0777);
            #endif
			memset(re_path,0, name_size);
			if(sp1>0)
			{
				l_sum=0.0;
        			c_sum=0.0;
		        	k_sum=0.0;
       		 		e_sum=0.0;
        			maxk_sum=0.0;   
	        		maxl_sum=0.0;
				maxnb_sum=0.0;
			}
			if(sp2>0)
			{
				strcat(re_path,dir_p);
				sprintf(file_name, "m_%d_M_%d_iter_%d.txt", m[i], M[j],  iter);
				strcat(re_path,file_name);	
				pFile_lck=fopen(re_path,"a");
				memset(file_name, 0, name_size);
				memset(re_path,0, name_size);
			}
			for(l=1;l<=iter;l++)
			{
				// 1) construct a network using local-world evolving model
				target=(struct network *)mem_alloc(sizeof(struct network));
				initNetwork(target, m[i], 0);
				step=iterN-m[i];
				while(step<=0)
				{
					step+=iterN;
				}
				while((target->nodeNum+step)<N)
				{
					localPreferAttach(target, M[j], m[i], step);
					if(sp2>0)
					{
						getConnectedNetInfo(target, &pro);
						//getNodeLinkLoad(target, &max_NB, &max_LB, NULL, NULL);
						fprintf(pFile_lck," %d %d %d %.5f %.5f %.5f %.5f %.5f %.5f %.5f\n", 
							m[i], M[j], target->nodeNum, pro->av_l, pro->av_c, pro->av_k, 
							(double)pro->max_k, (double)pro->max_l, pro->e_glob, max_NB);
					 	fflush(pFile_lck); 
						mem_free(pro);
					}
					step=iterN;
				}
				step=N-target->nodeNum;
				localPreferAttach(target, M[j], m[i],  step);
				max_NB=0.0;
				if(sp2>0||sp1>0)
				{
					getConnectedNetInfo(target, &pro);
					if(nb>0)
					{
						strcat(re_path,dir_p);
						strcat(re_path,dir_m);
						strcat(re_path,dir_M);
						sprintf(file_name, "nb_%d.txt", l);
						strcat(re_path,file_name);
						pFile_nb = fopen(re_path,"w");
						memset(file_name, 0, name_size);
						memset(re_path,0, name_size);
						
						strcat(re_path,dir_p);
						strcat(re_path,dir_m);
						strcat(re_path,dir_M);
						sprintf(file_name, "lb_%d.txt", l);
						strcat(re_path,file_name);
						pFile_lb = fopen(re_path,"w");
						memset(file_name, 0, name_size);
						memset(re_path,0, name_size);
						
					//	getNodeLinkLoad(target, &max_NB, &max_LB, pFile_nb, pFile_lb);
						fclose (pFile_nb);
						fclose (pFile_lb);
					}else{
					//	getNodeLinkLoad(target, &max_NB, &max_LB, NULL, NULL);
					}
					if(sp2>0)
					{
						fprintf(pFile_lck," %d %d %d %.5f %.5f %.5f %.5f %.5f  %.5f %.5f \n", 
							m[i], M[j], target->nodeNum, pro->av_l, pro->av_c, pro->av_k, 
							(double)pro->max_k, (double)pro->max_l, pro->e_glob, max_NB);
				 		fflush(pFile_lck); 					
					}
					if(sp1>0)
					{
						l_sum+=pro->av_l;
						c_sum+=pro->av_c;
						k_sum+=pro->av_k;
						maxk_sum+=pro->max_k;
						maxl_sum+=pro->max_l;
						e_sum+=pro->e_glob;
						maxnb_sum+=max_NB;
					}
					mem_free(pro);
				}
				if(pk>0)
				{
					strcat(re_path,dir_p);
					strcat(re_path,dir_m);
					strcat(re_path,dir_M);
					sprintf(file_name, "pk_%d.txt", l);
					strcat(re_path,file_name);
					pFile_pk = fopen(re_path,"w");
					memset(file_name, 0, name_size);
					memset(re_path,0, name_size);		
					outputpk(target,  pFile_pk);
					fclose (pFile_pk);
				}
				if(cm>0)
				{
					strcat(re_path,dir_p);
					strcat(re_path,dir_m);
					strcat(re_path,dir_M);
					sprintf(file_name, "cm_%d.txt", l);
					strcat(re_path,file_name);
					pFile_cm = fopen(re_path,"w");
					memset(file_name, 0, name_size);
					memset(re_path,0, name_size);
					outputCM(target,  pFile_cm);
					fclose (pFile_cm);
				}
				freeNetwork(target);
			}
			memset(dir_M, 0, name_size);
			if(sp2>0)
			{
				fclose (pFile_lck);
			}
			if(sp1>0)
			{
				fprintf(pFile_lck_N," %d %d %d %.5f %.5f %.5f %.5f %.5f %.5f %.5f\n", 
					m[i], M[j], N, l_sum/(double)iter, c_sum/(double)iter, k_sum/(double)iter, 
					maxk_sum/(double)iter, maxl_sum/(double)iter, e_sum/(double)iter,maxnb_sum/(double)iter); 
			 	fflush(pFile_lck_N); 
			}
       	}
		memset(dir_m, 0, name_size);
		if(sp1>0)
		{
			fclose (pFile_lck_N);
		}
	}
	
	time(&time_end);
       printf("\n exhausted time: %ld \n",time_end-time_begin);
       return 0;
}
Esempio n. 18
0
// for software network test
void 
ERTest()
{
	int i;
	int nodeNum;
	time_t time_begin,time_end;
	FILE * pFile_lck;
	FILE * pFile_node;
	FILE * pFile_link;
	FILE * pFile_net;
	struct network * target;
	struct netInfo *  netinfo;
	struct CLSTS *   clsts;
	double p;
	
	target=NULL;
	netinfo=NULL;
	clsts=NULL;
	pFile_lck = fopen("er_lck.txt","a");
	pFile_node=fopen("er_node.txt", "w");
	pFile_link=fopen("er_link.txt", "w");
	pFile_net=fopen("er_net.txt", "w");

/*	
	nodeNum = 2999;
	linkNum = 97676;
	par.p=(double)(65.8/(double)nodeNum/(double)2);
*/

	nodeNum = 10;
	p=0.3;


	time(&time_begin);
	i=0;
	while(1)
	{
		if(i==1)
		{
			break;
		}
		printf(" i = %d  ..............................  \n", i);

		target=(struct network *)mem_alloc(sizeof(struct network));		
		erModel(target, nodeNum, p);

		
		showNetwork(target);
		outputNetwork(target, pFile_net);
		
		// getNetwork Info
		netinfo=(struct netInfo*)mem_alloc(sizeof(struct netInfo));
		initNetInfo(netinfo, target);
		getBasicNetInfo(target, netinfo);

		// ouput the basic info
		outputNodeInfo(netinfo, pFile_node);
		outputLinkInfo(netinfo, pFile_link);
				
		clsts=NULL;
		getCLSTS(target,&clsts);
		getClstNetInfo(target, clsts, netinfo); 

		// statis info
		/*
		av_k      = netinfo->av_k ;
		max_k     = netinfo->max_k;
		av_coef  = netinfo->av_coef;
		e_loc      = netinfo->e_loc;
		S_size     =  netinfo->S_size; 
		av_s       =  netinfo->av_s;
		S_avspl   =    netinfo->S_avspl;
		S_maxspl =     netinfo->S_maxspl;				 		   
		e_glob_active  =   netinfo->e_glob_active;
		S_e_glob        =   netinfo->S_e_glob;		
		*/
		printf(" %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f \n",
		    			netinfo->av_k,
					netinfo->max_k,
					netinfo->av_coef,
					netinfo->e_loc, 
					netinfo->S_size, 
					netinfo->av_s, 
					netinfo->S_avspl, 
					netinfo->S_maxspl, 			 		   
					netinfo->e_glob_active,	
					netinfo->S_e_glob); 
		
		fprintf(pFile_lck, " %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f \n",
		    			netinfo->av_k,
					netinfo->max_k,
					netinfo->av_coef,
					netinfo->e_loc, 
					netinfo->S_size, 
					netinfo->av_s, 
					netinfo->S_avspl, 
					netinfo->S_maxspl, 			 		   
					netinfo->e_glob_active,	
					netinfo->S_e_glob); 
		i++;
		freeNetwork(target);
		freeCLSTS(clsts);
		freeNetInfo(netinfo);
	}
	/*
	av_k/=i;
	max_k/=i;
	av_coef/=i;
	e_loc/=i; 
	S_size/=i; 
	av_s/=i; 
	S_avspl/=i; 
	S_maxspl/=i; 			 		   
	e_glob_active/=i; 	
	S_e_glob/=i; 	
	
      fprintf(pFile_lck, "  %.2f  %.2f  %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f \n",
		    			av_k,
					max_k,
					av_coef,
					e_loc, 
					S_size, 
					av_s, 
					S_avspl, 
					S_maxspl, 			 		   
					e_glob_active,	
					S_e_glob); 	
	*/
	time(&time_end);
      	printf("\n exhausted time: %ld \n",time_end-time_begin);
      	
	fclose(pFile_lck);   
	fclose (pFile_node);
	fclose (pFile_link);
	fclose (pFile_net);

}
Esempio n. 19
0
void 
sf_syn()
{
	int         sfN;
	int         sfm[50];
	double    gamma[50];
	struct network * target;
	////double R;
	int i,j;
	int sfmN;
	int gammaN;
	FILE *pFile;

	////int loop;
	char dirN[100];
	char dirm[100];	
	
	// prerared for every function
	//////////////////////////////////////////////	
	char dir_func[100];// one fucntion, one directory
	char dir_time[100];
	char dir_path[100];
	char path[100];	
	char file_name[100];
	
	int name_size;
	time_t time_begin;
	struct tm * TM ;
	// make the dir_func/
	name_size=100;
	memset(dir_func,0, name_size);
	strcpy(dir_func, "sf_syn");
	strcat(dir_func,"/");
	#if defined(_WIN32)
        _mkdir(dir_func);
#else
		mkdir(dir_func, 0777);
#endif
	// make the dir_func/dir_time/
	TM=NULL;
	time(&time_begin);
	TM=localtime(&time_begin);
	strftime(dir_time, name_size, "%y%m%d%H%M", TM);
	strcat(dir_time,"/");
	memset(path,0, name_size);
	strcat(path,dir_func);
	strcat(path,dir_time);
	#if defined(_WIN32)
        _mkdir(path);
#else
		mkdir(path, 0777);
#endif
	strcpy(dir_path,path);
      ////////////////////////////////////////////////
      printf(" %s \n", dir_path);
	
	/*
	sfN=10000;
	
	sfm[0]=2;
	sfm[1]=3;
	sfm[2]=4;
	sfmN=3;
	
	gamma[0]=2.5;
	gamma[1]=3;
	gamma[2]=3.5;
	gamma[3]=4;
	gamma[4]=4.5;
	gamma[5]=5;
	gamma[6]=5.5;
	gamma[7]=6;
	gamma[8]=6.5;
	gamma[9]=7;
	gamma[10]=7.5;
	gamma[11]=8;
	gamma[12]=8.5;
	gamma[13]=9;
	gamma[14]=9.5;
	gamma[15]=10;
	gammaN=1;
*/

	sfN=1000;
	
	sfm[0]=5;
	sfm[1]=6;
	sfm[2]=7;
	sfm[3]=4;
	sfm[4]=8;
	
	sfmN=3;
	
	gamma[0]=2.1;
	gamma[1]=2.2;
	gamma[2]=2.4;
	gamma[3]=2.6;
	gamma[4]=2.8;
	gamma[5]=3.0;
	gamma[6]=3.2;
	gamma[7]=3.4;
	gamma[8]=3.6;
	gamma[9]=3.8;
	gamma[10]=4.0;
	gamma[11]=4.2;
	gamma[12]=4.4;
	gamma[13]=4.6;
	gamma[14]=4.8;
	gamma[15]=5.0;
	gamma[16]=5.5;
	gamma[17]=6.0;
	gamma[18]=6.5;
	gamma[19]=7.0;
	gamma[20]=7.5;
	gamma[21]=8.0;
	gammaN=22;
	
	
	printf("\n ----------------- \n");

	memset(path,0, name_size);
	memset(dirN,0, name_size);
	sprintf(dirN, "N_%d/",sfN);
	strcat(path,dir_path);
	strcat(path,dirN);
	#if defined(_WIN32)
        _mkdir(path);
#else
		mkdir(path, 0777);
#endif

	for(i=0;i<sfmN;i++)
	{
			memset(path,0, name_size);
			memset(dirm,0, name_size);
			sprintf(dirm, "m_%d/",sfm[i]);
			strcat(path,dir_path);
			strcat(path,dirN);
			strcat(path,dirm);
#if defined(_WIN32)
        _mkdir(path);
#else
		mkdir(path, 0777);
#endif
			
			for(j=0;j<gammaN;j++)
			{
				target=(struct network *)mem_alloc(sizeof(struct network));		
				priceModel(target, sfm[i], sfm[i], gamma[j], sfN);
				
				memset(path,0, name_size);
				strcat(path,dir_path);
				strcat(path,dirN);
				strcat(path,dirm);
				memset(file_name, 0, name_size);
				sprintf(file_name, "cm_%.2f.txt", gamma[j]);
				strcat(path,file_name);	
				printf("%s \n", path);
				pFile=fopen(path,"a");

				outputCM(target, pFile);
				fclose(pFile);
				freeNetwork(target);
			}
		}
		
}
Esempio n. 20
0
void 
sf_R_sc()
{
	int         sfN;
	int         sfm[50];
	double    gamma[50];
	struct network * target;
	double R;
	int i,j;
	int sfmN;
	int gammaN;
	FILE *pFile;
	FILE *pFile_sc;
	int loop;
	double nD;
	/*
	sfN=10000;
	
	sfm[0]=2;
	sfm[1]=3;
	sfm[2]=4;
	sfmN=3;
	
	gamma[0]=2.5;
	gamma[1]=3;
	gamma[2]=3.5;
	gamma[3]=4;
	gamma[4]=4.5;
	gamma[5]=5;
	gamma[6]=5.5;
	gamma[7]=6;
	gamma[8]=6.5;
	gamma[9]=7;
	gamma[10]=7.5;
	gamma[11]=8;
	gamma[12]=8.5;
	gamma[13]=9;
	gamma[14]=9.5;
	gamma[15]=10;
	gammaN=1;
*/

	sfN=4000;
	
	sfm[0]=1;
	sfm[1]=2;
	sfm[2]=3;
	sfm[3]=4;
	sfm[4]=8;
	
	sfmN=5;
	
	gamma[0]=2.1;
	gamma[1]=2.2;
	gamma[2]=2.4;
	gamma[3]=2.6;
	gamma[4]=2.8;
	gamma[5]=3.0;
	gamma[6]=3.2;
	gamma[7]=3.4;
	gamma[8]=3.6;
	gamma[9]=3.8;
	gamma[10]=4.0;
	gamma[11]=4.2;
	gamma[12]=4.4;
	gamma[13]=4.6;
	gamma[14]=4.8;
	gamma[15]=5.0;
	gamma[16]=5.5;
	gamma[17]=6.0;
	gamma[18]=6.5;
	gamma[19]=7.0;
	gamma[20]=7.5;
	gamma[21]=8.0;
	gammaN=22;
	
	pFile=fopen("sf_R.txt","a");
	pFile_sc=fopen("sf_sc.txt","a");
	printf("\n ----------------- \n");
	loop=1;
	while(1)
	{
		for(i=0;i<sfmN;i++)
		{
			fprintf(pFile,"%d  ", sfm[i]);
			fprintf(pFile_sc,"%d  ", sfm[i]);
			for(j=0;j<gammaN;j++)
			{
				target=(struct network *)mem_alloc(sizeof(struct network));		
				priceModel(target, sfm[i], sfm[i], gamma[j], sfN);
				R=getR_one(target);
				nD=findND(target);
				fprintf(pFile," %.5f ",  R);
				fprintf(pFile_sc," %.5f ",  nD);
				fflush(pFile);
				fflush(pFile_sc);
				printf("m = %d  gamma = %f  R = %.5f  nD=%.5f \n", sfm[i], gamma[j], R, nD);
				freeNetwork(target);
			}
			fprintf(pFile,"\n");
			fprintf(pFile_sc,"\n");
		}
		loop++;
		if(loop>10)
		{
			break;
		}
	}
	
	fclose(pFile);
	fclose(pFile_sc);

}
Esempio n. 21
0
// for software network test
void 
expTest()
{
	int step;
	int i;
	int nodeNum, linkNum;
	time_t time_begin,time_end;
	FILE * pFile_lck;
	FILE * pFile_node;
	struct network * target=NULL;
	struct netInfo *  netinfo=NULL;
	struct CLSTS *   clsts=NULL;
	int m0, m, M;

	//double av_k, max_k, av_coef,e_loc;
	//double S_size, av_s, S_avspl, S_maxspl, e_glob_active,S_e_glob;
	target=NULL;
	netinfo=NULL;
	clsts=NULL;
	pFile_lck = fopen("exp_lck.txt","a");
	nodeNum = 2999;
	linkNum = 97676;
	m=33;
	m0=33;
	M=33; // no local world effect  - > generating exp network
	step=nodeNum-m0;
	
	time(&time_begin);
	i=0;
	while(1)
	{
		if(i==1)
		{
			break;
		}
		printf(" i = %d  ..............................  \n", i);
		target=(struct network *)mem_alloc(sizeof(struct network));
		lwModel(target, m0, M, m, step);

		// getNetwork Info
		netinfo=(struct netInfo*)mem_alloc(sizeof(struct netInfo));
		initNetInfo(netinfo, target);
		getBasicNetInfo(target, netinfo);
		clsts=NULL;
		getCLSTS(target,&clsts);
		getClstNetInfo(target, clsts, netinfo); 

		pFile_node=fopen("exp_node.txt", "w");
		outputNodeInfo(netinfo, pFile_node);
		fclose (pFile_node);
		
		// statis info
		/*
		av_k      = netinfo->av_k ;
		max_k     = netinfo->max_k;
		av_coef  = netinfo->av_coef;
		e_loc      = netinfo->e_loc;
		S_size     =  netinfo->S_size; 
		av_s       =  netinfo->av_s;
		S_avspl   =    netinfo->S_avspl;
		S_maxspl =     netinfo->S_maxspl;				 		   
		e_glob_active  =   netinfo->e_glob_active;
		S_e_glob        =   netinfo->S_e_glob;		
		*/
		printf(" %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f  %.5d  %.5f  %.5f \n",
		    			netinfo->av_k,
					netinfo->max_k,
					netinfo->av_coef,
					netinfo->e_loc, 
					netinfo->S_size, 
					netinfo->av_s, 
					netinfo->S_avspl, 
					netinfo->S_maxspl,
					netinfo->e_glob_active,	
					netinfo->S_e_glob); 
		
		fprintf(pFile_lck, " %.5f  %d  %.5f  %.5f  %d  %.5f  %.5f  %.5d  %.5f  %.5f \n",
		    			netinfo->av_k,
					netinfo->max_k,
					netinfo->av_coef,
					netinfo->e_loc, 
					netinfo->S_size, 
					netinfo->av_s, 
					netinfo->S_avspl, 
					netinfo->S_maxspl,
					netinfo->e_glob_active,	
					netinfo->S_e_glob); 
		i++;
		freeNetwork(target);
		freeCLSTS(clsts);
		freeNetInfo(netinfo);
	}
	/*
	av_k/=i;
	max_k/=i;
	av_coef/=i;
	e_loc/=i; 
	S_size/=i; 
	av_s/=i; 
	S_avspl/=i; 
	S_maxspl/=i; 			 		   
	e_glob_active/=i; 	
	S_e_glob/=i; 	
	
      fprintf(pFile_lck, "  %.2f  %.2f  %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f \n",
		    			av_k,
					max_k,
					av_coef,
					e_loc, 
					S_size, 
					av_s, 
					S_avspl, 
					S_maxspl, 			 		   
					e_glob_active,	
					S_e_glob); 	
	*/
	time(&time_end);
      	printf("\n exhausted time: %ld \n",time_end-time_begin);
      	
	fclose(pFile_lck);      

}
Esempio n. 22
0
int
getSCN(char * rawdatafile,  /*input: root of the dir tree*/
       int  totalNum) /*input: total number of nodes*/

{
    int error;
    time_t time_begin,time_end;
    struct tm * TM;
    char dir_p[10];
    char * filename;
    int name_size;
    FILE *outfile;
    struct network * scn;

    name_size=30;
    error=0;
    /* 1) intialize the static variables: net and list*/
    scn=(struct network *)mem_alloc(sizeof(struct network));

    initNetwork(scn, totalNum, UN_DIRECT_WITH_WEIGHT);


    /* 2) get the SCN from rawdatafile*/
    readRawData(scn, rawdatafile);


    /* 3) get statistical properties of the network, and record all the information into output files */
    //   create ouput directories
    TM=NULL;
    time(&time_begin);
    TM=localtime(&time_begin);
    strftime(dir_p, name_size, "%y%m%d%H%M", TM);
    strcat(dir_p,"/");

#if defined(_WIN32)
    error=_mkdir(dir_p);
#else
    error=mkdir(dir_p, 0777);
#endif

    filename=(char *)mem_alloc(name_size*sizeof(char));

    // <1>  show the structure of the network
    //showNetwork(scn);
    // <2>  write the network info to the files
    memset(filename, 0, name_size);
    strcat(filename, dir_p);
    strcat(filename, "net.txt");
    outfile=fopen(filename, "w");
    outputNetwork(scn, outfile);
    fclose (outfile);

    // <4> analyze the structural properties
    analyzeSCN(scn,dir_p);

    time(&time_end);
    printf("\n exhausted time: %ld \n",time_end-time_begin);

    /* 4)  free network*/
    freeNetwork(scn);

    mem_free(filename);
    return error;
}
Esempio n. 23
0
void price_load()
{
	int i;
	int m0,m,N;
	double gamma[6];
	FILE * pFile_node;
	FILE * pFile_link;
	char file_name[100];
	int name_size;
	struct network * target;
//	double  max_NB;
//	double  max_LB;
	
		// prerared for every function
	//////////////////////////////////////////////	
	char dir_func[100];// one fucntion, one directory
	char dir_time[100];
	char dir_path[100];
	char path[100];

	time_t time_begin;
	struct tm * TM ;
	// make the dir_func/
	name_size=100;
	memset(dir_func,0, name_size);
	strcpy(dir_func, "price_load");
	strcat(dir_func,"/");
	#if defined(_WIN32)
        _mkdir(dir_func);
#else
		mkdir(dir_func, 0777);
#endif
	// make the dir_func/dir_time/
	TM=NULL;
	time(&time_begin);
	TM=localtime(&time_begin);
	strftime(dir_time, name_size, "%y%m%d%H%M", TM);
	strcat(dir_time,"/");
	memset(path,0, name_size);
	strcat(path,dir_func);
	strcat(path,dir_time);
	#if defined(_WIN32)
        _mkdir(path);
#else
		mkdir(path, 0777);
#endif
	strcpy(dir_path,path);
      ////////////////////////////////////////////////
      printf(" %s \n", dir_path);
	
	m0=3;
	m=3;
	N=10000;

	gamma[1]=2.5;
	gamma[2]=3.0;
	gamma[3]=5.0;
	gamma[4]=7.0;
	gamma[5]=10.0;

	name_size=20;
	
	for(i=5;i<=5;i++)
	{
		target=(struct network *)mem_alloc(sizeof(struct network));			
		priceModel(target, m0, m, gamma[i], N);
		
		memset(file_name,0, name_size);
		sprintf(file_name, "price_%.2f_node.txt",gamma[i]);
		strcpy(path,dir_path);
		strcat(path,file_name);
		pFile_node=fopen(path,"a");
		
		memset(file_name,0, name_size);
		sprintf(file_name, "price_%.2f_link.txt",gamma[i]);
		strcpy(path,dir_path);
		strcat(path,file_name);
		pFile_link=fopen(path,"a");		
	
	//	getNodeLinkLoad(target, NULL, &max_NB, &max_LB, pFile_node, pFile_link);
		
		fclose(pFile_node);
		fclose(pFile_link);
		freeNetwork(target);
	}
		
	
}