为了解决用邻接表存储入度计算复杂的问题,由邻接表升级为十字链表,保存了顶点的出度和入度情况。
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
//边
typedef struct Edge
{
int in;
int out;
struct Edge* in_next;
struct Edge* out_next;
//void* info;
}Edge;
//创建边
Edge* create_edge(int in,int out)
{
Edge* edge = malloc(sizeof(Edge));
edge->in = in;
edge->out = out;
edge->in_next = NULL;
edge->out_next = NULL;
return edge;
}
//顶点
typedef