|
| void | add_edge (int from, int to, int capacity) |
| bool | bfs () |
| int | dfs (int u, int f) |
| int | solve (std::vector< int > &matching) |
◆ add_edge()
| void Slic3r::MaxFlowWithLowerBounds::add_edge |
( |
int | from, |
|
|
int | to, |
|
|
int | capacity ) |
48 {
49 adj[from].emplace_back(
edges.size());
50 edges.emplace_back(from, to, capacity, 0);
51
53 edges.emplace_back(to, from, 0, 0);
54 }
std::vector< Edge > edges
Definition ToolOrderUtils.cpp:37
std::vector< std::vector< int > > adj
Definition ToolOrderUtils.cpp:38
References adj, and edges.
◆ bfs()
| bool Slic3r::MaxFlowWithLowerBounds::bfs |
( |
| ) |
|
56 {
58 std::queue<int> q;
61
62 while (!q.empty()) {
63 int u = q.front(); q.pop();
64 for (
int eid :
adj[u]) {
66 if (e.flow < e.capacity &&
level[e.to] == -1) {
68 q.push(e.to);
69 }
70 }
71 }
73 }
@ Edge
Definition Measure.hpp:26
int source_id
Definition ToolOrderUtils.cpp:43
int sink_id
Definition ToolOrderUtils.cpp:44
int total_nodes
Definition ToolOrderUtils.cpp:42
std::vector< int > level
Definition ToolOrderUtils.cpp:39
References adj, Slic3r::Edge::capacity, edges, Slic3r::Edge::flow, level, sink_id, source_id, Slic3r::Edge::to, and total_nodes.
Referenced by solve().
◆ dfs()
| int Slic3r::MaxFlowWithLowerBounds::dfs |
( |
int | u, |
|
|
int | f ) |
75 {
77 for (
int &i =
it[u]; i < (int)
adj[u].size(); ++i) {
80 if (e.flow < e.capacity &&
level[e.to] ==
level[u] + 1) {
81 int pushed =
dfs(e.to, std::min(
f, e.capacity - e.flow));
82 if (pushed > 0) {
83 e.flow += pushed;
84 edges[eid ^ 1].flow -= pushed;
85 return pushed;
86 }
87 }
88 }
89 return 0;
90 }
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124
std::vector< int > it
Definition ToolOrderUtils.cpp:40
int dfs(int u, int f)
Definition ToolOrderUtils.cpp:75
References adj, Slic3r::Edge::capacity, dfs(), edges, Slic3r::f(), Slic3r::Edge::flow, it, level, sink_id, and Slic3r::Edge::to.
Referenced by dfs(), and solve().
◆ solve()
| int Slic3r::MaxFlowWithLowerBounds::solve |
( |
std::vector< int > & | matching | ) |
|
92 {
93 int flow = 0;
97 flow += pushed;
98 }
99
102
104 for (
int u = 0; u <
L; ++u) {
105 for (
int eid :
adj[u]) {
107 if (e.flow > 0 && e.to >=
L && e.to <
L + R) {
108 matching[e.from] = e.to -
L;
109 }
110 }
111 }
112 return flow;
113 }
#define L(s)
Definition ExtrusionEntity.cpp:25
const int INF
Definition ToolOrderUtils.hpp:20
const int INVALID_ID
Definition ToolOrderUtils.hpp:21
std::vector< int > r_nodes
Definition ToolOrderUtils.cpp:36
bool bfs()
Definition ToolOrderUtils.cpp:56
std::vector< int > l_nodes
Definition ToolOrderUtils.cpp:35
References adj, bfs(), dfs(), edges, Slic3r::Edge::flow, Slic3r::Edge::from, Slic3r::MaxFlowGraph::INF, Slic3r::MaxFlowGraph::INVALID_ID, it, L, l_nodes, r_nodes, source_id, Slic3r::Edge::to, and total_nodes.
◆ adj
| std::vector<std::vector<int> > Slic3r::MaxFlowWithLowerBounds::adj |
◆ edges
| std::vector<Edge> Slic3r::MaxFlowWithLowerBounds::edges |
◆ it
| std::vector<int> Slic3r::MaxFlowWithLowerBounds::it |
◆ l_nodes
| std::vector<int> Slic3r::MaxFlowWithLowerBounds::l_nodes |
◆ level
| std::vector<int> Slic3r::MaxFlowWithLowerBounds::level |
◆ r_nodes
| std::vector<int> Slic3r::MaxFlowWithLowerBounds::r_nodes |
◆ sink_id
| int Slic3r::MaxFlowWithLowerBounds::sink_id { -1 } |
◆ source_id
| int Slic3r::MaxFlowWithLowerBounds::source_id { -1 } |
◆ total_nodes
| int Slic3r::MaxFlowWithLowerBounds::total_nodes { -1 } |
The documentation for this struct was generated from the following file: