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


C++ Network::addEdge方法代码示例

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


在下文中一共展示了Network::addEdge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Network

 Network *duplicate()
     {
         Network *network = new Network(mVertices.size());
         int i;
         Edge *edge;
         for (i=0;i<mEdges.size();i++)
         {
             edge = mEdges[i];
             cout << edge->start()->index() << " " << edge->end()->index() << endl;
             network->addEdge(edge->start()->index(),edge->end()->index());
         }
         return network;
     }
开发者ID:RoboBuddie,项目名称:gubg,代码行数:13,代码来源:network.hpp

示例2: flatten

// Only for named networks
void flatten(MultipleNetwork& mnet, MNET_FLATTENING_ALGORITHM algorithm,
		Network& net) {

	std::set<global_vertex_id> vertexes;
	mnet.getVertexes(vertexes);
	std::set<global_vertex_id>::const_iterator v_it;
	for (v_it = vertexes.begin(); v_it != vertexes.end(); ++v_it) {
		net.addVertex(mnet.getVertexName(*v_it));
	}

	std::set<global_edge_id> edges;
	mnet.getEdges(edges);
	std::set<global_edge_id>::const_iterator e_it;
	for (e_it = edges.begin(); e_it != edges.end(); ++e_it) {
		if (! net.containsEdge(mnet.getVertexName((*e_it).v1),mnet.getVertexName((*e_it).v2)))
			net.addEdge(mnet.getVertexName((*e_it).v1),mnet.getVertexName((*e_it).v2));
	}
}
开发者ID:mostafa-salehi,项目名称:multiplenetwork,代码行数:19,代码来源:flattening.cpp

示例3: route_edges


//.........这里部分代码省略.........
               //if (i==iter) debugpoint(cur.p(c),state.avgsize/10,0,0,255);
            }
         }
         used[minidx]=1;
         Point cp=cur.cross_point(gs[minidx].line);
         //if (i==iter) debugpoint(cp,state.avgsize/10,0,255,0);
         gs[minidx].line.re_ref(cp); // setting ref point of next line to the current cross point
         //if (i==iter) debugline(gs[minidx].line.from(),gs[minidx].line.p(state.avgsize),255,0,255);
         int newnode=nv.nodes.size(); 
         nv.addNode(newnode,other,"",1,1,cp.x,cp.y,0);
         edge_crossings[min(i,gs[curidx].node)][max(i,gs[curidx].node)].push_back(newnode); // add the new node to the two veronoi lines it belongs to
         edge_crossings[min(i,gs[minidx].node)][max(i,gs[minidx].node)].push_back(newnode);
         //nodemap[i].push_back(newnode);
         lastidx=curidx;
         curidx=minidx;
         first=false;
         //if (i==iter) debugline(cur.from(),cp,0,0,0);
      }
   }
   printf("finding relevant cross points on seperator lines and building network\n");
   
   // go through all voronoi lines and connect all registered cross points
   CmpCrossPoints ccp(nv);
   for (i=0;i<n+4;i++){ // includes 4 virtual nodes
      for (j=i+1;j<n+4;j++){
         if (edge_crossings[i][j].size() ==0 ) continue;
         sort(edge_crossings[i][j].begin(),edge_crossings[i][j].end(),ccp); // sort cross points on line
         for (k=0;k<(int)edge_crossings[i][j].size();k++){
            int n1=edge_crossings[i][j][k];
            if (i<n) nodemap[i].push_back(n1); // register voronoi node to be adjacent to original node i (if not virtual node)
            if (j<n) nodemap[j].push_back(n1);
            if (k==((int)edge_crossings[i][j].size())-1) break; // for the last crosspoint we do not create an edge
            int n2=edge_crossings[i][j][k+1];
            nv.addEdge(n1,n2,undirected);
            if (iter<=1) debugline(nv.nodes[n1].x,nv.nodes[n1].y,nv.nodes[n2].x,nv.nodes[n2].y,0,0,0,true);
         }
      }
   }
   printf("finding shortest path through network for each original edge\n");
   if (iter>=1){ // this is just for showing 1 step show only veronoi lines, 2nd show splines
      nv.calcEdgeLengths();
      int m=state.nw.edges.size();
      for (i=0;i<m;i++){
         printf(".");fflush(stdout);
         Edge &e=state.nw.edges[i];
         int n1=e.from;
         int n2=e.to;
         BFS bfs(nv,nodemap[n1]);
         int nn=bfs.next();
         while (nn>=0 && find(nodemap[n2].begin(),nodemap[n2].end(),nn)==nodemap[n2].end()){
            nn=bfs.next();
         }
         if (nn<0) printf("Ups, no route for edge\n");
         VI path=bfs.path();
         smooth_path(nv,path,state.avgsize/4);
         e.splinepoints.clear();
         e.splinehandles.clear();
         double beta;
         Point vec;
         double dd1=(path.size()>1 ? 
            (norm(nv.nodes[path[0]]-state.nw.nodes[n1])-max(state.nw.nodes[n1].width,state.nw.nodes[n1].height)/2)/2 :
            (norm(state.nw.nodes[n2]-state.nw.nodes[n1])-max(state.nw.nodes[n1].width,state.nw.nodes[n1].height)/2-max(state.nw.nodes[n2].width,state.nw.nodes[n2].height)/2)/2);
         dd1=min(dd1,state.avgsize/2);
         double d1=max(state.nw.nodes[n1].width,state.nw.nodes[n1].height)/2+dd1;
         double dd2=(path.size()>1 ? 
         (norm(nv.nodes[path.back()]-state.nw.nodes[n2])-max(state.nw.nodes[n2].width,state.nw.nodes[n2].height)/2)/2 :
开发者ID:fugufisch,项目名称:biographer,代码行数:67,代码来源:edgerouting.cpp


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