[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35] [36] [37] [38] [39] [40] [41] [42] [43] [44] [45] [46] [ 47 ] [48] [49] [50] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62] [63] [64] [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78] [79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90] [91] [92] [93] [94] [95] [96] [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108] [109] [110] [111] [112] [113] [114] [115] [116] [117]

( W DFS). , . , ,

DFS [) DFSm V W

DFS (6)

RETURN RETURN

RETURN RETURN

DFS (2)

DFS{3)

.(3)

"l

4 "

a"

"a

. 3.5.4. DFS.

, DPS . , . 3.5.6 T(G) , G, G T(G).

DPS :

1. , . , .

2. -I , , , -1 .

3. G -1 , .

DPS.

DPS . , G= (V, ), 0{}\), . . . , G 12 . , DPS 1 V\ .

, .



PR06RftH SPftN tINPOT»OUTPUT,TAPE5iINPUTiTftPE6=0UTPUTI

G. , DFS, 8 11 .

.

ADJ ()

MEXTIK) , ) . 1 .LE. .LE.P

ADJ(K> = , J = NEXT(K), ADJ(J)-nEPBAB

d , . ,

, ADJ QNEXTCJ)), . ..

TPEE(Jill J-E , .

TREE(Ji2)

«I , , .

G 1, 2, .... .

. Ui U UHV.

WORDS WORDS = + Z*tt,

AOJ NEXT.

"

INTEGER . Qt « . , VOROS

INTEGER ADJdOOOli NEXTllOOOli TREE(100i2)

6.

READ(S«1000» P«Q 1000 FORMAT

I = + 1

uoRDs = p t « ct

ADJ NEXT.

DO = It ADJ(n) = NEXTtH! = 100 CONTINUE

6 ..

00 N = It

READ (StlOOOl U,V NEXTCII NEXT(U> ADJdl s V UEXTIU) I 1 = 1*1 WEXTdl = HEXTJV) ADJdl =

. WEXT(V» = I 1 = 1 + 1 200 CONTINUE

DFS G,

V=l. DFS

TREE.

CAUU DFs f AOJt NEXTt It TREEt Pt WORDSt T ) Q .

. 3.5.5. DFS . ( 2000: « G»; 2100: « »; 2300: «, »; 1000: « DFS>>.)



WRITE (6i2000) (l.ADjdJ.NExTd). I = 1,WORDS) 2000 FORMAT t THE LIST REPRESENTATION OF NETWORK G > + 23H I ADJ NEXT </. { IHOt I8i lEi !£) )

write: (612100) 2100 FORMAT { 1H1,22H SPANfJINS TREE EDGES )

= T - 1

WRITE (6f2200) (( TREEdiJIi J=l«2)i IsitK S 2200 FORMAT ( IHOi I10« I6 ) ♦

IF I T ,E(J, P I STOP

WRITE {«)

2300 FORMAT { 1H1,41H NOTE THAT THE NETWORK IS NOT CONNECTED. )

STOP END

SUBROUTINE DFS ADJ. NEXTi Ut TREE. Pi WORDS. T I

. DFS - G, .LE. 100 . G , AOJ(WOBOS) NEXT (WORDS), WORDS = - 2*Q. DFS TREE V. G , DFS G, V. DFS , .

V V.

, V.

VISIT(VI=I , V 1- , . VISIT(.V) = 0 , V .

STORE

. , V , V. .LE. 100, 200 .

PTR .

- .

,

.

INTEGER . PTR. . V. U. WORDS INTEGER ADJ(W0RDS1. NEXT(W0RDS1, STORE(200l. TREE«lO0i2) INTEGER VlSITtlOB)

.

00 100 I s 1,100 VISIT(I) = 0

100 CONTINUE PTR = 0 T = I



[0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35] [36] [37] [38] [39] [40] [41] [42] [43] [44] [45] [46] [ 47 ] [48] [49] [50] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62] [63] [64] [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78] [79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90] [91] [92] [93] [94] [95] [96] [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108] [109] [110] [111] [112] [113] [114] [115] [116] [117]

0.0014