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; }