@@ -41,21 +41,16 @@ function incidence_matrix(
41
41
constraints:: Vector{<:JuMP.ConstraintRef} ,
42
42
variables:: Vector{JuMP.VariableRef} ,
43
43
):: 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)
47
45
A, B, E = graph
48
46
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
-
53
47
row = Vector {Int64} ()
54
48
col = Vector {Int64} ()
55
49
val = Vector {Float64} ()
56
50
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.
57
53
push! (row, i)
58
- # TODO : How did I know that I need to subtract M from j
59
54
push! (col, j - M)
60
55
push! (val, 1.0 )
61
56
end
@@ -69,7 +64,6 @@ function incidence_matrix(
69
64
col = Vector {Int64} ()
70
65
val = Vector {Float64} ()
71
66
M = length (igraph. _con_node_map)
72
- N = length (igraph. _var_node_map)
73
67
for e in Graphs. edges (igraph. _graph)
74
68
i = Graphs. src (e)
75
69
j = Graphs. dst (e)
@@ -78,8 +72,9 @@ function incidence_matrix(
78
72
end
79
73
# Now we know that j is a variable node
80
74
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.
83
78
push! (col, j - M)
84
79
push! (val, 1.0 )
85
80
end
0 commit comments