ok lets say i have the following text
T 2 X F
X 2 Y G
Y 1 Z
Z 2 G 1
I 3 T G E
F 2 I E
looking at the first line t is the vertex 2 is the number of edges it has and X and F are the edges connecting to T.
So im suppose to implement an adjacency list which will read a file and store it in array called info which contains vertexname, outdegree, and adjcency list.
i really need help how to correctly read the file and store the values into an array using link list class i have
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "slist.h"
#include "ll.C"
using namespace std;
void getData();
void printData();
const int SIZE = 10;
struct info
{
char vertexName;
int outDegree;
slist adjacentOnes; // this comes from slist.h which is a link list class
};
int main()
{
}
//PURPOSE: GETS DATA FROM THE FILE
void getData()
{
info table[SIZE];
ifstream fin;
fin.open("table.txt");
while(!fin.eof())
{
for(int i = 0; i < SIZE;i++)
{
fin >> table[i].vertexName;
fin >> table[i].outDegree;
// this is where im kinda of lost, I have a slist class which is a link list class
// i implemented and it works. It has a member called addRear. addRear must be called
// everytime a letter is read from the file.For how would i do this??
//
}
}
}
void printData()
{
}