//个人认为,陈越书上的相关代码过于繁琐,如太多的typedef和较长的变量命名,对于学生,实用性差;所以自己写了个线性表,才疏学浅,还望读者批评指正
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define MAXN 100
int n,m;
struct AdjList{
int v;
int weight;
struct AdjList* next;
}map[100];
void Init(){
for(int i=1;i<=n;i++){
map[i].v=i;
map[i].next=NULL;
}
return;
}
void Add(int x,int y,int w){
struct AdjList* temp=(struct AdjList*)malloc(sizeof(struct AdjList));
temp->v=y;
temp->weight=w;
temp->next=map[x].next;
map[x].next=temp;
return;
}
int main(){
int x,y,w;
cin>>n>>m;
Init();
for(int i=1;i<=m;i++){
cin>>x>>y>>w;
Add(x,y,w);//默认有向图 无向图得加两条边
}
}
//如果用到 指向一个顶点的点 等相关数据,可以让next指向 以当前节点为终点的边 的起点