#include<stdio.h>
#include<stdlib.h>
#include<queue>
typedef int Vertex;
typedef int WeightType;
typedef int DataType;
struct Edge {
Vertex A;
Vertex B;
WeightType Weight;
};
typedef struct AdjVNode* PtrAdjVNode;
struct AdjVNode {
PtrAdjVNode Next;
Vertex Node;
WeightType Weight;
};
struct VNode {
PtrAdjVNode FirstAdjV;
DataType Data;
};
struct GNode {
int Nv;
int Ne;
struct VNode* G;
};
typedef struct GNode* MyGraph;
MyGraph CreateGraph(int N);
void InitializeGraph(MyGraph Graph);
int main()
{
int N;
scanf("%d", &N);
MyGraph Graph = CreateGraph(N);
InitializeGraph(Graph);
}
MyGraph CreateGraph(int N)
{
MyGraph Graph = (MyGraph)malloc(sizeof(struct GNode));
Graph->Nv = N;
Graph->G = (struct VNode*)malloc(sizeof(struct VNode) * (N + 1));
for (int i = 1; i <= N; i++)
{
Graph->G[i].FirstAdjV = NULL;
}
return Graph;
}
void InitializeGraph(MyGraph Graph)
{
int AdjNum;
Vertex NodeName;
for (int i = 1; i <= Graph->Nv; i++)
{
scanf("%d", &AdjNum);
for (int j = 1; j <= AdjNum; j++)
{
scanf("%d", &NodeName);
PtrAdjVNode NewAdjNode = (PtrAdjVNode)malloc(sizeof(struct AdjVNode));
NewAdjNode->Node = NodeName;
NewAdjNode->Weight = 1;
NewAdjNode->Next = Graph->G[i].FirstAdjV;
Graph->G[i].FirstAdjV = NewAdjNode;
}
}
}
要做微博那道题,突然发现这样不行..先存着吧