Skip to content

Commit fccbd6d

Browse files
committed
(#2) Add type documentations for network models
1 parent d6a47a4 commit fccbd6d

File tree

5 files changed

+168
-7
lines changed

5 files changed

+168
-7
lines changed

docs/src/network.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,50 @@
66
OperationsResearchModels.Connection
77
```
88

9+
## ShortestPathProblem
10+
11+
```@docs
12+
OperationsResearchModels.ShortestPathProblem
13+
```
14+
915
## Shortest Path
1016

1117
```@docs
1218
OperationsResearchModels.solve(t::ShortestPathProblem)
1319
```
1420

21+
## ShortestPathResult
22+
23+
```@docs
24+
OperationsResearchModels.ShortestPathResult
25+
```
26+
27+
## Maximum Flow Problem
28+
29+
```@docs
30+
OperationsResearchModels.MaximumFlowProblem
31+
```
32+
33+
1534
## Maximum Flow
1635

1736
```@docs
1837
OperationsResearchModels.solve(t::MaximumFlowProblem)
1938
```
2039

40+
## MaximumFlowResult
41+
42+
```@docs
43+
OperationsResearchModels.MaximumFlowResult
44+
```
45+
46+
## MinimumCostFlowProblem
47+
48+
```@docs
49+
OperationsResearchModels.MinimumCostFlowProblem
50+
```
51+
52+
2153
## Minimum Cost Flow
2254

2355
```@docs
@@ -29,8 +61,28 @@ OperationsResearchModels.solve(t::MinimumCostFlowProblem)
2961
OperationsResearchModels.solve(t::MinimumCostFlowProblem, flow::Float64)
3062
```
3163

64+
65+
## MinimumCostFlowResult
66+
67+
```@docs
68+
OperationsResearchModels.MinimumCostFlowResult
69+
```
70+
71+
72+
## MstProblem
73+
74+
```@docs
75+
OperationsResearchModels.MstProblem
76+
```
77+
3278
## Minimum Spanning Tree
3379

3480
```@docs
3581
OperationsResearchModels.solve(p::MstProblem)
3682
```
83+
84+
## MstResult
85+
86+
```@docs
87+
OperationsResearchModels.MstResult
88+
```

src/maximumflow.jl

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,44 @@ export MaximumFlowProblem, MaximumFlowResult
1010

1111

1212

13-
struct MaximumFlowResult
14-
path::Vector{Connection}
15-
flow::Float64
16-
end
13+
"""
14+
MaximumFlowProblem
15+
16+
# Description
1717
18+
Defines the maximum flow problem.
19+
20+
# Fields
21+
22+
- `connections::Vector{Connection}`: The connections (edges) in the network.
23+
24+
"""
1825
struct MaximumFlowProblem
1926
connections::Vector{Connection}
2027
end
2128

2229

2330

31+
"""
32+
MaximumFlowResult
33+
34+
# Description
35+
36+
A structure to hold the result of the maximum flow problem.
37+
38+
# Fields
39+
40+
- `path::Vector{Connection}`: The connections (edges) in the flow path.
41+
- `flow::Float64`: The total flow through the network.
42+
43+
"""
44+
struct MaximumFlowResult
45+
path::Vector{Connection}
46+
flow::Float64
47+
end
48+
49+
50+
2451

2552

2653

src/minimumcostflow.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,41 @@ import ..MaximumFlow: MaximumFlowProblem, MaximumFlowResult
88

99
export MinimumCostFlowProblem, MinimumCostFlowResult
1010

11+
12+
13+
"""
14+
MinimumCostFlowProblem
15+
16+
# Description
17+
18+
Defines the minimum cost flow problem.
19+
20+
# Fields
21+
22+
- `connections::Vector{Connection}`: The connections (edges) in the network.
23+
- `costs::Vector{Connection}`: The costs associated with each connection.
24+
25+
"""
1126
struct MinimumCostFlowProblem
1227
connections::Vector{Connection}
1328
costs::Vector{Connection}
1429
end
1530

31+
32+
33+
"""
34+
MinimumCostFlowResult
35+
36+
# Description
37+
38+
A structure to hold the result of the minimum cost flow problem.
39+
40+
# Fields
41+
42+
- `path::Vector{Connection}`: The connections (edges) in the flow path.
43+
- `cost::Float64`: The total cost of the flow.
44+
45+
"""
1646
struct MinimumCostFlowResult
1747
path::Vector{Connection}
1848
cost::Float64

src/mst.jl

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,42 @@ export mst
99
export MstResult
1010
export MstProblem
1111

12-
struct MstResult
12+
13+
"""
14+
MstProblem
15+
16+
# Description
17+
Defines the minimum spanning tree problem.
18+
19+
# Fields
20+
- `connections::Vector{Connection}`: The connections (edges) in the network.
21+
22+
# Note
23+
The Connection object defined a directed edge, but for the minimum spanning tree problem, the edges are considered undirected.
24+
"""
25+
struct MstProblem
1326
connections::Vector{Connection}
14-
distance::Float64
1527
end
1628

17-
struct MstProblem
29+
30+
"""
31+
MstResult
32+
33+
# Description
34+
A structure to hold the result of the minimum spanning tree problem.
35+
36+
# Fields
37+
- `connections::Vector{Connection}`: The connections (edges) in the minimum spanning tree.
38+
- `distance::Float64`: The total distance (weight) of the minimum spanning tree.
39+
40+
"""
41+
struct MstResult
1842
connections::Vector{Connection}
43+
distance::Float64
1944
end
2045

2146

47+
2248
function hasloop(conns::Vector{Connection})::Bool
2349
if length(conns) <= 1
2450
return false

src/shortestpath.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,36 @@ export ShortestPathProblem
1111
export ShortestPathResult
1212

1313

14+
"""
15+
ShortestPathProblem
16+
17+
# Description
18+
19+
Defines the shortest path problem.
20+
21+
# Fields
22+
23+
- `connections::Vector{Connection}`: The connections (edges) in the network.
24+
25+
"""
1426
struct ShortestPathProblem
1527
connections::Vector{Connection}
1628
end
1729

30+
31+
"""
32+
ShortestPathResult
33+
34+
# Description
35+
36+
A structure to hold the result of the shortest path problem.
37+
38+
# Fields
39+
40+
- `path::Vector{Connection}`: The connections (edges) in the shortest path.
41+
- `cost::Float64`: The total cost of the shortest path.
42+
43+
"""
1844
struct ShortestPathResult
1945
path::Vector{Connection}
2046
cost::Float64

0 commit comments

Comments
 (0)