1.邻接矩阵 
int E[110 ][110 ];
E[1 ][2 ]=1;
E[5 ][3 ]=0; 
2.邻接链表 
#include <vector> 
#include <cstdio> 
using  namespace  std ;
const  int  MAXN = 100000 ;
vector <int >  edge[MAXN];
int  main()
{
    int  n, m; 
    for (int  i = 0 ; i < m; ++i)
    {
        int  a, b;
        scanf ("%d%d" , &a, &b);
        edge[a].push_back(b);
        
    }
    return  0 ;
} 
3.前向星 
typedef  struct  edge{
    int  to; 
    int  next;
    
}edge;
edge edges[1010 ];     
int  head[110 ];        
int  cnt;              
void  init() {         
    memset (head, -1 , sizeof (head));
    cnt = 0 ;
}
void  addEdge(int  u,int  v) {
    
    edges[cnt].to = v;    
    edges[cnt].next = head[u];     
    head[u] = cnt++;
}
int  main() {
    int  n, t1, t2;
    init();
    scanf ("%d" , &n);
    for (int  i = 0 ; i < n; i++) {
        scanf ("%d%d" , &t1, &t2);
        addEdge(t1, t2);
        
    }
} 
编号 起点 终点 第0条 1 2 第1条 2 3 第2条 3 4 第3条 1 3 第4条 4 1 第5条 1 5 第6条 4 5 
edge[0 ].to  = 2 ;   edge[0 ].next  = -1 ;    head[1 ] = 0 ;
edge[1 ].to  = 3 ;   edge[1 ].next  = -1 ;    head[2 ] = 1 ;
edge[2 ].to  = 4 ;   edge[2 ],next  = -1 ;    head[3 ] = 2 ;
edge[3 ].to  = 3 ;   edge[3 ].next  = 0 ;     head[1 ] = 3 ;
edge[4 ].to  = 1 ;   edge[4 ].next  = -1 ;    head[4 ] = 4 ;
edge[5 ].to  = 5 ;   edge[5 ].next  = 3 ;     head[1 ] = 5 ;
edge[6 ].to  = 5 ;   edge[6 ].next  = 4 ;     head[4 ] = 6 ; 
很明显,head[i]保存的是以i为起点的所有边中编号最大的那个,而把这个当作顶点i的第一条起始边的位置。这样在遍历时是倒着遍历的,也就是说与输入顺序是相反的,不过这样不影响结果的正确性。 比如以上图为例,以节点1为起点的边有3条,它们的编号分别是0,3,5,而head[1] = 5,我们在遍历以u节点为起始位置的所有边的时候是这样的:  
for (int i =head[u] ; ~i ; i =edge[i]. next) 
那么就是说先遍历编号为5的边,也就是head[1],然后就是edge[5].next,也就是编号3的边,然后继续edge[3].next,也  
就是编号0的边,可以看出是逆序的。