polish/reindent graph python wrappers and samples
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
# [START program]
|
||||
"""Solve assignment problem using linear assignment solver."""
|
||||
# [START import]
|
||||
from ortools.graph.python import linear_sum_assignment
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ortools.graph.python import linear_sum_assignment
|
||||
# [END import]
|
||||
|
||||
|
||||
@@ -35,8 +35,10 @@ def main():
|
||||
[45, 110, 95, 115],
|
||||
])
|
||||
|
||||
# Let's transform this into 3 parallel vectors (start_nodes, end_nodes, arc_costs)
|
||||
end_nodes_unraveled, start_nodes_unraveled = np.meshgrid(np.arange(costs.shape[1]),np.arange(costs.shape[0]))
|
||||
# Let's transform this into 3 parallel vectors (start_nodes, end_nodes,
|
||||
# arc_costs)
|
||||
end_nodes_unraveled, start_nodes_unraveled = np.meshgrid(
|
||||
np.arange(costs.shape[1]), np.arange(costs.shape[0]))
|
||||
start_nodes = start_nodes_unraveled.ravel()
|
||||
end_nodes = end_nodes_unraveled.ravel()
|
||||
arc_costs = costs.ravel()
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
# [START program]
|
||||
"""From Taha 'Introduction to Operations Research', example 6.4-2."""
|
||||
# [START import]
|
||||
from ortools.graph.python import max_flow
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ortools.graph.python import max_flow
|
||||
# [END import]
|
||||
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
# [START program]
|
||||
"""From Bradley, Hax and Maganti, 'Applied Mathematical Programming', figure 8.1."""
|
||||
# [START import]
|
||||
from ortools.graph.python import min_cost_flow
|
||||
|
||||
import numpy as np
|
||||
|
||||
from ortools.graph.python import min_cost_flow
|
||||
# [END import]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user