Algorithm research: The key path of solving AOE network

Source: Internet
Author: User
Tags count sort

We briefly introduce some concepts of AOE network and key path, and then analyze the main function of solving the critical path program. The existing AOE net Figure 7-9-4 shows that we use the adjacency table storage structure, attention and topology ordering when the adjacent table structure is different, where the ARC table node added weight field, used to store the arc of the weight value.

The process of solving the earliest occurrence of an event, ETV, is that we look through the process of topological sequence, so before the critical path, we need to call the code of the topology sequence algorithm to calculate the ETV and Topology sequence list, we have discussed the previous AOV Network and topology sequencing program to improve the code as follows

/* Topology sort, if GL has no loop, the output topology sort sequence and return 1, if there is a loop return 0.
    * * BOOL Topologicalsort (graphadjlist GL) {Edgenode *pe;
    int I, k, gettop; int top = 0;/* for stack pointer subscript/int count = 0;/* to count output vertices/////* Build stack will be 0 vertices into stack */int *stack = (int *) malloc (gl-
    
    >numvertexes * sizeof (int)); for (i = 0; i < gl->numvertexes; i++) if (0 = = gl->adjlist[i].in) Stack[++top] = i;/* The top with a degree of 0
    Point into Stack * * top2 = 0;
    ETV = (int *) malloc (gl->numvertexes * sizeof (int)); for (i = 0; i < gl->numvertexes; i++) etv[i] = 0;
    
    /* Initialize */stack2 = (int *) malloc (gl->numvertexes * sizeof (int));
    
    cout << "Topologicalsort ..." << Endl;
        while (top!= 0) {gettop = stack[top--];
        cout << gl->adjlist[gettop].data << "->";  count++; /* Output I vertex, and count * * * STACK2[++TOP2] = gettop; /* Will eject the vertex number into the topology sequence of the stack * * for (PE = gl->adjlist[gettop].firstedge; pe; PE = PE->next) {k = pe->adjvex; /* To reduce the number of adjacent points of the I vertex by 1, if minus 1 after 0, then into the stack/if (!
            --gl->adjlist[k].in)) stack[++top] = k; * To find the earliest occurrence time of each vertex event ETV value/if ((etv[gettop) + pe->weight) > Etv[k]) etv[k] = Etv[gettop] +
        pe->weight;
    }} cout << Endl;
    if (Count < gl->numvertexes) return false;
else return true; }

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.