Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -1,12 +1 @@
|
|||
graph=: ".;._2]0 :0
|
||||
0 _ _2 _ NB. 1->3 costs _2
|
||||
4 0 3 _ NB. 2->1 costs 4; 2->3 costs 3
|
||||
_ _ 0 2 NB. 3->4 costs 2
|
||||
_ _1 _ 0 NB. 4->2 costs _1
|
||||
)
|
||||
|
||||
floyd graph
|
||||
0 _1 _2 0
|
||||
4 0 2 4
|
||||
5 1 0 2
|
||||
3 _1 1 0
|
||||
floyd=: ]F..(]<.{"1+/{) i.@#
|
||||
|
|
|
|||
|
|
@ -1,33 +1,12 @@
|
|||
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.
|
||||
graph=: ".;._2]0 :0
|
||||
0 _ _2 _ NB. 1->3 costs _2
|
||||
4 0 3 _ NB. 2->1 costs 4; 2->3 costs 3
|
||||
_ _ 0 2 NB. 3->4 costs 2
|
||||
_ _1 _ 0 NB. 4->2 costs _1
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
floyd graph
|
||||
0 _1 _2 0
|
||||
4 0 2 4
|
||||
5 1 0 2
|
||||
3 _1 1 0
|
||||
|
|
|
|||
|
|
@ -1,14 +1,33 @@
|
|||
task graph
|
||||
pair dist path
|
||||
1->2 _1 1->3->4->2
|
||||
1->3 _2 1->3
|
||||
1->4 0 1->3->4
|
||||
2->1 4 2->1
|
||||
2->3 2 2->1->3
|
||||
2->4 4 2->1->3->4
|
||||
3->1 5 3->4->2->1
|
||||
3->2 1 3->4->2
|
||||
3->4 2 3->4
|
||||
4->1 3 4->2->1
|
||||
4->2 _1 4->2
|
||||
4->3 1 4->2->1->3
|
||||
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
|
||||
)
|
||||
|
|
|
|||
14
Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-5.j
Normal file
14
Task/Floyd-Warshall-algorithm/J/floyd-warshall-algorithm-5.j
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
task graph
|
||||
pair dist path
|
||||
1->2 _1 1->3->4->2
|
||||
1->3 _2 1->3
|
||||
1->4 0 1->3->4
|
||||
2->1 4 2->1
|
||||
2->3 2 2->1->3
|
||||
2->4 4 2->1->3->4
|
||||
3->1 5 3->4->2->1
|
||||
3->2 1 3->4->2
|
||||
3->4 2 3->4
|
||||
4->1 3 4->2->1
|
||||
4->2 _1 4->2
|
||||
4->3 1 4->2->1->3
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import "/fmt" for Fmt
|
||||
import "./fmt" for Fmt
|
||||
|
||||
class FloydWarshall {
|
||||
static doCalcs(weights, nVertices) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue