コード例 #1
0
ファイル: community.cs プロジェクト: AngelaG1/pathBased
        public edge next;                               // pointer for linked list of edges

        public edge()
        {
            so = 0; si = 0; next = null;
        }                                                                                       // default constructor
コード例 #2
0
ファイル: community.cs プロジェクト: AngelaG1/pathBased
        // ------------------------------------------------------------------------------------


        // ------------------------------------------------------------------------------------

        public void Initialize(int numnodes, int numlinks)
        {
            //// temporary variables for this function
            //int numnodes = 0;
            //int numlinks = 0;
            //int s, f, t;
            edge[] last;



            //// First scan through the input file to discover the largest node id. We need to
            //// do this so that we can allocate a properly sized array for the sparse matrix
            //// representation.


            //while (fscan >> s >> f)
            //{					// read friendship pair (s,f)
            //    numlinks++;							// count number of edges
            //    if (f < s) { t = s; s = f; f = t; }		// guarantee s < f
            //    if (f > numnodes) { numnodes = f; }		// track largest node index

            //    if (t2 - t1 > ioparm.timer)
            //    {				// check timer; if necessarsy, display

            //        t1 = t2;							//
            //        ioparm.timerFlag = true;				//
            //    }									//
            //    t2 = time(&t2);							//

            //}
            //fscan.close();

            gparm.maxid = numnodes + 2;                                 // store maximum index
            elist       = new edge[2 * numlinks];                       // create requisite number of edges
            // index of next edge of elist to be used

            //// Now that we know numnodes, we can allocate the space for the sparse matrix, and
            //// then reparse the file, adding edges as necessary.

            e        = new edge[gparm.maxid];           // (unordered) sparse adjacency matrix
            last     = new edge[gparm.maxid];           // list of pointers to the last edge in each row
            numnodes = 0;                               // numnodes now counts number of actual used node ids
            numlinks = 0;                               // numlinks now counts number of bi-directional edges created
            //ioparm.timerFlag = false;					// reset timer



            //while (fin >> s >> f)
            //{
            //    s++; f++;								// increment s,f to prevent using e[0]
            //    if (f < s) { t = s; s = f; f = t; }		// guarantee s < f
            //    numlinks++;							// increment link count (preemptive)
            //    if (e[s].so == 0)
            //    {						// if first edge with s, add s and (s,f)
            //        e[s].so = s;						//
            //        e[s].si = f;						//
            //        last[s] = &e[s];					//    point last[s] at self
            //        numnodes++;						//    increment node count
            //    }
            //    else
            //    {								//    try to add (s,f) to s-edgelist
            //        current = &e[s];					//
            //        existsFlag = false;					//
            //        while (current != NULL)
            //        {			// check if (s,f) already in edgelist
            //            if (current->si == f)
            //            {			//
            //                existsFlag = true;			//    link already exists
            //                numlinks--;				//    adjust link-count downward
            //                break;					//
            //            }							//
            //            current = current->next;			//    look at next edge
            //        }								//
            //        if (!existsFlag)
            //        {					// if not already exists, append it
            //            newedge = &elist[ecounter++];		//    grab next-free-edge
            //            newedge->so = s;				//
            //            newedge->si = f;				//
            //            last[s]->next = newedge;		//    append newedge to [s]'s list
            //            last[s] = newedge;		//    point last[s] to newedge
            //        }								//
            //    }									//

            //    if (e[f].so == 0)
            //    {						// if first edge with f, add f and (f,s)
            //        e[f].so = f;						//
            //        e[f].si = s;						//
            //        last[f] = &e[f];					//    point last[s] at self
            //        numnodes++;						//    increment node count
            //    }
            //    else
            //    {								// try to add (f,s) to f-edgelist
            //        if (!existsFlag)
            //        {					//    if (s,f) wasn't in s-edgelist, then
            //            newedge = &elist[ecounter++];		//       (f,s) not in f-edgelist
            //            newedge->so = f;				//
            //            newedge->si = s;				//
            //            last[f]->next = newedge;		//    append newedge to [f]'s list
            //            last[f] = newedge;		//    point last[f] to newedge
            //        }								//
            //    }
            //    existsFlag = false;						// reset existsFlag

            //}



            //gparm.m = numlinks;							// store actual number of edges created
            //gparm.n = numnodes;							// store actual number of nodes used
            return;
        }