本文整理汇总了C++中Wire::collectChained方法的典型用法代码示例。如果您正苦于以下问题:C++ Wire::collectChained方法的具体用法?C++ Wire::collectChained怎么用?C++ Wire::collectChained使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wire
的用法示例。
在下文中一共展示了Wire::collectChained方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: minCut
void GraphUtils::minCut(QList<ConnectorItem *> & connectorItems, QList<SketchWidget *> & foreignSketchWidgets, ConnectorItem * source, ConnectorItem * sink, QList<ConnectorEdge *> & minCut)
{
// this helped: http://boost.2283326.n4.nabble.com/graph-edmund-karp-max-flow-vs-kolmogorov-max-flow-color-map-td2565611.html
using namespace boost;
typedef adjacency_list_traits < vecS, vecS, directedS > Traits;
typedef property < vertex_color_t, boost::default_color_type > COLOR;
typedef property < vertex_index_t, long, COLOR > VERTEX;
typedef property < edge_reverse_t, Traits::edge_descriptor > REVERSE;
typedef property < edge_residual_capacity_t, long, REVERSE > RESIDUAL;
typedef property < edge_capacity_t, long, RESIDUAL > EDGE;
typedef adjacency_list < listS, vecS, directedS, VERTEX, EDGE > Graph;
Graph g;
property_map < Graph, edge_capacity_t >::type capacity = get(edge_capacity, g);
property_map < Graph, edge_residual_capacity_t >::type residual_capacity = get(edge_residual_capacity, g);
property_map < Graph, edge_reverse_t >::type reverse = get(edge_reverse, g);
property_map < Graph, vertex_color_t >::type color = get(vertex_color, g);
property_map < Graph, vertex_index_t >::type index = get(vertex_index, g);
Traits::vertex_descriptor s, t;
QList<Wire *> visitedWires;
QList<int> indexes;
QHash<ConnectorItem *, int> vertices;
QList<ConnectorEdge *> edges;
QVector<Traits::vertex_descriptor> verts;
vertices.insert(source, 0);
vertices.insert(sink, 1);
verts.append(s = add_vertex(g));
verts.append(t = add_vertex(g));
foreach (ConnectorItem * connectorItem, connectorItems) {
//connectorItem->debugInfo("input");
if (connectorItem->attachedToItemType() == ModelPart::Wire) {
Wire * wire = qobject_cast<Wire *>(connectorItem->attachedTo());
if (visitedWires.contains(wire)) continue;
QList<Wire *> wires;
QList<ConnectorItem *> ends;
wire->collectChained(wires, ends);
visitedWires.append(wires);
if (ends.count() < 2) continue;
foreach (ConnectorItem * end, ends) {
appendVertIf(end, vertices, verts);
}
for (int i = 0; i < ends.count(); i++) {
ConnectorItem * end = ends[i];
for (int j = i + 1; j < ends.count(); j++) {
ConnectorEdge * connectorEdge = makeConnectorEdge(edges, end, ends[j], 1000, wire);
connectorEdge->setHeadTail(vertices.value(connectorEdge->c0), vertices.value(connectorEdge->c1));
}
}
continue;
}