-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmin_path_error_additional_starts.py
49 lines (44 loc) · 1.25 KB
/
min_path_error_additional_starts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import flowpaths as fp
import networkx as nx
graph = nx.DiGraph()
graph.add_edge("s", "a", flow=6)
graph.add_edge("a", "b", flow=22)
graph.add_edge("s", "b", flow=7)
graph.add_edge("a", "c", flow=4)
graph.add_edge("b", "c", flow=29)
graph.add_edge("c", "d", flow=26)
graph.add_edge("d", "t", flow=6)
graph.add_edge("c", "t", flow=7)
mpe_model = fp.kMinPathError(graph, flow_attr="flow", k=4, weight_type=int)
mpe_model.solve()
if mpe_model.is_solved():
print(mpe_model.get_solution())
mpe_model_2 = fp.kMinPathError(
graph,
flow_attr="flow",
k=4,
weight_type=int,
additional_starts=['a'],
additional_ends=['d'])
mpe_model_2.solve()
if mpe_model_2.is_solved():
print(mpe_model_2.get_solution())
graph10 = nx.DiGraph()
graph10.add_edge("s", "a", flow=6)
graph10.add_edge("a", "b", flow=12)
graph10.add_edge("s", "b", flow=7)
graph10.add_edge("a", "c", flow=4)
graph10.add_edge("b", "c", flow=19)
graph10.add_edge("c", "d", flow=16)
graph10.add_edge("d", "t", flow=6)
graph10.add_edge("c", "t", flow=7)
mpe_model_10 = fp.kMinPathError(
graph10,
flow_attr="flow",
k=4,
weight_type=int,
additional_starts=['a'],
additional_ends=['d'])
mpe_model_10.solve()
if mpe_model_10.is_solved():
print(mpe_model_10.get_solution())