本文整理汇总了C++中AdjacencyList::nodeCount方法的典型用法代码示例。如果您正苦于以下问题:C++ AdjacencyList::nodeCount方法的具体用法?C++ AdjacencyList::nodeCount怎么用?C++ AdjacencyList::nodeCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdjacencyList
的用法示例。
在下文中一共展示了AdjacencyList::nodeCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
int minCutEdges = N_NODES;
AdjacencyList adjList(N_NODES);
std::ifstream infile;
infile.open("../kargerMinCut.txt");
if (!infile) {
std::cout << "Opening file failed." << std::endl;
return -1;
}
std::string line;
while (std::getline(infile, line)) {
std::istringstream iss(line);
int u, v;
iss >> u;
while (iss >> v) {
if (iss.fail()) {
std::cout << "Reading error or incorrect type." << std::endl;
return -1;
}
if (u < 1 || u > N_NODES || v < 1 || v > N_NODES) {
std::cout << "Vertex ID out of range" << std::endl;
return -1;
}
adjList.insertEdge(u-1, v-1);
}
}
SteadyClockTimer timer;
timer.start();
for (int i = 0; i < ITERATIONS; ++i) {
srand(i);
AdjacencyList adjListCopy = adjList;
while (adjListCopy.nodeCount() > 2) {
adjListCopy.contractRandomEdge();
}
if (adjListCopy.edgeCount() < minCutEdges) {
minCutEdges = adjListCopy.edgeCount();
}
}
std::cout << "After " << ITERATIONS << " iterations," << std::endl;
std::cout << "Possible min cut edge count is: " << minCutEdges << std::endl;
std::cout << "time taken is: " << timer.getMs() << " ms" << std::endl;
return 0;
}