Skip to content

Commit b317daf

Browse files
committed
(#2) Update examples in the network models
1 parent 3e7d394 commit b317daf

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

src/maximumflow.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ julia> result = solve(problem);
8282
8383
julia> result.path
8484
9-element Vector{Connection}:
85-
Connection(1, 2, 3.0, "x12")
86-
Connection(1, 3, 2.0, "x13")
87-
Connection(1, 4, 2.0, "x14")
88-
Connection(2, 5, 3.0, "x25")
89-
Connection(3, 5, 1.0, "x35")
90-
Connection(3, 6, 1.0, "x36")
91-
Connection(4, 6, 2.0, "x46")
92-
Connection(5, 7, 4.0, "x57")
93-
Connection(6, 7, 3.0, "x67")
85+
Connection(1, 2, 3.0)
86+
Connection(1, 3, 2.0)
87+
Connection(1, 4, 2.0)
88+
Connection(2, 5, 3.0)
89+
Connection(3, 5, 1.0)
90+
Connection(3, 6, 1.0)
91+
Connection(4, 6, 2.0)
92+
Connection(5, 7, 4.0)
93+
Connection(6, 7, 3.0)
9494
9595
julia> result.flow
9696
7.0

src/mst.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,22 @@ julia> conns = Connection[
149149
]
150150
151151
4-element Vector{Connection}:
152-
Connection(1, 2, 10, "x12")
153-
Connection(2, 3, 10, "x23")
154-
Connection(3, 4, 10, "x34")
155-
Connection(1, 4, 10, "x14")
152+
Connection(1, 2, 10)
153+
Connection(2, 3, 10)
154+
Connection(3, 4, 10)
155+
Connection(1, 4, 10)
156156
157157
julia> result = solve(MstProblem(conns))
158-
MstResult(Connection[Connection(3, 4, 10, "x34"), Connection(1, 4, 10, "x14"), Connection(2, 3, 10, "x23")], 30.0)
158+
MstResult(Connection[Connection(3, 4, 10), Connection(1, 4, 10), Connection(2, 3, 10)], 30.0)
159159
160160
julia> result.distance
161161
30.0
162162
163163
julia> result.connections
164164
3-element Vector{Connection}:
165-
Connection(3, 4, 10, "x34")
166-
Connection(1, 4, 10, "x14")
167-
Connection(2, 3, 10, "x23")
165+
Connection(3, 4, 10)
166+
Connection(1, 4, 10)
167+
Connection(2, 3, 10)
168168
```
169169
"""
170170
function solve(problem::MstProblem)::MstResult

src/shortestpath.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ julia> solve(ShortestPathProblem(conns));
8282
8383
julia> result.path
8484
3-element Vector{Connection}:
85-
Connection(1, 3, 2, "x13")
86-
Connection(3, 6, 1, "x36")
87-
Connection(6, 7, 5, "x67")
85+
Connection(1, 3, 2)
86+
Connection(3, 6, 1)
87+
Connection(6, 7, 5)
8888
8989
julia> result.cost
9090
8.0
@@ -94,7 +94,7 @@ function solve(problem::ShortestPathProblem)
9494

9595
cns = problem.connections
9696

97-
function leftexpressions(node::Int64, nodes::Vector{Connection}, model)
97+
function inflow(node::Int64, nodes::Vector{Connection}, model)
9898
lst = []
9999
for conn in nodes
100100
if conn.to == node
@@ -111,7 +111,7 @@ function solve(problem::ShortestPathProblem)
111111
return expr
112112
end
113113

114-
function rightexpressions(node::Int64, nodes::Vector{Connection}, model)
114+
function outflow(node::Int64, nodes::Vector{Connection}, model)
115115
lst = []
116116
for conn in nodes
117117
if conn.from == node
@@ -150,8 +150,8 @@ function solve(problem::ShortestPathProblem)
150150

151151
# Constraints
152152
for nextnode in mynodes
153-
leftexpr = leftexpressions(nextnode, cns, model)
154-
rightexpr = rightexpressions(nextnode, cns, model)
153+
leftexpr = inflow(nextnode, cns, model)
154+
rightexpr = outflow(nextnode, cns, model)
155155
if nextnode in [startnode, finishnode]
156156
@constraint(model, leftexpr + rightexpr == 1)
157157
else

0 commit comments

Comments
 (0)