本文整理汇总了C++中GraphNode::id方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphNode::id方法的具体用法?C++ GraphNode::id怎么用?C++ GraphNode::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphNode
的用法示例。
在下文中一共展示了GraphNode::id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveGraph
void DualGraph::saveGraph(const char *filename) {
std::ofstream output(filename);
for (NodeIter nit(this); !nit.end(); ++nit) {
GraphNode *node = *nit;
output << "v " << node->id() << "\n";
}
for (EdgeIter eit(this); !eit.end(); ++eit) {
GraphEdge *edge = *eit;
output << "e " << edge->from()->id() << " " << edge->to()->id() << "\n";
}
output.close();
}
示例2: calculateOutput
// May be overridden by child classes.
std::string GraphNode::calculateOutput()
{
fmt::MemoryWriter output;
for (auto input : mInputs) {
if (input->link()) {
GraphNodeLink *link = input->link();
// spdlog::get("qde")->debug("Node '{}': Input has link: '{}'", mId, link->id());
if (link->source()) {
GraphNode *node = dynamic_cast<GraphNode *>(link->source()->parent());
output << node->calculateOutput();
spdlog::get("qde")->debug("Node '{}': Link has source: '{}'", mId, node->id());
}
}
}
return output.str();
}
示例3: generateGraph
DualGraph* generateGraph(std::vector<Patch*>& patches) {
DualGraph *dualGraph = new DualGraph;
std::map<Vertex*, std::vector<Patch*> > ver2patchMap;
for (auto p : patches) {
GraphNode *node = dualGraph->addNode();
p->graphNode = node;
for (auto v : p->vertices) {
auto pvec = ver2patchMap[v];
for (size_t i = 0; i < pvec.size(); ++i) {
Patch *p0 = pvec[i];
dualGraph->addEdge(p0->graphNode, node);
dualGraph->addEdge(node, p0->graphNode);
}
ver2patchMap[v].push_back(p);
}
}
//well.. let's print out the dualgraph
//convert the dual graph to cm
//first, the position, each center of the cluster
std::ofstream dgfile("dualgraph.cm");
for (auto p : patches) {
GraphNode *gnode = p->graphNode;
dgfile << "Vertex " << gnode->id() + 1 << " " << p->center[0] << " " << p->center[1] << " " << p->center[2] << "\n";
}
for (auto p : patches) {
GraphNode *gnode = p->graphNode;
for (GraphNode::EdgeIter eit(gnode); !eit.end(); ++eit) {
GraphEdge *edge = *eit;
if (edge->to()->id() > gnode->id()) {
dgfile << "Edge " << edge->from()->id() + 1 << " " << edge->to()->id() + 1 << "\n";
}
}
}
dualGraph->saveMetis("dualgraph.metis");
dgfile.close();
std::vector <std::string> edgestr;
std::set<Vertex*> vertices;
double total_boundary_length = 0;
int boundary_count = 0;
for (auto p : patches) {
std::set<Vertex*> pvertices;
for (auto he : p->boundary) {
if (!he->twin()) {
total_boundary_length += (he->source()->point() - he->target()->point()).norm();
++boundary_count;
if ( ver2patchMap[he->source()].size() == 1) {
//continue;
}
vertices.insert(he->source());
auto itpair = pvertices.insert(he->source());
if (itpair.second) {
p->corners.push_back(he->source());
}
if ( ver2patchMap[he->target()].size() == 1) {
// continue;
}
vertices.insert(he->target());
itpair = pvertices.insert(he->target());
if (itpair.second) {
p->corners.push_back(he->target());
}
}
if ( ver2patchMap[he->source()].size() >= 3) {
vertices.insert(he->source());
auto itpair = pvertices.insert(he->source());
if (itpair.second) {
p->corners.push_back(he->source());
}
}
if ( ver2patchMap[he->target()].size() >= 3) {
vertices.insert(he->target());
auto itpair = pvertices.insert(he->target());
if (itpair.second) {
p->corners.push_back(he->target());
}
}
}
//.........这里部分代码省略.........