fndiam Subroutine

private subroutine fndiam(snd1, snd2, ndstk, nr, ndeg, lvl, lvls1, lvls2, iwk, idflt)

Arguments

Type IntentOptional AttributesName
integer :: snd1
integer :: snd2
integer :: ndstk
integer :: nr
integer :: ndeg
integer :: lvl
integer :: lvls1
integer :: lvls2
integer :: iwk
integer :: idflt

Calls

proc~~fndiam~~CallsGraph proc~fndiam fndiam proc~tree tree proc~fndiam->proc~tree

Called by

proc~~fndiam~~CalledByGraph proc~fndiam fndiam proc~reduce reduce proc~reduce->proc~fndiam

Contents

Source Code


Source Code

    SUBROUTINE FNDIAM(SND1, SND2, NDSTK, NR, NDEG, LVL, LVLS1,LVLS2, IWK, IDFLT)
        !  FNDIAM IS THE CONTROL PROCEDURE FOR FINDING THE PSEUDO-DIAMETER OF
        !  NDSTK AS WELL AS THE LEVEL STRUCTURE FROM EACH END
        !  SND1-        ON INPUT THIS IS THE NODE NUMBER OF THE FIRST
        !               ATTEMPT AT FINDING A DIAMETER.  ON OUTPUT IT
        !               CONTAINS THE ACTUAL NUMBER USED.
        !  SND2-        ON OUTPUT CONTAINS OTHER END OF DIAMETER
        !  LVLS1-       ARRAY CONTAINING LEVEL STRUCTURE WITH SND1 AS ROOT
        !  LVLS2-       ARRAY CONTAINING LEVEL STRUCTURE WITH SND2 AS ROOT
        !  IDFLT-       FLAG USED IN PICKING FINAL LEVEL STRUCTURE, SET
        !               =1 IF WIDTH OF LVLS1  <=  WIDTH OF LVLS2, OTHERWISE =2
        !  LVL,IWK-     WORKING STORAGE
        ! USE INTEGER*2 NDSTK  WITH AN IBM 360 OR 370.
        INTEGER NDSTK
        INTEGER FLAG, SND, SND1, SND2
        ! COMMON /GRA/ N, IDPTH, IDEG
        ! IT IS ASSUMED THAT THE LAST LEVEL HAS AT MOST 100 NODES.
        ! COMMON /CC/ NDLST(100)
        INTEGER,POINTER :: NDLST(:)
        DIMENSION NDSTK(NR,IDEG), NDEG(1), LVL(N), LVLS1(N), LVLS2(N),IWK(N)
        !
        NDLST => AUX
        !
        FLAG = 0
        MTW2 = N
        SND = SND1
        ! ZERO LVL TO INDICATE ALL NODES ARE AVAILABLE TO TREE
10      DO 20 I=1,N
            LVL(I) = 0
20      END DO
        LVLN = 1
        ! DROP A TREE FROM SND
        CALL TREE(SND, NDSTK, NR, LVL, IWK, NDEG, LVLWTH, LVLBOT,LVLN, MAXLW, MTW2)
        IF (FLAG>=1) GO TO 50
        FLAG = 1
30      IDPTH = LVLN - 1
        MTW1 = MAXLW
        ! COPY LEVEL STRUCTURE INTO LVLS1
        DO 40 I=1,N
            LVLS1(I) = LVL(I)
40      END DO
        NDXN = 1
        NDXL = 0
        MTW2 = N
        ! SORT LAST LEVEL BY DEGREE  AND STORE IN NDLST
        CALL SORTDG(NDLST, IWK(LVLBOT), NDXL, LVLWTH, NDEG)
        SND = NDLST(1)
        GO TO 10
50      IF (IDPTH>=LVLN-1) GO TO 60
        ! START AGAIN WITH NEW STARTING NODE
        SND1 = SND
        GO TO 30
60      IF (MAXLW>=MTW2) GO TO 80
        MTW2 = MAXLW
        SND2 = SND
        ! STORE NARROWEST REVERSE LEVEL STRUCTURE IN LVLS2
        DO 70 I=1,N
            LVLS2(I) = LVL(I)
70      END DO
80      IF (NDXN == NDXL) GO TO 90
        ! TRY NEXT NODE IN NDLST
        NDXN = NDXN + 1
        SND = NDLST(NDXN)
        GO TO 10
90      IDFLT = 1
        IF (MTW2 <= MTW1) IDFLT = 2
        NULLIFY(NDLST)
        RETURN
    END SUBROUTINE FNDIAM