当前位置: 首页>>代码示例>>C++>>正文


C++ GraphEdge::to方法代码示例

本文整理汇总了C++中GraphEdge::to方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphEdge::to方法的具体用法?C++ GraphEdge::to怎么用?C++ GraphEdge::to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphEdge的用法示例。


在下文中一共展示了GraphEdge::to方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
开发者ID:yuwuyi,项目名称:DualGraph,代码行数:13,代码来源:DualGraph.cpp

示例2: 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());
				}

			}

		}
//.........这里部分代码省略.........
开发者ID:yuwuyi,项目名称:kmean,代码行数:101,代码来源:main.cpp


注:本文中的GraphEdge::to方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。