AOV engineering network diagram calculation

zhaozj2021-02-08  224

Below is a C code to calculate the AOV engineering network diagram, which conform to the ANSI standard, which can be used in most compilers.

#include #include #include

#define MAX_V_NUM 1024 // maximum number of vertices #define WORD32 unsigned long # define WORD32_BLEN 4 # define MAX_WORD32 0xffffffffL # define INIT_AOV memset ((void *) & g_aov, (char) 0xff, (size_t) MAX_V_NUM * MAX_V_NUM * WORD32_BLEN) #define IN_FILE_NAME "aov.in" #define err_file_not_found 1 # define true 1

WORD32 G_AOV [MAX_V_NUM] [MAX_V_NUM]; WORD32 G_E [MAX_V_NUM], G_L [MAX_V_NUM]; int G_n;

// Function predefined - Start Void Input_init (); void cagc_el (); void print_result (); // Function predefined - end

Void INPUT_INIT () {Word32 I, J, K; File * fp_in;

Init_aov;

FP_IN = fopen (IN_FILE_NAME, "R"); if (fp_in == null) {printf ("File Not Found! / N"); EXIT (Err_File_not_found);} fscanf (fp_in, "% d / n", & g_n) While (true) {fscanf (fp_in, "% lu% lu% lu", & i, & j, & k); if ((i == 0) && (j == 0) && (k == 0)) Break G_AOV [i - 1] [j - 1] = k; fscanf (fp_in, "/ n");} fclose (fp_in);

g_e [0] = 0;

Void Calc_el () {Word32 Ext; INT I, J;

For (i = 1; i EXT) EXT = G_E [J] G_AOV [J] [I]; G_E [I] = EXT;

G_L [g_n - 1] = g_e [g_n - 1]; for (i = g_n - 2; i> = 0; I -) {ext = max_word32; for (j = 0; j

Void Print_Result () {INT I, J;

Printf ("# / te / t / tl / n"); for (i = 0; i

Return 0;}

The format of the input file Aov.in is like this:

First line: n, indicate the number of vertices

Each line is a process

Finally end with 0 0 0

Matters 1 For the starting matters, the matter n is the last item.

In the output, * is a point on the critical path.

转载请注明原文地址:https://www.9cbs.com/read-2628.html

New Post(0)