Skip to content

Commit 1198d8e

Browse files
committed
add notes on where we exploit graph convention and remove unused code
1 parent d067071 commit 1198d8e

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/incidence_matrix.jl

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,16 @@ function incidence_matrix(
4141
constraints::Vector{<:JuMP.ConstraintRef},
4242
variables::Vector{JuMP.VariableRef},
4343
)::SparseArrays.SparseMatrixCSC
44-
graph, con_node_map, var_node_map = get_bipartite_incidence_graph(
45-
constraints, variables
46-
)
44+
graph, _, _ = get_bipartite_incidence_graph(constraints, variables)
4745
A, B, E = graph
4846
M = length(constraints)
49-
N = length(variables)
50-
con_row_map = Dict(zip(constraints, 1:M))
51-
var_col_map = Dict(zip(variables, 1:N))
52-
5347
row = Vector{Int64}()
5448
col = Vector{Int64}()
5549
val = Vector{Float64}()
5650
for (i, j) in E
51+
# NOTE: Here we exploit the graph's convention. This will need to
52+
# change if we change how the graph is constructed.
5753
push!(row, i)
58-
# TODO: How did I know that I need to subtract M from j
5954
push!(col, j - M)
6055
push!(val, 1.0)
6156
end
@@ -69,7 +64,6 @@ function incidence_matrix(
6964
col = Vector{Int64}()
7065
val = Vector{Float64}()
7166
M = length(igraph._con_node_map)
72-
N = length(igraph._var_node_map)
7367
for e in Graphs.edges(igraph._graph)
7468
i = Graphs.src(e)
7569
j = Graphs.dst(e)
@@ -78,8 +72,9 @@ function incidence_matrix(
7872
end
7973
# Now we know that j is a variable node
8074
push!(row, i)
81-
# TODO: How do we know that we subtract M from
82-
# variable nodes?
75+
# NOTE: Here we exploit the graph's convention. This will need to
76+
# change if we change how the graph is constructed, e.g. we add
77+
# a node for the objective.
8378
push!(col, j - M)
8479
push!(val, 1.0)
8580
end

0 commit comments

Comments
 (0)