Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Stl application

Make a plan and the data structure using the adjacent table, with a vertex list, each vertex of a list of adjacent vertices used to store the map information from reading the document, the file format is as follows :
5
1 2 -999
2 3 -999
3 1 -999 map the size of the first act, after every vertex of the graph begins to id, id behind adjacent vertices, -999 end said. Vertex data structure definition :
Struct gravex{ //the vex 's structure;
Unsigned int vexid;
List<adj>; adjlist;
};
Adj data is structured as follows :
Struct adj{ 4003rd the graph 's store list is way, it' s the vex 's list
Unsigned int myid; //the vex 's id in the list;
Link adjlink; //edge 's information
};
Adjlist adjacent to the table, use list.

List<gravex>; glist; definition of the chain of vertices.
The plans create procedures are as follows :
Nt graph : : create () (
Int i, j, adjid;
Char * filename= "gra.txt";
Adj tempadj;
Gravex tempvex;
Ifstream infile (filename);
If (!infile) (
Cout<< "file open error," "<endl;
Return 0
            }
Infile>;>;gsize;
  
For (i=1;i<=gsize;i++) (
Infile>;>;tempvex.vexid;
Infile>;>;adjid;
While (adjid!=-999) (
Tempadj.myid=adjid;
Tempvex.adjlist.push_back (tempadj);
Infile>;>;adjid;
) //push The vex 's adjlist
Glist.push_back (tempvex); //push Vex into list;
      
                          }
Infile.close ();
Return gsize;
}
Main () (
Int i, j;
Graph g1;
: : Iterator git; list<gravex>;
: : Iterator adjit; list<adj>;
G1.create ();
Git=g1.glist.begin ();
Git++;
Git++;
Cout<<git->;vexid<<endl;
Cout<<git->;adjlist.begin () ->;myid<<endl;
}
After the operation, said only the right point, the adjacency list of each vertex is not on the procedural defects?
Members heroes quickly doubts and the Bad ! ! [img][/img][img][/img]

Stl application

Top about themselves

Stl application

Where is not clear how the law is wrong months

Stl application

The third point above procedures should export id, the first and third vertices adjacent vertices. 3,3 output is obviously wrong, it should be 3,1



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com