I'm new in coding, and this is my first attempt on graphs. Basically I have to find the shortest path between two locations using graphs. The arrival time and departure time will be given to us. I am having problem in creating the graph. In the void addloc function I want to add the location to the array of adjacency list everytime I add a new location. How do I do that? Also it would be really helpful if someone could tell me how I can keep the cities as string instead of int. If i keep them as strings I can't use the list as it takes only int or enum as input.
` using namespace std;
class location
{
public:
int city;
};
class flightconnect
{
int arvtime;
int deptime;
int arvcity;
public:
flightconnect(int _a, int _d, int _c) { arvtime = _a; deptime = _d; arvcity = _c;}
int getdeptime() { return deptime; }
int getarvtime() { return arvtime; }
int getarvcity() { return arvcity; }
};
struct graph
{
location* vertex;
list<flightconnect> *adj;
};
void addloc(int a,graph *flight)
{
flight = new graph;
flight->vertex->city=a;
//what should come in the next line?
flight->adj = flight->adj.append(a);
}
void addflight(int at,int dt,int a,int d,graph *flight)
{
flightconnect node(at,dt,d);
flight->adj[a].push_back(node);
}`