I have created a function as

function ShortestPath(DAG, K2Score)

for i = 1:length(K2Score)

ind = findall(K2Score .== 0)

#K2Score[1,ind] ~= root,

K2Score[1,ind] = 0.01end

## Finding the root.

G = DAG

M,N = size[DAG]

k = 1

for i in 1:M

for j in 1:N

if G[i,j] ~= 0

a[1,k] = i

a[2,k] = j

k = k +1

end

end

endn = k-1

k = 1;

for j in 1:N

flag = 0

for i in 1:M

if G[i,j] ~= 0

flag = 1

end

end

if flag .== 0

root[1,k] = j; # Must store all the values

k = k+1

end

end## Applying bellman algorithm

for ii = 1:length(root)

k =1

for i = 1:n

if a[1,i] .== root[1,ii]

b[1,k] = a[1,i]

b[2,k] = a[2,i]

k = k+1

end

endfor i = 1:n

if a[1,i] ~= root[1,ii]

b[1,k] = a[1,i]

b[2,k] = a[2,i]

k = k+1

end

endfor i = 1:M

for ii = 1:length(root)

dist[ii,i] = 20000; # infinity Value

end

enddist[ii,root[1,ii]] = 0

for i = 1: M

for j = 1:n

k = dist[ii,b[1,j]] + 1

if k .< dist[ii,b[2,j]]

dist[ii,b[2,j]] = k

end

end

end## Finding the minimum of distance

final_dist = minimum(dist, dims = 1)

end

return final_dist

end

And I am us

final_dist_UCII_WOMEN = ShortestPath(UCIV_WOMEN_DAG, UCIV_WOMEN_K2Score)

Throughs an error like

```
BoundsError: attempt to access 1×112 Array{Float64,2} at index [1, CartesianIndex{2}[CartesianIndex(1, 79), CartesianIndex(1, 82), CartesianIndex(1, 83), CartesianIndex(1, 85), CartesianIndex(1, 88), CartesianIndex(1, 91), CartesianIndex(1, 94), CartesianIndex(1, 97), CartesianIndex(1, 104)]]
Stacktrace:
[1] throw_boundserror(::Array{Float64,2}, ::Tuple{Int64,Array{CartesianIndex{2},1}}) at .\abstractarray.jl:541
[2] checkbounds at .\abstractarray.jl:506 [inlined]
[3] _setindex! at .\multidimensional.jl:784 [inlined]
[4] setindex! at .\abstractarray.jl:1153 [inlined]
[5] ShortestPath(::Array{Float64,2}, ::Array{Float64,2}) at .\In[33]:6
[6] top-level scope at In[34]:1
[7] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091
```

The data in UCIV_WOMEN_K2Score is like

```
Tables.MatrixTable{Array{Float64,2}}:
:Column1 [-282.75936567503123]
:Column2 [-305.58336610157846]
:Column3 [-292.41728385977933]
:Column4 [-305.18462549235426]
:Column5 [-274.38053518866104]
:Column6 [-264.9541448871945]
:Column7 [-220.70659792617909]
:Column8 [-134.11407429858826]
:Column9 [-238.25801615743833]
:Column10 [-223.2858117418622]
:Column11 [-297.1694634952932]
:Column12 [-296.66690599815234]
:Column13 [-280.3308279437817]
:Column14 [-232.9550950909364]
:Column15 [-232.13675627716506]
:Column16 [-236.38528000947178]
:Column17 [-261.930952318306]
:Column18 [-260.73925958765756]
:Column19 [-289.29985505843]
:Column20 [-248.3846110642878]
:Column21 [-265.17573796201276]
:Column22 [-304.0344529707333]
:Column23 [-289.8263398616875]
:Column24 [-257.0691832080685]
:Column25 [-291.3757440508586]
:Column26 [-264.0948838305343]
:Column27 [-292.5600596311132]
:Column28 [-249.35945573391615]
:Column29 [-81.92327266391918]
:Column30 [-119.47535227825449]
:Column31 [-290.87671876102786]
:Column32 [-259.1160299476976]
:Column33 [-274.5405597958887]
:Column34 [-282.42420745421214]
:Column35 [-250.5227823754762]
:Column36 [-237.45806324419493]
:Column37 [-311.6203721601196]
:Column38 [-284.93117212740185]
:Column39 [-273.39518795019046]
:Column40 [-217.78300320183075]
:Column41 [-251.84915951112367]
:Column42 [-272.9138143613708]
:Column43 [-287.4156101302241]
:Column44 [-114.37471605094095]
:Column45 [-161.41934549656662]
:Column46 [-261.84687097011204]
:Column47 [-274.9514937520016]
:Column48 [-158.65000549478196]
:Column49 [-109.86505012401156]
:Column50 [-213.1359440025262]
:Column51 [-75.29153514406694]
:Column52 [-195.70559894473286]
:Column53 [-213.0431581230352]
:Column54 [-281.5760210196869]
:Column55 [-295.204849892014]
:Column56 [-8.409162447202561]
:Column57 [-129.96265278868083]
:Column58 [-199.24228981544687]
:Column59 [-279.023929653169]
:Column60 [-170.92260998595782]
:Column61 [-96.28484854268876]
:Column62 [-84.50709805496444]
:Column63 [-28.22050948456115]
:Column64 [-5.105945473900647]
:Column65 [-46.82916759238583]
:Column66 [-8.409162447202561]
:Column67 [-8.409162447202561]
:Column68 [-8.409162447202561]
:Column69 [-8.409162447202561]
:Column70 [-8.409162447202561]
:Column71 [-15.468565275793821]
:Column72 [-8.409162447202561]
:Column73 [-8.409162447202561]
:Column74 [-8.409162447202561]
:Column75 [-8.409162447202561]
:Column76 [-13.299511575424276]
:Column77 [-8.409162447202561]
:Column78 [-8.409162447202561]
:Column79 [0.0]
:Column80 [-8.409162447202561]
:Column81 [-8.409162447202561]
:Column82 [0.0]
:Column83 [0.0]
:Column84 [-8.409162447202561]
:Column85 [0.0]
:Column86 [-8.409162447202561]
:Column87 [-8.409162447202561]
:Column88 [0.0]
:Column89 [-8.409162447202561]
:Column90 [-8.409162447202561]
:Column91 [0.0]
:Column92 [-15.468565275793821]
:Column93 [-15.468565275793821]
:Column94 [0.0]
:Column95 [-8.409162447202561]
:Column96 [-8.409162447202561]
:Column97 [0.0]
:Column98 [-5.105945473900647]
:Column99 [-5.105945473900647]
:Column100 [-5.105945473900647]
:Column101 [-5.105945473900647]
:Column102 [-15.468565275793821]
:Column103 [-5.105945473900647]
:Column104 [0.0]
:Column105 [-8.409162447202561]
:Column106 [-15.468565275793821]
:Column107 [-5.105945473900647]
:Column108 [-5.105945473900647]
:Column109 [-5.105945473900647]
:Column110 [-5.105945473900647]
:Column111 [-8.409162447202561]
:Column112 [-15.468565275793821]
```

Please help me to figure out the problem.

Thanks