Data:
Type
Edegnode=record
T,w,next:longint;
End;
Var
E:array[1..m]of Longint;
Head:array[1..n]of Longint;
Read-in Edge:
For I:=1 to n do head[i]:=-1;
For I:=1 to M do
Begin
READLN (U,E[I].T,E[I].W);
E[i].next:=head[u];
Head[u]:=i;
End;
Traverse the code:
For I:=1 to N do
Begin
K:=head[i];
While K<>-1 do
Begin
Each operation
K:=e[k].next;
End;
End;
The advantage of chain forward star is that in addition to the necessary edge information storage space, only need very little extra space can be realized, the code and principle is relatively simple, can store the heavy edge, can cope with the number of points and edges is very large situation, should say besides can not directly with the starting point and the end point to determine whether there is an edge outside. The chain-forward star is almost perfect.
To store a forward edge with a chain forward to the star, it is stored two times.
Chain-forward Star