Skip to content

Commit

Permalink
changing adjacency matrix functions to support single input nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
PavanChaggar committed Jan 29, 2022
1 parent 5857cd1 commit 8758fb5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/simpleppl.jl
Expand Up @@ -117,15 +117,25 @@ function adjacency_matrix(inputs)
N = length(inputs)
nodes = keys(inputs)
A = spzeros(Bool, N, N)
for (i, node) in enumerate(nodes)
for (row_n, node) in enumerate(nodes)
v_inputs = inputs[node]
for inp in v_inputs
ind = findfirst(==(inp), nodes)
A[i, ind] = true
end
setinput!(A, row_n, nodes, v_inputs)
end
A
end

function setinput!(A::SparseMatrixCSC{Bool, Int64}, row_n, nodes, v_inputs::Symbol)
ind = findfirst(==(v_inputs), nodes)
A[i, ind] = true
end

function setinput!(A::SparseMatrixCSC{Bool, Int64}, row_n, nodes, v_inputs)
for inp in v_inputs
ind = findfirst(==(inp), nodes)
A[row_n, ind] = true
end
A
end
end

adjacency_matrix(m::Model) = adjacency_matrix(m.ModelState.input)

Expand Down

0 comments on commit 8758fb5

Please sign in to comment.