Open
Description
That would make it easier to maintain the association between the original grid and the distance values. E.g. it would allow for something like
julia> g = ConScape.Grid(size(r)..., affinities=a, costs=_cost, prune=true)
[ Info: cost graph contains 6 strongly connected subgraphs
[ Info: removing 8 nodes from affinity and cost graphs
ConScape.Grid of size 4x4
julia> lc = ConScape.least_cost_distance(g)
8×8 Matrix{Float64}:
0.0 0.693147 1.38629 2.07944 0.693147 1.38629 2.07944 2.77259
0.693147 0.0 0.693147 1.38629 1.38629 0.693147 1.38629 2.07944
1.38629 0.693147 0.0 0.693147 2.07944 1.38629 0.693147 1.38629
2.07944 1.38629 0.693147 0.0 2.77259 2.07944 1.38629 0.693147
1.38629 2.07944 2.77259 3.46574 0.0 1.38629 2.77259 4.15888
2.07944 1.38629 2.07944 2.77259 1.38629 0.0 1.38629 2.77259
2.77259 2.07944 1.38629 2.07944 2.77259 1.38629 0.0 1.38629
3.46574 2.77259 2.07944 1.38629 4.15888 2.77259 1.38629 0.0
julia> lc_aa = AxisArray(lc, source=vec(CartesianIndices((4,4))[:,3:4]), target=vec(CartesianIndices((4,4))[:,3:4]))
2-dimensional AxisArray{Float64,2,...} with axes:
:source, CartesianIndex{2}[CartesianIndex(1, 3), CartesianIndex(2, 3), CartesianIndex(3, 3), CartesianIndex(4, 3), CartesianIndex(1, 4), CartesianIndex(2, 4), CartesianIndex(3, 4), CartesianIndex(4, 4)]
:target, CartesianIndex{2}[CartesianIndex(1, 3), CartesianIndex(2, 3), CartesianIndex(3, 3), CartesianIndex(4, 3), CartesianIndex(1, 4), CartesianIndex(2, 4), CartesianIndex(3, 4), CartesianIndex(4, 4)]
And data, a 8×8 Matrix{Float64}:
0.0 0.693147 1.38629 2.07944 0.693147 1.38629 2.07944 2.77259
0.693147 0.0 0.693147 1.38629 1.38629 0.693147 1.38629 2.07944
1.38629 0.693147 0.0 0.693147 2.07944 1.38629 0.693147 1.38629
2.07944 1.38629 0.693147 0.0 2.77259 2.07944 1.38629 0.693147
1.38629 2.07944 2.77259 3.46574 0.0 1.38629 2.77259 4.15888
julia> lc_aa[:, atvalue(CartesianIndex(3,4))]
1-dimensional AxisArray{Float64,1,...} with axes:
:source, CartesianIndex{2}[CartesianIndex(1, 3), CartesianIndex(2, 3), CartesianIndex(3, 3), CartesianIndex(4, 3), CartesianIndex(1, 4), CartesianIndex(2, 4), CartesianIndex(3, 4), CartesianIndex(4, 4)]
And data, a 8-element Vector{Float64}:
2.0794415416798357
1.3862943611198906
0.6931471805599453
1.3862943611198906
2.772588722239781
1.3862943611198906
0.0
1.3862943611198906
Metadata
Metadata
Assignees
Labels
No labels