Chain-forward Star

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.