I have data like this in a text file
A 2 B F
B 1 E
E 0
F 3 A B E
The first is the vertex name...so A in the first line
The second is the # of vertices it is connected to (out-degree)...so 2
Everything after the integer needs to be added to a linked list...the vertices that A is connected to... B->F will be what the linked list looks like for A.
Keep in mind the adjacent vertices list isn't fixed...it can be empty as seen for E or it can go to 100...or beyond.
I have this for reading in the input...I'm using an array of structs...but I'm stuck on the linked list part since it isn't fixed.
Code:ifstream fin; fin.open("table.txt"); int i = 0; while(!fin.eof()){ fin >> Gtable[i].name >> Gtable[i].out_degree >> Gtable[i].list.addFront(); // stuck here...the parameter in addFront should be the char that is read in. ++i; } fin.close();


Reply With Quote
Victor Nijegorodov 
Bookmarks