Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
33
Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-3.j
Normal file
33
Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-3.j
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
floydrecon=: verb define
|
||||
n=. ($y)$_(I._=,y)},($$i.@#)y
|
||||
for_j. i.#y do.
|
||||
d=. y <. j ({"1 +/ {) y
|
||||
b=. y~:d
|
||||
y=. d
|
||||
n=. (n*-.b)+b * j{"1 n
|
||||
end.
|
||||
)
|
||||
|
||||
task=: verb define
|
||||
dist=. floyd y
|
||||
next=. floydrecon y
|
||||
echo 'pair dist path'
|
||||
for_i. i.#y do.
|
||||
for_k. i.#y do.
|
||||
ndx=. <i,k
|
||||
if. (i~:k)*_>ndx{next do.
|
||||
txt=. (":1+i),'->',(":1+k)
|
||||
txt=. txt,_5{.":ndx{dist
|
||||
txt=. txt,' ',":1+i
|
||||
j=. i
|
||||
while. j~:k do.
|
||||
assert. j~:(<j,k){next
|
||||
j=. (<j,k){next
|
||||
txt=. txt,'->',":1+j
|
||||
end.
|
||||
echo txt
|
||||
end.
|
||||
end.
|
||||
end.
|
||||
i.0 0
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue