This code is giving me runtime error. Here, first I want to take a integer input which determine the number (n) of nodes in the graph. Then for n-1 time I want take two integer input which will give the adjacency information.
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#define MAXEDGE 1000
using namespace std;
typedef struct{
int linked_to;
}edg;
typedef struct{
edg edge[MAXEDGE];
bool visited[MAXEDGE];
int total_nodes;
}graph;
int main() {
int u,v,n = 0;
graph *g;
scanf("%d",&g->total_nodes);
for(int i = 0; i<g->total_nodes; i++){
scanf("%d %d",&u,&v);
g->edge[u].linked_to = v;
}
return 0;
}