adj_list_graph.c
#include "adj_list_graph.h"
bool *visited;
PAdjGraph GraphInit()
{
char src[GRAPH_NODE_MAX_SIZE] = {
0};
PAdjGraph graph = (PAdjGraph)malloc(sizeof(AdjGraph));
if(graph == NULL) {
perror("graph malloc error.");
return (PAdjGraph)GRAPH_ERR;
}
printf("Please input the number of vertex nodes.\n");
scanf("%d", &graph->nodeSize);
printf("Please input the number of edges.\n");
scanf("%d", &graph->edgeSize);
graph->node = (PVertexNode)malloc(sizeof(VertexNode) * graph->nodeSize);
if(graph->node == NULL) {
perror("vertex node malloc error.");
return (PAdjGraph)GRAPH_ERR;
}
printf("Please input the src nodes.\n");
scanf("%s", src);