chore: full README and refactor

This commit is contained in:
Aouab 2026-01-15 03:47:36 +01:00
parent 2c26d061d7
commit 64caac7803
18 changed files with 930 additions and 116 deletions

3
.gitignore vendored
View file

@ -3,3 +3,6 @@ ford/
outfile
*~
*.exe
.vscode/
result/

View file

@ -5,7 +5,7 @@
},
"editor.formatOnSave": true,
"ocaml.sandbox": {
"kind": "custom",
"template": "$prog $args"
"kind": "opam",
"switch": "ocaml-base-compiler"
}
}

View file

@ -1,14 +1,10 @@
.PHONY: all build format edit demo clean
src?=0
dst?=5
graph?=graph1.txt
all: build
build:
@echo "\n 🚨 COMPILING 🚨 \n"
dune build src/ftest.exe
dune build src/maxflow.exe
ls src/*.exe > /dev/null && ln -fs src/*.exe .
format:
@ -17,10 +13,18 @@ format:
edit:
code . -n
demo: build
@echo "\n ⚡ EXECUTING ⚡\n"
./ftest.exe graphs/${graph} $(src) $(dst) outfile
@echo "\n 🥁 RESULT (content of outfile) 🥁\n"
demo-flow: build
mkdir -p result
@echo "\n Running Ford-Fulkerson demo \n"
./maxflow.exe flow graphs/graph7.txt 1 9 result/result-flowdemo result/result-flowdemo-svg
@echo "\n Result stored in result/\n"
@cat outfile
demo-scheduling: build
mkdir -p result
@echo "\n Running Airplane Scheduling demo \n"
./maxflow.exe scheduling scheduling/schedule3.txt 9 result/result-schdemo result/result-schdemo-svg
@echo "\n Result stored in result/\n"
@cat outfile
clean:

226
README.md
View file

@ -1,22 +1,218 @@
Base project for Ocaml project on Ford-Fulkerson. This project contains some simple configuration files to facilitate editing Ocaml in VSCode.
# Maxflow Problem & Airline Scheduling
To use, you should install the *OCaml Platform* extension in VSCode.
Then open VSCode in the root directory of this repository (command line: `code path/to/ocaml-maxflow-project`).
This project implements:
Features :
- full compilation as VSCode build task (Ctrl+Shift+b)
- highlights of compilation errors as you type
- code completion
- view of variable types
- A maximum flow solver using the **Ford–Fulkerson algorithm**.
- An **airline scheduling solver** using a variation of a bounded circulation graph (flow with lower bounds).
It can be used to:
- Solve generic max-flow problems from graph files.
- Compute feasible airline schedules using at most `k` airplanes or crew members.
A [`Makefile`](Makefile) provides some useful commands:
![example schedule](./img/example_schedule.svg)
- `make build` to compile. This creates an `ftest.exe` executable
- `make demo` to run the `ftest` program with some arguments
- `make format` to indent the entire project
- `make edit` to open the project in VSCode
- `make clean` to remove build artifacts
<center>
In case of trouble with the VSCode extension (e.g. the project does not build, there are strange mistakes), a common workaround is to (1) close vscode, (2) `make clean`, (3) `make build` and (4) reopen vscode (`make edit`).
*Example scheduling of 15 airplanes across 26 flights*
</center>
## Dependencies
- OCaml ≥ 4.13
- dune
- graphviz (optional, for SVG export)
## Run
Build the project
```
dune build / make build
```
The executable supports two modes:
- `flow`
- `scheduling`
### Flow problem
```bash
./maxflow flow infile source sink outfile [svgfile]
```
Graph files are located in the `graphs/` folder.
#### Example
```bash
./maxflow flow graphs/graph3.txt 0 5 result
```
With SVG export:
```bash
./maxflow flow graphs/graph3.txt 0 5 result result_svg
```
This generates:
- `result.dot`
- optionally `result_svg.svg`
### Airline scheduling
Example schedules are located in the `scheduling/` folder.
```bash
./maxflow scheduling infile airplane_count outfile [svgfile]
```
#### Example
```bash
./maxflow scheduling scheduling/schedule1.txt 10 output
```
This generates:
- `output.schedule` (text schedule)
- `output.dot` (graph visualization)
- optionally `output.svg`
## How the project works
### Maximum flow
The project implements the **Ford–Fulkerson algorithm**, which calculates the maximum flow in an oriented graph.
Consider the following example:
![graph](./img/flow_graph_empty.png)
Each edge has an initial flow value (mostly 0) and a maximum flow capacity, the **Ford–Fulkerson algorithm** computes the maximum flow that can be passed between two nodes (namely source and sink), in our case if we choose 0 as the source, and 5 as the sink:
![graph](./img/flow_graph_computed.png)
The maximum flow we can pass is 25.
The algorithm works by converting the flow graph into a residual flow graph, and finding augmenting paths exhaustively. The graph is valid as long as, for each node, the sum of incoming flow is equal to the sum of outgoing flow:
<center>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bwhite%7D%5Csum_%7Bu%20%5Cin%20V%7D%20f(u,v)%20%3D%20%5Csum_%7Bw%20%5Cin%20V%7D%20f(v,w)">
<source media="(prefers-color-scheme: light)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7D%5Csum_%7Bu%20%5Cin%20V%7D%20f(u,v)%20%3D%20%5Csum_%7Bw%20%5Cin%20V%7D%20f(v,w)">
<img alt="Flow conservation equation" src="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7D%5Csum_%7Bu%20%5Cin%20V%7D%20f(u,v)%20%3D%20%5Csum_%7Bw%20%5Cin%20V%7D%20f(v,w)">
</picture>
</center>
Except for the sink and the source (net outflow, net inflow)
If you want to know more about how the **Ford–Fulkerson algorithm** works, [this website](https://algorithms.discrete.ma.tum.de/graph-algorithms/flow-ford-fulkerson/index_en.html) helped me a lot understand it.
## Airline scheduling model
Given a limited amount of airplanes (or crews), we want to assign a list of flights to each airplane following these criteria:
- Each flight requires one airplane (duh).
- Each flight is performed exactly once.
- A plane can only continue to another flight if it arrives early enough and at the same airport.
This is modeled as a **bounded circulation problem** (flow with lower bounds).
### Bounded circulation model
A bounded ciculation model is the generalization of network flow problems, with the added constraint of a lower bounds on edge flows, i.e instead of a simple flow graph with only capacity, each edge `e` has:
- lower bound `l(e)`
- capacity `u(e)`
- flow `f(e)` such that:
<center>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B180%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bwhite%7Dl(e)%20%5Cle%20f(e)%20%5Cle%20c(e)">
<source media="(prefers-color-scheme: light)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B180%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7Dl(e)%20%5Cle%20f(e)%20%5Cle%20c(e)">
<img alt="Lower bound ≤ flow ≤ capacity" src="https://latex.codecogs.com/svg.latex?%5Cdpi%7B180%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7Dl(e)%20%5Cle%20f(e)%20%5Cle%20c(e)">
</picture>
</center>
Each vertex `v` is also defined with a demand, that represents how much flow that node requires, the formula for the demand of a vertex is defined as the difference between incoming and outgoing lower bounds:
<center>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bwhite%7Dd(v)%20%3D%20%5Csum_%7B(v,w)%20%5Cin%20E%7D%20l_%7Bvw%7D%20-%20%5Csum_%7B(u,v)%20%5Cin%20E%7D%20l_%7Buv%7D">
<source media="(prefers-color-scheme: light)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7Dd(v)%20%3D%20%5Csum_%7B(v,w)%20%5Cin%20E%7D%20l_%7Bvw%7D%20-%20%5Csum_%7B(u,v)%20%5Cin%20E%7D%20l_%7Buv%7D">
<img alt="Demand definition" src="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7Dd(v)%20%3D%20%5Csum_%7B(v,w)%20%5Cin%20E%7D%20l_%7Bvw%7D%20-%20%5Csum_%7B(u,v)%20%5Cin%20E%7D%20l_%7Buv%7D">
</picture>
</center>
(this is widely used in problems like the Circulation-Demand problem, where some factories produce goods and some villages that each have a demand rate)
### Use with Ford-Fulkerson
The Ford-Fulkerson cannot be applied directly to a bounded circulation graph, as it cannot handle lower bounds, as such, the circulation graph will need to be converted to an equivalent maxflow problem, to do so, lower bounds need to be eliminated, and that is done by subtracting the lower bound of each edge from its flow, and updating the demands accordingly.
After updating the flows and demands, two additional nodes need to be added, a super source `(SS)` and a super sink `(TT)`, their relationship with the rest of the vertices is defined like so:
<center>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bwhite%7D%5Ctext%7Bfor%20each%20vertex%20%7Dv%3A%20%5Cbegin%7Bcases%7D%20SS%20%5Clongrightarrow%20v%2C%20%26%20f(SS%2C%20v)%20%3D%20-d(v)%20%5Cquad%20%5Ctext%7Bif%20%7D%20d(v)%20%3C%200%20%5C%5C%5B2mm%5D%20v%20%5Clongrightarrow%20TT%2C%20%26%20f(v%2C%20TT)%20%3D%20d(v)%20%5Cquad%20%5Ctext%7Bif%20%7D%20d(v)%20%3E%200%20%5Cend%7Bcases%7D">
<source media="(prefers-color-scheme: light)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7D%5Ctext%7Bfor%20each%20vertex%20%7Dv%3A%20%5Cbegin%7Bcases%7D%20SS%20%5Clongrightarrow%20v%2C%20%26%20f(SS%2C%20v)%20%3D%20-d(v)%20%5Cquad%20%5Ctext%7Bif%20%7D%20d(v)%20%3C%200%20%5C%5C%5B2mm%5D%20v%20%5Clongrightarrow%20TT%2C%20%26%20f(v%2C%20TT)%20%3D%20d(v)%20%5Cquad%20%5Ctext%7Bif%20%7D%20d(v)%20%3E%200%20%5Cend%7Bcases%7D">
<img alt="Super source and super sink connections" src="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7D%5Ctext%7Bfor%20each%20vertex%20%7Dv%3A%20%5Cbegin%7Bcases%7D%20SS%20%5Clongrightarrow%20v%2C%20%26%20f(SS%2C%20v)%20%3D%20-d(v)%20%5Cquad%20%5Ctext%7Bif%20%7D%20d(v)%20%3C%200%20%5C%5C%5B2mm%5D%20v%20%5Clongrightarrow%20TT%2C%20%26%20f(v%2C%20TT)%20%3D%20d(v)%20%5Cquad%20%5Ctext%7Bif%20%7D%20d(v)%20%3E%200%20%5Cend%7Bcases%7D">
</picture>
</center>
Computing the Ford-Fulkerson algorithm such that all net outflow coming from SS is equal to the sum of the positive demands of the graph:
<center>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bwhite%7D%5Csum_%7B(SS,v)%5Cin%20E%7D%20f(SS,v)%20%3D%20%5Csum_%7Bd(v)%20%3E%200%7D%20d(v)">
<source media="(prefers-color-scheme: light)" srcset="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7D%5Csum_%7B(SS,v)%5Cin%20E%7D%20f(SS,v)%20%3D%20%5Csum_%7Bd(v)%20%3E%200%7D%20d(v)">
<img alt="Total flow from super source" src="https://latex.codecogs.com/svg.latex?%5Cdpi%7B150%7D%5Cbg%7Btransparent%7D%5Ccolor%7Bblack%7D%5Csum_%7B(SS,v)%5Cin%20E%7D%20f(SS,v)%20%3D%20%5Csum_%7Bd(v)%20%3E%200%7D%20d(v)">
</picture>
</center>
results in all the demands being satisfied, and in the case of the equivalent Circulation problem, all demands and lower bounds are satisfied.
### Modelisation of the Airline Scheduling Problem
Given an airplane count `C`, the Airline Scheduling Problem circulation graph is defined like so:
<center>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="./img/airline_scheduling_dark_mode.png">
<source media="(prefers-color-scheme: light)" srcset="./img/airline_scheduling_light_mode.png">
<img alt="formula" src="./img/airline_scheduling_light_mode.png">
</picture>
</center>
Two flights are compatible if the second is spaced out enough that it can be joined by the same airplane after the first has landed, in this project, I have made the arbitrary choice to make that condition be:
- Flight 1's destination airport is the same as Flight 2
- Flight 1's arrival time is at least 30 minutes before Flight 2
That being said, this condition can be further developer to allow airplanes to join neighboring airports for example.
As explained above, after converting this circulation graph to its maxflow equivalent and adding the super source and super sink, if computing the maximum flow satisfies the condition `sum of outgoing flow from SS = total demand`, the demands of the circulation graph are satisfied.
Therefore, [it is claimed and proved](https://en.wikipedia.org/wiki/Maximum_flow_problem#cite_note-ITA-43) that finding a flow value of `C` between `s` and `t` is equal to finding a feasible schedule for the given flight set with at most `C` airplanes.
#### Finding the minimum needed airplanes
Since the outgoing flow of `s` is the number of airplanes, one might conclude that it is enough to run the algorithm with a high enough `C` value. However, since the algorithm is greedy, or rather generous, it will instead use airplanes at its disposition before connecting the same airplane between two flights.
As an example, you can try running the algorithm on the provided `schedule3.txt` (in the `scheduling` folder), which has a lot of connectable flights, with a value like `20`, then run it again with a value `10`, you will notice that the algorithm now schedules one airplane for multiple flights, which it did not choose to do beforehand.
## Resources
These are the resources I have researched and used for the purpose understanding this project
- https://en.wikipedia.org/wiki/Maximum_flow_problem
- https://www.youtube.com/watch?v=HyFsVuae9-w
- https://ocw.tudelft.nl/wp-content/uploads/Algoritmiek_Extensions_to_Max_Flow_-_circulations_01.pdf

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
img/demand_formula.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

530
img/example_schedule.svg Normal file
View file

@ -0,0 +1,530 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1796pt" height="503pt" viewBox="0.00 0.00 1796.00 503.00">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 499.32)">
<title>airline_schedule</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-499.32 1792.37,-499.32 1792.37,4 -4,4"/>
<!-- HND -->
<g id="node1" class="node">
<title>HND</title>
<polygon fill="none" stroke="black" points="133.29,-46.33 86.96,-46.33 86.96,0 133.29,0 133.29,-46.33"/>
<text xml:space="preserve" text-anchor="middle" x="110.12" y="-18.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">HND</text>
</g>
<!-- NRT -->
<g id="node2" class="node">
<title>NRT</title>
<polygon fill="none" stroke="black" points="295.33,-45.17 251.33,-45.17 251.33,-1.17 295.33,-1.17 295.33,-45.17"/>
<text xml:space="preserve" text-anchor="middle" x="273.33" y="-18.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">NRT</text>
</g>
<!-- HND&#45;&gt;NRT -->
<g id="edge1" class="edge">
<title>HND-&gt;NRT</title>
<path fill="none" stroke="black" d="M133.54,-23.17C161.08,-23.17 208.02,-23.17 239.6,-23.17"/>
<polygon fill="black" stroke="black" points="239.36,-26.67 249.36,-23.17 239.36,-19.67 239.36,-26.67"/>
<text xml:space="preserve" text-anchor="middle" x="191.14" y="-27.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a1 (JL6001)</text>
</g>
<!-- ICN -->
<g id="node3" class="node">
<title>ICN</title>
<polygon fill="none" stroke="black" points="472.5,-43.22 432.39,-43.22 432.39,-3.11 472.5,-3.11 472.5,-43.22"/>
<text xml:space="preserve" text-anchor="middle" x="452.44" y="-18.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">ICN</text>
</g>
<!-- NRT&#45;&gt;ICN -->
<g id="edge2" class="edge">
<title>NRT-&gt;ICN</title>
<path fill="none" stroke="black" d="M295.69,-23.17C326.85,-23.17 384.95,-23.17 420.7,-23.17"/>
<polygon fill="black" stroke="black" points="420.39,-26.67 430.39,-23.17 420.39,-19.67 420.39,-26.67"/>
<text xml:space="preserve" text-anchor="middle" x="355.51" y="-27.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a1 (KE6002)</text>
</g>
<!-- PEK -->
<g id="node4" class="node">
<title>PEK</title>
<polygon fill="none" stroke="black" points="654.98,-44.39 612.54,-44.39 612.54,-1.94 654.98,-1.94 654.98,-44.39"/>
<text xml:space="preserve" text-anchor="middle" x="633.76" y="-18.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">PEK</text>
</g>
<!-- ICN&#45;&gt;PEK -->
<g id="edge3" class="edge">
<title>ICN-&gt;PEK</title>
<path fill="none" stroke="black" d="M472.97,-23.17C503.77,-23.17 563.92,-23.17 600.99,-23.17"/>
<polygon fill="black" stroke="black" points="600.64,-26.67 610.64,-23.17 600.64,-19.67 600.64,-26.67"/>
<text xml:space="preserve" text-anchor="middle" x="550.15" y="-27.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a1 (CA6003)</text>
</g>
<!-- DEN -->
<g id="node5" class="node">
<title>DEN</title>
<polygon fill="none" stroke="black" points="1144.59,-407.55 1099.81,-407.55 1099.81,-362.78 1144.59,-362.78 1144.59,-407.55"/>
<text xml:space="preserve" text-anchor="middle" x="1122.2" y="-380.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">DEN</text>
</g>
<!-- LAX -->
<g id="node6" class="node">
<title>LAX</title>
<polygon fill="none" stroke="black" points="1308.05,-455.55 1263.27,-455.55 1263.27,-410.78 1308.05,-410.78 1308.05,-455.55"/>
<text xml:space="preserve" text-anchor="middle" x="1285.66" y="-428.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">LAX</text>
</g>
<!-- DEN&#45;&gt;LAX -->
<g id="edge4" class="edge">
<title>DEN-&gt;LAX</title>
<path fill="none" stroke="black" d="M1144.97,-390.1C1169.49,-395.84 1210.43,-406.01 1244.88,-417.37 1247.29,-418.16 1249.76,-419.02 1252.24,-419.92"/>
<polygon fill="black" stroke="black" points="1250.94,-423.17 1261.53,-423.46 1253.43,-416.63 1250.94,-423.17"/>
<text xml:space="preserve" text-anchor="middle" x="1205.03" y="-421.57" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a2 (UA5003)</text>
</g>
<!-- SFO -->
<g id="node22" class="node">
<title>SFO</title>
<polygon fill="none" stroke="black" points="1467.38,-454.01 1425.7,-454.01 1425.7,-412.32 1467.38,-412.32 1467.38,-454.01"/>
<text xml:space="preserve" text-anchor="middle" x="1446.54" y="-428.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">SFO</text>
</g>
<!-- LAX&#45;&gt;SFO -->
<g id="edge17" class="edge">
<title>LAX-&gt;SFO</title>
<path fill="none" stroke="black" d="M1308.42,-433.17C1335.85,-433.17 1383.19,-433.17 1414.43,-433.17"/>
<polygon fill="black" stroke="black" points="1414.03,-436.67 1424.03,-433.17 1414.03,-429.67 1414.03,-436.67"/>
<text xml:space="preserve" text-anchor="middle" x="1367.07" y="-437.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a10 (UA4001)</text>
</g>
<!-- ORD -->
<g id="node7" class="node">
<title>ORD</title>
<polygon fill="none" stroke="black" points="979.32,-445.94 933.76,-445.94 933.76,-400.39 979.32,-400.39 979.32,-445.94"/>
<text xml:space="preserve" text-anchor="middle" x="956.54" y="-418.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">ORD</text>
</g>
<!-- ORD&#45;&gt;DEN -->
<g id="edge5" class="edge">
<title>ORD-&gt;DEN</title>
<path fill="none" stroke="black" d="M979.61,-418.04C1007.59,-411.55 1056.05,-400.29 1088.37,-392.79"/>
<polygon fill="black" stroke="black" points="1089.06,-396.22 1098,-390.55 1087.47,-389.4 1089.06,-396.22"/>
<text xml:space="preserve" text-anchor="middle" x="1039.37" y="-417.17" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a3 (UA5002)</text>
</g>
<!-- ATL -->
<g id="node8" class="node">
<title>ATL</title>
<polygon fill="none" stroke="black" points="814.03,-481.77 770.81,-481.77 770.81,-438.56 814.03,-438.56 814.03,-481.77"/>
<text xml:space="preserve" text-anchor="middle" x="792.42" y="-455.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">ATL</text>
</g>
<!-- ATL&#45;&gt;ORD -->
<g id="edge6" class="edge">
<title>ATL-&gt;ORD</title>
<path fill="none" stroke="black" d="M814.28,-455.4C841.63,-449.16 889.91,-438.14 922.31,-430.75"/>
<polygon fill="black" stroke="black" points="923.02,-434.18 931.99,-428.54 921.46,-427.35 923.02,-434.18"/>
<text xml:space="preserve" text-anchor="middle" x="874.48" y="-454.44" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a4 (DL3003)</text>
</g>
<!-- MIA -->
<g id="node9" class="node">
<title>MIA</title>
<polygon fill="none" stroke="black" points="655.37,-436.78 612.15,-436.78 612.15,-393.56 655.37,-393.56 655.37,-436.78"/>
<text xml:space="preserve" text-anchor="middle" x="633.76" y="-410.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">MIA</text>
</g>
<!-- MIA&#45;&gt;ATL -->
<g id="edge7" class="edge">
<title>MIA-&gt;ATL</title>
<path fill="none" stroke="black" d="M655.72,-419.4C678.9,-424.29 717.23,-433.02 749.44,-443.37 752.95,-444.49 756.59,-445.77 760.19,-447.11"/>
<polygon fill="black" stroke="black" points="758.7,-450.29 769.29,-450.66 761.25,-443.77 758.7,-450.29"/>
<text xml:space="preserve" text-anchor="middle" x="713.09" y="-447.57" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a5 (DL3002)</text>
</g>
<!-- DXB -->
<g id="node10" class="node">
<title>DXB</title>
<polygon fill="none" stroke="black" points="1308.44,-245.94 1262.88,-245.94 1262.88,-200.39 1308.44,-200.39 1308.44,-245.94"/>
<text xml:space="preserve" text-anchor="middle" x="1285.66" y="-218.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">DXB</text>
</g>
<!-- SIN -->
<g id="node11" class="node">
<title>SIN</title>
<polygon fill="none" stroke="black" points="1465.82,-242.44 1427.26,-242.44 1427.26,-203.89 1465.82,-203.89 1465.82,-242.44"/>
<text xml:space="preserve" text-anchor="middle" x="1446.54" y="-218.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">SIN</text>
</g>
<!-- DXB&#45;&gt;SIN -->
<g id="edge8" class="edge">
<title>DXB-&gt;SIN</title>
<path fill="none" stroke="black" d="M1308.75,-223.17C1336.6,-223.17 1384.59,-223.17 1415.69,-223.17"/>
<polygon fill="black" stroke="black" points="1415.58,-226.67 1425.58,-223.17 1415.58,-219.67 1415.58,-226.67"/>
<text xml:space="preserve" text-anchor="middle" x="1367.07" y="-227.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a6 (SQ9001)</text>
</g>
<!-- SYD -->
<g id="node12" class="node">
<title>SYD</title>
<polygon fill="none" stroke="black" points="1626.32,-245.17 1582.32,-245.17 1582.32,-201.16 1626.32,-201.16 1626.32,-245.17"/>
<text xml:space="preserve" text-anchor="middle" x="1604.32" y="-218.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">SYD</text>
</g>
<!-- SIN&#45;&gt;SYD -->
<g id="edge9" class="edge">
<title>SIN-&gt;SYD</title>
<path fill="none" stroke="black" d="M1466.02,-223.17C1491.75,-223.17 1538.77,-223.17 1570.52,-223.17"/>
<polygon fill="black" stroke="black" points="1570.36,-226.67 1580.36,-223.17 1570.36,-219.67 1570.36,-226.67"/>
<text xml:space="preserve" text-anchor="middle" x="1524.85" y="-227.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a6 (SQ9002)</text>
</g>
<!-- FRA -->
<g id="node13" class="node">
<title>FRA</title>
<polygon fill="none" stroke="black" points="294.94,-348.78 251.71,-348.78 251.71,-305.55 294.94,-305.55 294.94,-348.78"/>
<text xml:space="preserve" text-anchor="middle" x="273.33" y="-322.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">FRA</text>
</g>
<!-- CDG -->
<g id="node14" class="node">
<title>CDG</title>
<polygon fill="none" stroke="black" points="475.22,-346.94 429.66,-346.94 429.66,-301.39 475.22,-301.39 475.22,-346.94"/>
<text xml:space="preserve" text-anchor="middle" x="452.44" y="-319.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">CDG</text>
</g>
<!-- FRA&#45;&gt;CDG -->
<g id="edge10" class="edge">
<title>FRA-&gt;CDG</title>
<path fill="none" stroke="black" d="M295.34,-326.81C325.63,-326.3 381.9,-325.34 417.96,-324.73"/>
<polygon fill="black" stroke="black" points="417.89,-328.23 427.83,-324.57 417.77,-321.24 417.89,-328.23"/>
<text xml:space="preserve" text-anchor="middle" x="355.51" y="-330.64" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a7 (AF8001)</text>
</g>
<!-- JFK -->
<g id="node27" class="node">
<title>JFK</title>
<polygon fill="none" stroke="black" points="472.11,-403.84 432.77,-403.84 432.77,-364.49 472.11,-364.49 472.11,-403.84"/>
<text xml:space="preserve" text-anchor="middle" x="452.44" y="-379.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">JFK</text>
</g>
<!-- FRA&#45;&gt;JFK -->
<g id="edge24" class="edge">
<title>FRA-&gt;JFK</title>
<path fill="none" stroke="black" d="M295.03,-338.11C301.52,-341.29 308.79,-344.59 315.66,-347.17 351.3,-360.51 393.83,-371.31 421.68,-377.73"/>
<polygon fill="black" stroke="black" points="420.65,-381.08 431.17,-379.87 422.19,-374.25 420.65,-381.08"/>
<text xml:space="preserve" text-anchor="middle" x="355.51" y="-374.76" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a14 (LH4001)</text>
</g>
<!-- ROM -->
<g id="node15" class="node">
<title>ROM</title>
<polygon fill="none" stroke="black" points="657.71,-348.11 609.81,-348.11 609.81,-300.22 657.71,-300.22 657.71,-348.11"/>
<text xml:space="preserve" text-anchor="middle" x="633.76" y="-319.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">ROM</text>
</g>
<!-- CDG&#45;&gt;ROM -->
<g id="edge11" class="edge">
<title>CDG-&gt;ROM</title>
<path fill="none" stroke="black" d="M475.43,-324.17C506.01,-324.17 561.72,-324.17 597.97,-324.17"/>
<polygon fill="black" stroke="black" points="597.94,-327.67 607.94,-324.17 597.94,-320.67 597.94,-327.67"/>
<text xml:space="preserve" text-anchor="middle" x="550.15" y="-328.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a7 (AF8002)</text>
</g>
<!-- ATH -->
<g id="node16" class="node">
<title>ATH</title>
<polygon fill="none" stroke="black" points="814.81,-346.55 770.03,-346.55 770.03,-301.78 814.81,-301.78 814.81,-346.55"/>
<text xml:space="preserve" text-anchor="middle" x="792.42" y="-319.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">ATH</text>
</g>
<!-- ROM&#45;&gt;ATH -->
<g id="edge12" class="edge">
<title>ROM-&gt;ATH</title>
<path fill="none" stroke="black" d="M657.88,-324.17C684.47,-324.17 728.36,-324.17 758.51,-324.17"/>
<polygon fill="black" stroke="black" points="758.21,-327.67 768.21,-324.17 758.21,-320.67 758.21,-327.67"/>
<text xml:space="preserve" text-anchor="middle" x="713.09" y="-328.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a7 (AZ8003)</text>
</g>
<!-- MAD -->
<g id="node17" class="node">
<title>MAD</title>
<polygon fill="none" stroke="black" points="297.66,-179.5 248.99,-179.5 248.99,-130.83 297.66,-130.83 297.66,-179.5"/>
<text xml:space="preserve" text-anchor="middle" x="273.33" y="-150.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">MAD</text>
</g>
<!-- BCN -->
<g id="node18" class="node">
<title>BCN</title>
<polygon fill="none" stroke="black" points="474.83,-116.56 430.05,-116.56 430.05,-71.77 474.83,-71.77 474.83,-116.56"/>
<text xml:space="preserve" text-anchor="middle" x="452.44" y="-89.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">BCN</text>
</g>
<!-- MAD&#45;&gt;BCN -->
<g id="edge13" class="edge">
<title>MAD-&gt;BCN</title>
<path fill="none" stroke="black" d="M297.84,-147.07C329.01,-136.33 384.11,-117.35 419.15,-105.29"/>
<polygon fill="black" stroke="black" points="420.02,-108.69 428.34,-102.12 417.74,-102.07 420.02,-108.69"/>
<text xml:space="preserve" text-anchor="middle" x="355.51" y="-144.62" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a8 (IB7002)</text>
</g>
<!-- LIS -->
<g id="node19" class="node">
<title>LIS</title>
<polygon fill="none" stroke="black" points="652.26,-99.67 615.26,-99.67 615.26,-62.67 652.26,-62.67 652.26,-99.67"/>
<text xml:space="preserve" text-anchor="middle" x="633.76" y="-76.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">LIS</text>
</g>
<!-- BCN&#45;&gt;LIS -->
<g id="edge14" class="edge">
<title>BCN-&gt;LIS</title>
<path fill="none" stroke="black" d="M475.07,-92.6C507.21,-90.27 567.63,-85.89 603.63,-83.28"/>
<polygon fill="black" stroke="black" points="603.6,-86.79 613.32,-82.57 603.09,-79.81 603.6,-86.79"/>
<text xml:space="preserve" text-anchor="middle" x="550.15" y="-94.16" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a8 (TP7003)</text>
</g>
<!-- RAK -->
<g id="node20" class="node">
<title>RAK</title>
<polygon fill="none" stroke="black" points="815.2,-191.94 769.64,-191.94 769.64,-146.39 815.2,-146.39 815.2,-191.94"/>
<text xml:space="preserve" text-anchor="middle" x="792.42" y="-164.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">RAK</text>
</g>
<!-- LIS&#45;&gt;RAK -->
<g id="edge15" class="edge">
<title>LIS-&gt;RAK</title>
<path fill="none" stroke="black" d="M652.48,-86.14C675.92,-93.23 717.94,-107.69 749.44,-128.37 753.98,-131.35 758.45,-134.86 762.69,-138.55"/>
<polygon fill="black" stroke="black" points="760.19,-141 769.89,-145.25 764.95,-135.88 760.19,-141"/>
<text xml:space="preserve" text-anchor="middle" x="713.09" y="-132.57" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a8 (TP7004)</text>
</g>
<!-- TLS -->
<g id="node21" class="node">
<title>TLS</title>
<polygon fill="none" stroke="black" points="130.57,-283.61 89.68,-283.61 89.68,-242.72 130.57,-242.72 130.57,-283.61"/>
<text xml:space="preserve" text-anchor="middle" x="110.12" y="-258.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">TLS</text>
</g>
<!-- RAK&#45;&gt;TLS -->
<g id="edge26" class="edge">
<title>RAK-&gt;TLS</title>
<path fill="none" stroke="black" d="M770,-192.4C741.89,-220.24 689.63,-263.17 634.76,-263.17 272.33,-263.17 272.33,-263.17 272.33,-263.17 227.16,-263.17 174.88,-263.17 142.4,-263.17"/>
<polygon fill="black" stroke="black" points="142.49,-259.67 132.49,-263.17 142.49,-266.67 142.49,-259.67"/>
<text xml:space="preserve" text-anchor="middle" x="452.44" y="-267.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a15 (FR1001)</text>
</g>
<!-- SOF -->
<g id="node26" class="node">
<title>SOF</title>
<polygon fill="none" stroke="black" points="977.38,-232.01 935.7,-232.01 935.7,-190.32 977.38,-190.32 977.38,-232.01"/>
<text xml:space="preserve" text-anchor="middle" x="956.54" y="-206.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">SOF</text>
</g>
<!-- RAK&#45;&gt;SOF -->
<g id="edge22" class="edge">
<title>RAK-&gt;SOF</title>
<path fill="none" stroke="black" d="M815.32,-173.33C839.55,-178.11 879.66,-186.59 913.56,-196.37 917.31,-197.45 921.22,-198.68 925.07,-199.96"/>
<polygon fill="black" stroke="black" points="923.6,-203.15 934.19,-203.11 925.89,-196.54 923.6,-203.15"/>
<text xml:space="preserve" text-anchor="middle" x="874.48" y="-200.57" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a13 (FR1002)</text>
</g>
<!-- TLS&#45;&gt;FRA -->
<g id="edge23" class="edge">
<title>TLS-&gt;FRA</title>
<path fill="none" stroke="black" d="M130.92,-269.49C154.92,-277.34 196.44,-291.51 230.99,-306.37 234.39,-307.83 237.89,-309.43 241.37,-311.09"/>
<polygon fill="black" stroke="black" points="239.65,-314.14 250.17,-315.42 242.74,-307.86 239.65,-314.14"/>
<text xml:space="preserve" text-anchor="middle" x="191.14" y="-310.57" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a14 (LH2001)</text>
</g>
<!-- TLS&#45;&gt;MAD -->
<g id="edge16" class="edge">
<title>TLS-&gt;MAD</title>
<path fill="none" stroke="black" d="M130.89,-247.47C137.31,-242.52 144.52,-237.1 151.29,-232.37 180.36,-212.01 214.53,-190.41 239.14,-175.26"/>
<polygon fill="black" stroke="black" points="240.74,-178.38 247.44,-170.17 237.08,-172.41 240.74,-178.38"/>
<text xml:space="preserve" text-anchor="middle" x="191.14" y="-236.57" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a9 (IB7001)</text>
</g>
<!-- SEA -->
<g id="node23" class="node">
<title>SEA</title>
<polygon fill="none" stroke="black" points="1625.54,-454.39 1583.09,-454.39 1583.09,-411.94 1625.54,-411.94 1625.54,-454.39"/>
<text xml:space="preserve" text-anchor="middle" x="1604.32" y="-428.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">SEA</text>
</g>
<!-- SFO&#45;&gt;SEA -->
<g id="edge18" class="edge">
<title>SFO-&gt;SEA</title>
<path fill="none" stroke="black" d="M1467.59,-433.17C1493.85,-433.17 1540.21,-433.17 1571.34,-433.17"/>
<polygon fill="black" stroke="black" points="1571.34,-436.67 1581.34,-433.17 1571.34,-429.67 1571.34,-436.67"/>
<text xml:space="preserve" text-anchor="middle" x="1524.85" y="-437.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a10 (AS5001)</text>
</g>
<!-- YVR -->
<g id="node24" class="node">
<title>YVR</title>
<polygon fill="none" stroke="black" points="1788.37,-455.94 1742.81,-455.94 1742.81,-410.39 1788.37,-410.39 1788.37,-455.94"/>
<text xml:space="preserve" text-anchor="middle" x="1765.59" y="-428.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">YVR</text>
</g>
<!-- SEA&#45;&gt;YVR -->
<g id="edge19" class="edge">
<title>SEA-&gt;YVR</title>
<path fill="none" stroke="black" d="M1625.81,-433.17C1652.41,-433.17 1699.17,-433.17 1730.99,-433.17"/>
<polygon fill="black" stroke="black" points="1730.87,-436.67 1740.87,-433.17 1730.87,-429.67 1730.87,-436.67"/>
<text xml:space="preserve" text-anchor="middle" x="1684.57" y="-437.37" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a10 (AC6001)</text>
</g>
<!-- IST -->
<g id="node25" class="node">
<title>IST</title>
<polygon fill="none" stroke="black" points="1140.7,-269.67 1103.7,-269.67 1103.7,-232.67 1140.7,-232.67 1140.7,-269.67"/>
<text xml:space="preserve" text-anchor="middle" x="1122.2" y="-246.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">IST</text>
</g>
<!-- IST&#45;&gt;DXB -->
<g id="edge20" class="edge">
<title>IST-&gt;DXB</title>
<path fill="none" stroke="black" d="M1141.1,-248.06C1167.68,-243.45 1218.07,-234.71 1251.51,-228.91"/>
<polygon fill="black" stroke="black" points="1251.82,-232.41 1261.08,-227.26 1250.62,-225.52 1251.82,-232.41"/>
<text xml:space="preserve" text-anchor="middle" x="1205.03" y="-247.86" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a11 (EK3002)</text>
</g>
<!-- SOF&#45;&gt;IST -->
<g id="edge21" class="edge">
<title>SOF-&gt;IST</title>
<path fill="none" stroke="black" d="M977.55,-214.46C1001.83,-218.64 1043.89,-226.53 1079.22,-236.37 1083.62,-237.59 1088.22,-239.04 1092.7,-240.54"/>
<polygon fill="black" stroke="black" points="1091.37,-243.78 1101.96,-243.79 1093.69,-237.18 1091.37,-243.78"/>
<text xml:space="preserve" text-anchor="middle" x="1039.37" y="-240.57" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a12 (TK2002)</text>
</g>
<!-- JFK&#45;&gt;MIA -->
<g id="edge25" class="edge">
<title>JFK-&gt;MIA</title>
<path fill="none" stroke="black" d="M472.3,-385.37C498.95,-387.33 549.05,-391.99 590.78,-401.37 594.19,-402.13 597.71,-403.06 601.2,-404.07"/>
<polygon fill="black" stroke="black" points="600.02,-407.37 610.61,-407.03 602.12,-400.69 600.02,-407.37"/>
<text xml:space="preserve" text-anchor="middle" x="550.15" y="-405.57" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a14 (AA3001)</text>
</g>
<!-- a15 -->
<g id="node28" class="node">
<title>a15</title>
<ellipse fill="none" stroke="black" cx="633.76" cy="-210.17" rx="24.98" ry="24.98"/>
<text xml:space="preserve" text-anchor="middle" x="633.76" y="-205.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a15</text>
</g>
<!-- a15&#45;&gt;RAK -->
<g id="edge27" class="edge">
<title>a15-&gt;RAK</title>
<path fill="none" stroke="black" d="M658.21,-204.03C684.86,-197.05 728.52,-185.63 758.55,-177.77"/>
<polygon fill="black" stroke="black" points="759.08,-181.25 767.86,-175.33 757.3,-174.48 759.08,-181.25"/>
</g>
<!-- a14 -->
<g id="node29" class="node">
<title>a14</title>
<ellipse fill="none" stroke="black" cx="24.98" cy="-294.17" rx="24.98" ry="24.98"/>
<text xml:space="preserve" text-anchor="middle" x="24.98" y="-289.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a14</text>
</g>
<!-- a14&#45;&gt;TLS -->
<g id="edge28" class="edge">
<title>a14-&gt;TLS</title>
<path fill="none" stroke="black" d="M48.7,-285.69C57.92,-282.26 68.72,-278.23 78.61,-274.54"/>
<polygon fill="black" stroke="black" points="79.7,-277.87 87.84,-271.1 77.25,-271.31 79.7,-277.87"/>
</g>
<!-- a13 -->
<g id="node30" class="node">
<title>a13</title>
<ellipse fill="none" stroke="black" cx="633.76" cy="-142.17" rx="24.98" ry="24.98"/>
<text xml:space="preserve" text-anchor="middle" x="633.76" y="-137.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a13</text>
</g>
<!-- a13&#45;&gt;RAK -->
<g id="edge29" class="edge">
<title>a13-&gt;RAK</title>
<path fill="none" stroke="black" d="M658.9,-146.33C685.49,-150.91 728.44,-158.31 758.2,-163.44"/>
<polygon fill="black" stroke="black" points="757.34,-166.84 767.79,-165.09 758.53,-159.95 757.34,-166.84"/>
</g>
<!-- a12 -->
<g id="node31" class="node">
<title>a12</title>
<ellipse fill="none" stroke="black" cx="792.42" cy="-235.17" rx="24.98" ry="24.98"/>
<text xml:space="preserve" text-anchor="middle" x="792.42" y="-230.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a12</text>
</g>
<!-- a12&#45;&gt;SOF -->
<g id="edge30" class="edge">
<title>a12-&gt;SOF</title>
<path fill="none" stroke="black" d="M817.34,-231.62C845.77,-227.42 893.28,-220.38 924.51,-215.76"/>
<polygon fill="black" stroke="black" points="924.73,-219.26 934.11,-214.34 923.71,-212.34 924.73,-219.26"/>
</g>
<!-- a11 -->
<g id="node32" class="node">
<title>a11</title>
<ellipse fill="none" stroke="black" cx="956.54" cy="-275.17" rx="24.98" ry="24.98"/>
<text xml:space="preserve" text-anchor="middle" x="956.54" y="-270.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a11</text>
</g>
<!-- a11&#45;&gt;IST -->
<g id="edge31" class="edge">
<title>a11-&gt;IST</title>
<path fill="none" stroke="black" d="M981.69,-271.62C1011.18,-267.3 1061,-259.99 1092.44,-255.38"/>
<polygon fill="black" stroke="black" points="1092.62,-258.89 1102.01,-253.98 1091.61,-251.97 1092.62,-258.89"/>
</g>
<!-- a10 -->
<g id="node33" class="node">
<title>a10</title>
<ellipse fill="none" stroke="black" cx="1122.2" cy="-450.17" rx="24.98" ry="24.98"/>
<text xml:space="preserve" text-anchor="middle" x="1122.2" y="-445.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a10</text>
</g>
<!-- a10&#45;&gt;LAX -->
<g id="edge32" class="edge">
<title>a10-&gt;LAX</title>
<path fill="none" stroke="black" d="M1147.37,-447.62C1175.14,-444.7 1220.86,-439.88 1251.83,-436.62"/>
<polygon fill="black" stroke="black" points="1251.83,-440.14 1261.41,-435.61 1251.1,-433.18 1251.83,-440.14"/>
</g>
<!-- a9 -->
<g id="node34" class="node">
<title>a9</title>
<ellipse fill="none" stroke="black" cx="24.98" cy="-231.17" rx="20.15" ry="20.15"/>
<text xml:space="preserve" text-anchor="middle" x="24.98" y="-226.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a9</text>
</g>
<!-- a9&#45;&gt;TLS -->
<g id="edge33" class="edge">
<title>a9-&gt;TLS</title>
<path fill="none" stroke="black" d="M44.02,-238.11C54.16,-242.01 67.07,-246.98 78.72,-251.46"/>
<polygon fill="black" stroke="black" points="77.37,-254.7 87.96,-255.02 79.89,-248.16 77.37,-254.7"/>
</g>
<!-- a8 -->
<g id="node35" class="node">
<title>a8</title>
<ellipse fill="none" stroke="black" cx="110.12" cy="-155.17" rx="20.15" ry="20.15"/>
<text xml:space="preserve" text-anchor="middle" x="110.12" y="-150.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a8</text>
</g>
<!-- a8&#45;&gt;MAD -->
<g id="edge34" class="edge">
<title>a8-&gt;MAD</title>
<path fill="none" stroke="black" d="M130.57,-155.17C156.97,-155.17 204.61,-155.17 237.32,-155.17"/>
<polygon fill="black" stroke="black" points="237.11,-158.67 247.11,-155.17 237.11,-151.67 237.11,-158.67"/>
</g>
<!-- a7 -->
<g id="node36" class="node">
<title>a7</title>
<ellipse fill="none" stroke="black" cx="110.12" cy="-328.17" rx="20.15" ry="20.15"/>
<text xml:space="preserve" text-anchor="middle" x="110.12" y="-323.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a7</text>
</g>
<!-- a7&#45;&gt;FRA -->
<g id="edge35" class="edge">
<title>a7-&gt;FRA</title>
<path fill="none" stroke="black" d="M130.57,-328.04C157.72,-327.88 207.32,-327.57 240.05,-327.37"/>
<polygon fill="black" stroke="black" points="239.79,-330.87 249.77,-327.31 239.74,-323.87 239.79,-330.87"/>
</g>
<!-- a6 -->
<g id="node37" class="node">
<title>a6</title>
<ellipse fill="none" stroke="black" cx="1122.2" cy="-194.17" rx="20.15" ry="20.15"/>
<text xml:space="preserve" text-anchor="middle" x="1122.2" y="-189.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a6</text>
</g>
<!-- a6&#45;&gt;DXB -->
<g id="edge36" class="edge">
<title>a6-&gt;DXB</title>
<path fill="none" stroke="black" d="M1142.36,-197.61C1169.14,-202.42 1218.18,-211.23 1251.1,-217.14"/>
<polygon fill="black" stroke="black" points="1250.48,-220.58 1260.94,-218.91 1251.72,-213.69 1250.48,-220.58"/>
</g>
<!-- a5 -->
<g id="node38" class="node">
<title>a5</title>
<ellipse fill="none" stroke="black" cx="452.44" cy="-442.17" rx="20.15" ry="20.15"/>
<text xml:space="preserve" text-anchor="middle" x="452.44" y="-437.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a5</text>
</g>
<!-- a5&#45;&gt;MIA -->
<g id="edge37" class="edge">
<title>a5-&gt;MIA</title>
<path fill="none" stroke="black" d="M472.63,-439.28C503.2,-434.67 563.31,-425.62 600.55,-420.01"/>
<polygon fill="black" stroke="black" points="600.91,-423.5 610.28,-418.55 599.87,-416.58 600.91,-423.5"/>
</g>
<!-- a4 -->
<g id="node39" class="node">
<title>a4</title>
<ellipse fill="none" stroke="black" cx="633.76" cy="-475.17" rx="20.15" ry="20.15"/>
<text xml:space="preserve" text-anchor="middle" x="633.76" y="-470.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a4</text>
</g>
<!-- a4&#45;&gt;ATL -->
<g id="edge38" class="edge">
<title>a4-&gt;ATL</title>
<path fill="none" stroke="black" d="M654.28,-473.3C680.54,-470.78 727.57,-466.28 759.13,-463.26"/>
<polygon fill="black" stroke="black" points="759.27,-466.76 768.89,-462.32 758.6,-459.79 759.27,-466.76"/>
</g>
<!-- a3 -->
<g id="node40" class="node">
<title>a3</title>
<ellipse fill="none" stroke="black" cx="792.42" cy="-400.17" rx="20.15" ry="20.15"/>
<text xml:space="preserve" text-anchor="middle" x="792.42" y="-395.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a3</text>
</g>
<!-- a3&#45;&gt;ORD -->
<g id="edge39" class="edge">
<title>a3-&gt;ORD</title>
<path fill="none" stroke="black" d="M812.65,-402.89C839.62,-406.72 889.07,-413.73 922.12,-418.42"/>
<polygon fill="black" stroke="black" points="921.6,-421.88 931.99,-419.82 922.58,-414.95 921.6,-421.88"/>
</g>
<!-- a2 -->
<g id="node41" class="node">
<title>a2</title>
<ellipse fill="none" stroke="black" cx="956.54" cy="-362.17" rx="20.15" ry="20.15"/>
<text xml:space="preserve" text-anchor="middle" x="956.54" y="-357.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a2</text>
</g>
<!-- a2&#45;&gt;DEN -->
<g id="edge40" class="edge">
<title>a2-&gt;DEN</title>
<path fill="none" stroke="black" d="M976.96,-364.89C1004.45,-368.76 1055.09,-375.87 1088.46,-380.56"/>
<polygon fill="black" stroke="black" points="1087.58,-383.98 1097.97,-381.9 1088.56,-377.04 1087.58,-383.98"/>
</g>
<!-- a1 -->
<g id="node42" class="node">
<title>a1</title>
<ellipse fill="none" stroke="black" cx="24.98" cy="-23.17" rx="20.15" ry="20.15"/>
<text xml:space="preserve" text-anchor="middle" x="24.98" y="-18.97" font-family="Helvetica,Arial,sans-serif" font-size="14.00">a1</text>
</g>
<!-- a1&#45;&gt;HND -->
<g id="edge41" class="edge">
<title>a1-&gt;HND</title>
<path fill="none" stroke="black" d="M45.26,-23.17C54.26,-23.17 65.22,-23.17 75.52,-23.17"/>
<polygon fill="black" stroke="black" points="75.19,-26.67 85.19,-23.17 75.19,-19.67 75.19,-26.67"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 29 KiB

BIN
img/flow_graph_computed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

BIN
img/flow_graph_empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
img/image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View file

@ -1,5 +1,3 @@
A -> B | 08:00 -> 10:00
B -> C | 11:00 -> 12:45
A -> C | 09:43 -> 11:20
RAK -> TLS | 15:00 -> 17:00
TLS -> LAX | 20:00 -> 23:00
RAK -> TLS | 15:00 -> 17:00 | FR3904
RAK -> SOF | 15:05 -> 18:25 | FR3095
TLS -> LAX | 20:00 -> 23:00 | US879

20
scheduling/schedule2.txt Normal file
View file

@ -0,0 +1,20 @@
RAK -> TLS | 15:00 -> 17:00 | FR3904
RAK -> SOF | 15:05 -> 18:25 | FR3095
TLS -> LAX | 20:00 -> 23:00 | US879
SOF -> FRA | 19:10 -> 21:00 | LH1423
FRA -> JFK | 23:00 -> 02:30 | LH400
LAX -> SFO | 00:30 -> 01:45 | UA221
SFO -> SEA | 03:00 -> 05:00 | AS330
SEA -> YVR | 06:15 -> 07:10 | AC809
YVR -> NRT | 10:00 -> 13:30 | AC3
NRT -> SIN | 15:00 -> 21:30 | SQ637
SIN -> SYD | 23:00 -> 06:30 | SQ231
SYD -> MEL | 08:00 -> 09:30 | QF402
MEL -> AKL | 11:00 -> 16:30 | NZ124
AKL -> HNL | 18:00 -> 07:00 | NZ10
HNL -> LAX | 09:00 -> 17:00 | HA11
LAX -> DFW | 19:00 -> 22:30 | AA102
DFW -> MIA | 23:30 -> 03:00 | AA215
MIA -> MAD | 05:00 -> 14:30 | IB6124
MAD -> BCN | 16:00 -> 17:15 | IB304
BCN -> RAK | 19:00 -> 20:30 | FR8123

28
scheduling/schedule3.txt Normal file
View file

@ -0,0 +1,28 @@
RAK -> TLS | 08:00 -> 10:00 | FR1001
TLS -> FRA | 11:00 -> 13:00 | LH2001
FRA -> JFK | 14:30 -> 18:30 | LH4001
JFK -> MIA | 20:00 -> 23:00 | AA3001
RAK -> SOF | 09:00 -> 12:30 | FR1002
SOF -> IST | 13:30 -> 15:00 | TK2002
IST -> DXB | 16:00 -> 20:00 | EK3002
LAX -> SFO | 07:00 -> 08:15 | UA4001
SFO -> SEA | 09:00 -> 11:00 | AS5001
SEA -> YVR | 12:00 -> 13:00 | AC6001
TLS -> MAD | 10:30 -> 12:00 | IB7001
MAD -> BCN | 13:00 -> 14:15 | IB7002
FRA -> CDG | 09:00 -> 10:15 | AF8001
CDG -> ROM | 11:30 -> 13:30 | AF8002
ROM -> ATH | 15:00 -> 17:00 | AZ8003
DXB -> SIN | 21:30 -> 09:00 | SQ9001
SIN -> SYD | 10:30 -> 20:00 | SQ9002
MIA -> ATL | 06:00 -> 08:00 | DL3002
ATL -> ORD | 09:00 -> 11:00 | DL3003
ORD -> DEN | 14:00 -> 16:00 | UA5002
DEN -> LAX | 17:00 -> 19:00 | UA5003
HND -> NRT | 08:00 -> 09:00 | JL6001
NRT -> ICN | 10:30 -> 13:00 | KE6002
ICN -> PEK | 15:00 -> 17:00 | CA6003
BCN -> LIS | 18:00 -> 19:30 | TP7003
LIS -> RAK | 21:00 -> 22:30 | TP7004

View file

@ -1,5 +1,5 @@
(executable
(name ftest)
(name maxflow)
;; (libraries )
;; Disable some warnings
;; (flags (:standard -w -6))

View file

@ -30,16 +30,16 @@ let () =
let graph = from_file infile in
let result = apply_ford_fulkerson (flow_from_string_graph graph) source sink in
export outfile (printable_flow_graph result);
export (outfile ^ ".dot") (printable_flow_graph result);
(match svgfile with
| Some f -> ignore (system (sprintf "dot -Tsvg %s -o %s" outfile f))
| Some f -> ignore (system (sprintf "dot -Tsvg %s.dot -o %s.svg" outfile f))
| None -> ());
end
else if mode = "scheduling" then begin
if Array.length Sys.argv < 5 then begin
printf "Usage: %s scheduling infile crew_count outfile [svgfile]\n" Sys.argv.(0);
printf "Usage: %s scheduling infile airplane_count outfile [svgfile]\n" Sys.argv.(0);
exit 1
end;
@ -59,13 +59,12 @@ let () =
printf "No feasible schedule found.\n";
exit 1
| Some g ->
export_schedule_graph (outfile ^ ".txt") g flights;
export_schedule_graph (outfile ^ ".dot") g flights;
export_schedule (outfile ^ ".schedule") g flights;
(match svgfile with
| Some f ->
export_schedule (outfile ^ ".dot") g flights;
ignore (system (sprintf "dot -Tsvg %s.dot -o %s" outfile f))
ignore (system (sprintf "dot -Tsvg %s.dot -o %s.svg" outfile f))
| None -> ())
end
else begin

View file

@ -1,7 +1,6 @@
open Graph
open Algo
open Tools
open Gfile
type flight = {
id: int;
@ -9,8 +8,12 @@ type flight = {
arrival_airport: string;
departure_time: int;
arrival_time: int;
flight_number: string;
}
let date_to_minutes s = Scanf.sscanf s "%02d:%02d" (fun h m -> h * 60 + m);;
let minutes_to_date m = Printf.sprintf "%02d:%02d" (m / 60) (m mod 60);;
let read_flights_from_file path : flight list =
let ic = open_in path in
let flights = ref [] in
@ -23,15 +26,16 @@ let read_flights_from_file path : flight list =
if line <> "" then begin
try
(* AIRPORT -> AIRPORT | HH:MM -> HH:MM *)
Scanf.sscanf line "%s -> %s | %d:%d -> %d:%d"
(fun departure_airport arrival_airport dep_h dep_m arr_h arr_m ->
let dep_time = dep_h * 60 + dep_m in
let arr_time = arr_h * 60 + arr_m in
Scanf.sscanf line "%s -> %s | %s -> %s | %s"
(fun departure_airport arrival_airport deptime arrtime flight_number ->
let dep_time = date_to_minutes deptime in
let arr_time = date_to_minutes arrtime in
let f = { id = !id_counter;
departure_airport;
arrival_airport;
departure_time = dep_time;
arrival_time = arr_time } in
arrival_time = arr_time;
flight_number } in
flights := f :: !flights;
id_counter := !id_counter + 1
)
@ -198,56 +202,20 @@ let airline_schedule flights k : bounded_flow graph option =
let export_schedule_graph path (g: bounded_flow graph) flights =
let ff = open_out path in
(* Start DOT graph *)
Printf.fprintf ff "digraph airline_schedule {\n";
Printf.fprintf ff " fontname=\"Helvetica,Arial,sans-serif\";\n";
Printf.fprintf ff " node [fontname=\"Helvetica,Arial,sans-serif\"];\n";
Printf.fprintf ff " edge [fontname=\"Helvetica,Arial,sans-serif\"];\n";
Printf.fprintf ff " rankdir=LR;\n";
Printf.fprintf ff " node [shape=circle];\n";
Printf.fprintf ff " node [shape=square];\n";
(* get airport name from node id *)
let node_name id =
match List.find_opt (fun f -> si f.id = id || di f.id = id) flights with
| Some f -> f.departure_airport
| None -> if id = s then "source" else if id = t then "sink" else "unknown"
in
let n = n_fold g (fun a _ -> a + 1) 0 in
let ss = n in
let tt = n + 1 in
(* Print each arc with flow as label *)
let print_arc (arc: bounded_flow arc) =
if arc.lbl.flow > 0 &&
arc.src <> s &&
arc.tgt <> s &&
arc.src <> t &&
arc.tgt <> t &&
arc.src <> ss &&
arc.tgt <> tt then
let src_name = node_name arc.src in
let tgt_name = node_name arc.tgt in
Printf.fprintf ff " \"%s\" -> \"%s\" [label=\"%d\"];\n" src_name tgt_name arc.lbl.flow
in
e_iter g print_arc;
Printf.fprintf ff "}\n";
close_out ff;;
let export_schedule path (g: bounded_flow graph) flights =
let ff = open_out path in
(* Map node id -> flight, start with di because of di -> si case *)
let airport_of_did id =
List.find_opt (fun f -> di f.id = id) flights
in
let airport_of_sid id =
(* grab flight from sid *)
let flight_of_sid id =
List.find_opt (fun f -> si f.id = id) flights
in
let n = n_fold g (fun a _ -> a + 1) 0 in
let ss = n - 2 in
let tt = n - 1 in
@ -275,22 +243,100 @@ let export_schedule path (g: bounded_flow graph) flights =
let airplane_counter = ref 1 in
(* Generate all airplane paths *)
let airplane_initial_flights = ref [] in
(* generate all airplane paths *)
let rec trace_all v =
match next_arc_from v with
| None -> ()
| Some _ ->
let path = trace_airplane [] v in
(* Print the full route *)
let rec print_path = function
| [] -> ()
| (arc: bounded_flow arc) :: rest ->
let airplane = !airplane_counter in
if arc.src = s then
(* Case 1: starts *)
match flight_of_sid arc.tgt with
| Some flight -> airplane_initial_flights := (airplane, flight) :: !airplane_initial_flights
| None -> ()
else if is_si arc.src && is_di arc.tgt then begin
match flight_of_sid arc.src with
| Some flight -> Printf.fprintf ff " \"%s\" -> \"%s\" [label=\"%s\"];\n"
flight.departure_airport
flight.arrival_airport
(Printf.sprintf "a%d (%s)" airplane flight.flight_number)
| None -> ();
end;
print_path rest
in
print_path path;
airplane_counter := !airplane_counter + 1;
trace_all v
in
trace_all s;
(* print airplane nodes*)
Printf.fprintf ff " node [shape=circle];\n";
List.iter (fun (airplane, flight) -> Printf.fprintf ff " \"a%d\" -> \"%s\";\n" airplane flight.departure_airport) !airplane_initial_flights;
Printf.fprintf ff "\n}\n";
close_out ff
let export_schedule path (g: bounded_flow graph) flights =
let ff = open_out path in
(* grab flight from sid *)
let flight_of_sid id =
List.find_opt (fun f -> si f.id = id) flights
in
let n = n_fold g (fun a _ -> a + 1) 0 in
let ss = n - 2 in
let tt = n - 1 in
(* Keep track of which arcs were already used in a path *)
let used = Hashtbl.create 100 in
(* Find next arc with positive flow and not used *)
let next_arc_from v =
List.find_opt (fun (arc: bounded_flow arc) ->
arc.lbl.flow > 0 && not (Hashtbl.mem used (arc.src, arc.tgt)) &&
not (List.mem arc.src [ss; tt]) &&
not (List.mem arc.tgt [ss; tt; t])
) (out_arcs g v)
in
(* Trace one airplane path starting from s *)
let rec trace_airplane path_nodes current =
match next_arc_from current with
| None -> List.rev path_nodes
| Some arc ->
Hashtbl.add used (arc.src, arc.tgt) ();
trace_airplane (arc :: path_nodes) arc.tgt
in
let airplane_counter = ref 1 in
(* generate all airplane paths *)
let rec trace_all v =
match next_arc_from v with
| None -> ()
| Some _ ->
let path = trace_airplane [] v in
let rec print_path = function
| [] -> ()
| (arc: bounded_flow arc) :: rest ->
let airplane = !airplane_counter in
if arc.src = s then
let airport =
match airport_of_sid arc.tgt with
match flight_of_sid arc.tgt with
| Some f -> f.departure_airport
| None -> "?"
in
@ -300,33 +346,23 @@ let export_schedule path (g: bounded_flow graph) flights =
else if is_di arc.src && is_si arc.tgt then
(* Case 2: waits *)
let airport =
match airport_of_did arc.src with
| Some f -> f.arrival_airport
| None -> "?"
in
Printf.fprintf ff
"Airplane %d waits at airport %s\n"
airplane airport
match flight_of_sid arc.tgt with
| Some next_flight -> Printf.fprintf ff
"Airplane %d waits at airport %s for flight %s at %s\n"
airplane next_flight.departure_airport next_flight.flight_number (minutes_to_date next_flight.departure_time)
| None -> ();
else begin
let from_airport =
match airport_of_sid arc.src with
| Some f -> f.departure_airport
| None -> "?"
and to_airport =
match airport_of_did arc.tgt with
| Some f -> f.arrival_airport
| None -> "?"
in
Printf.fprintf ff
"Airplane %d: %s -> %s\n"
airplane from_airport to_airport;
if rest = [] then begin
Printf.fprintf ff
"Airplane %d schedule ends at airport %s\n"
airplane to_airport;
end;
match flight_of_sid arc.src with
| Some flight -> Printf.fprintf ff
"Airplane %d: %s -> %s (%s)\n"
airplane flight.departure_airport flight.arrival_airport flight.flight_number;
if rest = [] then begin
Printf.fprintf ff
"Airplane %d schedule ends at airport %s\n"
airplane flight.arrival_airport;
end;
| None -> ();
end;
print_path rest
@ -339,5 +375,4 @@ let export_schedule path (g: bounded_flow graph) flights =
in
trace_all s;
close_out ff
close_out ff

View file

@ -6,6 +6,7 @@ type flight = {
arrival_airport: string;
departure_time: int;
arrival_time: int;
flight_number: string;
}
type bounded_flow = {