本文整理汇总了C++中ListDigraph::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ ListDigraph::erase方法的具体用法?C++ ListDigraph::erase怎么用?C++ ListDigraph::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListDigraph
的用法示例。
在下文中一共展示了ListDigraph::erase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv){
// ------------------------------
// --- INPUT - OUTPUT
// ------------------------------
string sourceLGF, sourceTempEdge, target;
ArgParser ap( argc, argv);
ap.refOption("g", "Graph file of LEMON GRAPH FORMAT", sourceLGF, true);
ap.refOption("t", "Temporal active edges", sourceTempEdge, true);
ap.refOption("n", "Target filename", target, true);
ap.parse();
// sourceLGF = "/Users/sonneundasche/Documents/FLI/DATA/02Sheep/Schaf_NEW.lgf";
// sourceTempEdge = "/Users/sonneundasche/Documents/FLI/DATA/02Sheep/Schaf_NEW_time_tmpArcIDs.txt";
// sourceLGF = "/Users/sonneundasche/Documents/FLI/DATA/03Pork/porkNEW_.lgf";
// sourceTempEdge = "/Users/sonneundasche/Documents/FLI/DATA/03Pork/porkNEW__time_tmpArcIDs.txt";
// target = "Test";
// ------------------------------
// --- Graph creation
// ------------------------------
cout << "- READING\n";
ListDigraph mGraph;
try {
digraphReader(mGraph, sourceLGF)
.run();
} catch (lemon::Exception) {
cerr << "Error reading";
exit(0);
}
// ------------------------------
// --- Temporal Edges
// ------------------------------
vector<int> times;
boost::unordered_map< int, vector<ListDigraph::Arc > > mTimeToArcs;
times = tempGR::readTemporalArcList(mGraph, mTimeToArcs, sourceTempEdge);
// ------------------------------
// --- Determine the components
// ------------------------------
cout << "- CALCULATION\n";
ListDigraph::NodeMap<int> mCompIds(mGraph);
mapFill(mGraph, mCompIds, -1);
int nrComponents = connectedComponents( undirector( mGraph ), mCompIds );
// Determine the ID with the biggest component
vector<int> mIDcount(nrComponents,0);
for (ListDigraph::NodeIt n(mGraph); n!=INVALID; ++n) {
mIDcount[ mCompIds[ n ] ]++;
}
auto a = max_element( mIDcount.begin(), mIDcount.end() );
int maxCompID = distance( mIDcount.begin(), a );
cout << "Nodes: " << countNodes( mGraph ) << " components: " << countConnectedComponents( undirector( mGraph ) ) << endl;
cout << "Max Comp ID: " << maxCompID << " size: " << *a << endl;
// int i = 0;
// for ( auto x : mIDcount ){
// cout << "Comp ID: " << i++ << " size: " << x << endl;
// }
// ------------------------------
// --- Mark nodes of the biggest component
// ------------------------------
cout << "- PROCESSING\n";
vector< ListDigraph::Node > eraseNodes;
for (ListDigraph::NodeIt n(mGraph); n!=INVALID; ++n) {
if ( mCompIds[ n ] != maxCompID) {
eraseNodes.push_back(n);
}
}
cout << "The complete graph has " << countConnectedComponents( undirector( mGraph ) )
<< " components and " << countNodes(mGraph) << " nodes" << endl;
// ------------------------------
// --- erase the nodes
// ------------------------------
for (auto n : eraseNodes){
mGraph.erase( n );
}
cout << "The new graph has " << countConnectedComponents( undirector( mGraph ) )
<< " components and " << countNodes(mGraph) << " nodes" << endl;
ListDigraph newGraph;
ListDigraph::ArcMap< ListDigraph::Arc > arcRef( mGraph);
ListDigraph::NodeMap< ListDigraph::Node> nodeRef( mGraph );
digraphCopy( mGraph, newGraph)
.arcRef(arcRef) // arcMap[ oldArc ] = newArc
.nodeRef(nodeRef)
.run();
// ------------------------------
// --- erase the invalid temporal edges
// ------------------------------
vector< vector< ListDigraph::Arc > > newTempArcs;
//.........这里部分代码省略.........