stdists←{                   ⍝ Spanning-tree path lengths.
    tree←⍵                  ⍝ spanning tree
    0{                      ⍝ distance from root
        next dvec←⍵         ⍝ chldren and distance vector
        next≡⍬:dvec         ⍝ no children: finished
        ∆dvec←⍺@nextdvec   ⍝ extended distance vector
        ∆next←⍸treenext    ⍝ grandchildren
        (⍺+1)∆next ∆dvec  ⍝ examine rest of tree
    }(⍵⍳¯1)(⍵⊢¨¯1)          ⍝ starting vertex and initial distances
}

code_colours

test script

Back to: notes

Back to: Workspaces