tree Subroutine

private subroutine tree(iroot, ndstk, nr, lvl, iwk, ndeg, lvlwth, lvlbot, lvln, maxlw, ibort)

Arguments

Type IntentOptional AttributesName
integer :: iroot
integer :: ndstk
integer :: nr
integer :: lvl
integer :: iwk
integer :: ndeg
integer :: lvlwth
integer :: lvlbot
integer :: lvln
integer :: maxlw
integer :: ibort

Called by

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

Contents

Source Code


Source Code

    SUBROUTINE TREE(IROOT, NDSTK, NR, LVL, IWK, NDEG, LVLWTH, LVLBOT, LVLN, MAXLW, IBORT)
        !  TREE DROPS A TREE IN NDSTK FROM IROOT
        !  LVL-         ARRAY INDICATING AVAILABLE NODES IN NDSTK WITH ZERO
        !               ENTRIES. TREE ENTERS LEVEL NUMBERS ASSIGNED
        !               DURING EXECUTION OF THIS PROCEDURE
        !  IWK-         ON OUTPUT CONTAINS NODE NUMBERS USED IN TREE
        !               ARRANGED BY LEVELS (IWK(LVLN) CONTAINS IROOT
        !               AND IWK(LVLBOT+LVLWTH-1) CONTAINS LAST NODE ENTERED)
        !  LVLWTH-      ON OUTPUT CONTAINS WIDTH OF LAST LEVEL
        !  LVLBOT-      ON OUTPUT CONTAINS INDEX INTO IWK OF FIRST
        !               NODE IN LAST LEVEL
        !  MAXLW-       ON OUTPUT CONTAINS THE MAXIMUM LEVEL WIDTH
        !  LVLN-        ON INPUT THE FIRST AVAILABLE LOCATION IN IWK
        !               USUALLY ONE BUT IF IWK IS USED TO STORE PREVIOUS
        !               CONNECTED COMPONENTS, LVLN IS NEXT AVAILABLE LOCATION.
        !               ON OUTPUT THE TOTAL NUMBER OF LEVELS + 1
        !  IBORT-       INPUT PARAM WHICH TRIGGERS EARLY RETURN IF
        !               MAXLW BECOMES >= IBORT
        ! USE INTEGER*2 NDSTK  WITH AN IBM 360 OR 370.
        INTEGER NDSTK
        DIMENSION NDSTK(NR,IDEG), LVL(N), IWK(N), NDEG(N)
        MAXLW = 0
        ITOP = LVLN
        INOW = LVLN
        LVLBOT = LVLN
        LVLTOP = LVLN + 1
        LVLN = 1
        LVL(IROOT) = 1
        IWK(ITOP) = IROOT
10      LVLN = LVLN + 1
20      IWKNOW = IWK(INOW)
        NDROW = NDEG(IWKNOW)
        DO 30 J=1,NDROW
            ITEST = NDSTK(IWKNOW,J)
            IF (LVL(ITEST)/=0) CYCLE
            LVL(ITEST) = LVLN
            ITOP = ITOP + 1
            IWK(ITOP) = ITEST
30      END DO
        INOW = INOW + 1
        IF (INOW < LVLTOP) GO TO 20
        LVLWTH = LVLTOP - LVLBOT
        IF (MAXLW < LVLWTH) MAXLW = LVLWTH
        IF (MAXLW>=IBORT) RETURN
        IF (ITOP < LVLTOP) RETURN
        LVLBOT = INOW
        LVLTOP = ITOP + 1
        GO TO 10
    END SUBROUTINE TREE