// include/graph.h #ifndef GRAPH_H #define GRAPH_H #include #include "station.h" #include "route.h" // 邻接表节点 typedef struct AdjNode { int stationId; int routeId; double travelTime; // 行驶时间(分钟) struct AdjNode* next; } AdjNode; // 邻接表 typedef struct AdjList { AdjNode* head; } AdjList; // 图结构 typedef struct Graph { AdjList adjLists[MAX_STATIONS]; int vertexCount; } Graph; // 路径节点 typedef struct PathNode { int stationId; int routeId; double time; struct PathNode* next; } PathNode; // 图操作函数 Graph* createGraph(int vertexCount); void destroyGraph(Graph* graph); void addEdge(Graph* graph, int from, int to, int routeId, double travelTime); void buildGraphFromRoutes(Graph* graph, const BusRoute routes[], int routeCount, const Station stations[], int stationCount); // 路径查询函数 PathNode* dijkstra(Graph* graph, int start, int end, double* totalTime); void freePath(PathNode* path); void displayPath(PathNode* path, const Station stations[], int stationCount, const BusRoute routes[], int routeCount); #endif