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


C++ Digraph::addArc方法代码示例

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


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

示例1: BuildEdgesMap

static void BuildEdgesMap(const IntArray& E, const IntArray& U, const IntArray& V,
						  Digraph& dg, IntNodeMap& nodes_map, IntArcMap& edges_map)
{
	for(unsigned int i=0;i<E.size();i++)
	{
		if(edges_map.find(E[i]) == edges_map.end())
		{
			Digraph::Node u = nodes_map[U[i]];
			Digraph::Node v = nodes_map[V[i]];
			Digraph::Arc e = dg.addArc(u, v);
			edges_map.insert(IntArcMap::value_type(E[i], e));
		}
	}
}
开发者ID:wyrover,项目名称:GDES,代码行数:14,代码来源:GraphUtils.cpp

示例2: vno_test3

void vno_test3()
{
    cout<<"【测试1】直接调用vno库进行网络解算...."<<endl;
    // 1) 通风网络
    Digraph dg;
    // 记录节点编号
    NodeIdMap nid(dg);
    //记录分支编号
    EdgeIdMap eid(dg);
    // 3) 分支数据--风阻、计算风量
    VNO_EdgeMap ed(dg,0);
    // 4) 风机数据
    VNO_FanMap fd(dg,0);
    //节点数据
    VNO_NodeMap nd(dg,0);

    // 构建通风网络
    Digraph::Node v1 = dg.addNode();
    Digraph::Node v2 = dg.addNode();
    Digraph::Node v3 = dg.addNode();
    Digraph::Node v4 = dg.addNode();
    Digraph::Node v5 = dg.addNode();
    Digraph::Node v6 = dg.addNode();
    Digraph::Arc e1 = dg.addArc(v1, v2); // v1 -> v2
    Digraph::Arc e2 = dg.addArc(v2, v3); // v2 -> v3
    Digraph::Arc e3 = dg.addArc(v2, v4); // v2 -> v4
    Digraph::Arc e4 = dg.addArc(v3, v5); // v3 -> v5
    Digraph::Arc e6 = dg.addArc(v4, v5); // v4 -> v5
    Digraph::Arc e5 = dg.addArc(v3, v4); // v3 -> v4
    Digraph::Arc e7 = dg.addArc(v5, v6); // v5 -> v6

    // 记录节点和分支编号(方便打印输出)
    nid[v1]=1; nid[v2]=2; nid[v3]=3; nid[v4]=4; nid[v5]=5; nid[v6]=6;
    eid[e1]=1; eid[e2]=2; eid[e3]=3; eid[e4]=4; eid[e5]=5; eid[e6]=6; eid[e7]=7;

    // 设置分支数据(风阻)
    ed[e1]=CreateEdgeData(0.375);
    ed[e2]=CreateEdgeData(1.5);
    ed[e3]=CreateEdgeData(2.0);
    ed[e4]=CreateEdgeData(4.6875);
    ed[e5]=CreateEdgeData(12.5);
    ed[e6]=CreateEdgeData(1.7361);
    ed[e7]=CreateEdgeData(0.5);

    //设置节点数据(压力和高程)
    //注:高程数据暂时没有用
    nd[v1] = CreateNodeData(10000,0); //必须已知源点的压力和高程
    nd[v2] = CreateNodeData(0,0);
    nd[v3] = CreateNodeData(0,0);
    nd[v4] = CreateNodeData(0,0);
    nd[v5] = CreateNodeData(0,0);
    nd[v6] = CreateNodeData(0,0);

    //固定风量

    // 添加风机数据(特性曲线参数)
    fd[e7]=CreateFanData(1046.3, 5, -0.85);

    // 2) 网络数据--总风量
    double Q = 20;

    // 解算通风网络
    bool ret = VNO(dg, ed, fd, nd, Q);

    //PrintVN(dg,eid,nid,ed,fd,nd,Q);
    // 打印解算结果
    if(!ret)
    {
        cout<<"解算失败"<<endl;
    }
    else
    {
        cout<<"解算成功"<<endl;
        PrintVN(dg,eid,nid,ed,fd,nd,Q);

        //EdgeArray p;
        ////搜索最大阻力路线
        //MRP(dg,ed,fd,nd,p);
        //PrintMRP(dg,eid,nid,ed,fd,p);
        //PrintVN(dg,eid,nid,ed,fd,nd,Q);

        ////通路调节
        //APM(dg,ed,fd,nd,Simple_AdjustFunc);
    }

    // 清除内存
    VNO_ClearDatas(dg, ed, fd, nd);
}
开发者ID:hunanhd,项目名称:vns,代码行数:88,代码来源:test.cpp

示例3: vno_test

void vno_test()
{
    cout<<"【测试1】直接调用vno库进行网络解算...."<<endl;
    // 1) 通风网络
    Digraph dg;
    // 记录节点编号
    NodeIdMap nid(dg);
    //记录分支编号
    EdgeIdMap eid(dg);
    // 3) 分支数据--风阻、计算风量
    VNO_EdgeMap ed(dg,0);
    // 4) 风机数据
    VNO_FanMap fd(dg,0);
    //节点数据
    VNO_NodeMap nd(dg,0);

    // 构建通风网络
    Digraph::Node v1 = dg.addNode();
    Digraph::Node v2 = dg.addNode();
    Digraph::Node v3 = dg.addNode();
    Digraph::Node v4 = dg.addNode();
    Digraph::Node v5 = dg.addNode();
    Digraph::Node v6 = dg.addNode();
    Digraph::Node v7 = dg.addNode();
    Digraph::Node v8 = dg.addNode();
    Digraph::Node v9 = dg.addNode();
    Digraph::Node v10 = dg.addNode();
    Digraph::Arc e1 = dg.addArc(v1, v2); // v1 -> v2
    Digraph::Arc e2 = dg.addArc(v2, v3); // v2 -> v3
    Digraph::Arc e3 = dg.addArc(v2, v4); // v2 -> v4
    Digraph::Arc e4 = dg.addArc(v3, v5); // v3 -> v5
    Digraph::Arc e5 = dg.addArc(v4, v5); // v3 -> v4
    Digraph::Arc e6 = dg.addArc(v3, v6); // v4 -> v5
    Digraph::Arc e7 = dg.addArc(v5, v7); // v5 -> v6
    Digraph::Arc e8 = dg.addArc(v4, v8); // v5 -> v6
    Digraph::Arc e9 = dg.addArc(v6, v7); // v5 -> v6
    Digraph::Arc e10 = dg.addArc(v7, v8); // v5 -> v6
    Digraph::Arc e11 = dg.addArc(v6, v9); // v5 -> v6
    Digraph::Arc e12 = dg.addArc(v8, v9); // v5 -> v6
    Digraph::Arc e13 = dg.addArc(v9, v10); // v5 -> v6

    // 记录节点和分支编号(方便打印输出)
    nid[v1]=1; nid[v2]=2; nid[v3]=3; nid[v4]=4; nid[v5]=5; nid[v6]=6;
    nid[v7]=7; nid[v8]=8; nid[v9]=9; nid[v10]=10;
    eid[e1]=1; eid[e2]=2; eid[e3]=3; eid[e4]=4; eid[e5]=5; eid[e6]=6; eid[e7]=7;
    eid[e8]=8; eid[e9]=9; eid[e10]=10; eid[e11]=11; eid[e12]=12; eid[e13]=13;

    // 设置分支数据(风阻)
    ed[e1]=CreateEdgeData(0.0225);
    ed[e2]=CreateEdgeData(0.1104);
    ed[e3]=CreateEdgeData(0.3);
    ed[e4]=CreateEdgeData(0.158);
    ed[e5]=CreateEdgeData(3.6);
    ed[e6]=CreateEdgeData(0.15);
    ed[e7]=CreateEdgeData(0.072);
    ed[e8]=CreateEdgeData(1.35);
    ed[e9]=CreateEdgeData(0.225);
    ed[e10]=CreateEdgeData(0.0551);
    ed[e11]=CreateEdgeData(4.5);
    ed[e12]=CreateEdgeData(0.0385);
    ed[e13]=CreateEdgeData(0.0585);

    //设置节点数据(压力和高程)
    //注:高程数据暂时没有用
    nd[v1] = CreateNodeData(10000,0); //必须已知源点的压力和高程
    nd[v2] = CreateNodeData(0,0);
    nd[v3] = CreateNodeData(0,0);
    nd[v4] = CreateNodeData(0,0);
    nd[v5] = CreateNodeData(0,0);
    nd[v6] = CreateNodeData(0,0);
    nd[v7] = CreateNodeData(0,0);
    nd[v8] = CreateNodeData(0,0);
    nd[v9] = CreateNodeData(0,0);
    nd[v10] = CreateNodeData(0,0);

    //固定风量
    ed[e6]->fq=30;
    ed[e7]->fq=40;
    ed[e8]->fq=25;
    //ed[e11]->fq=10;

    // 添加风机数据(特性曲线参数)
    //fd[e7]=CreateFanData(1046.3, 5, -0.85, 0, 0, 0);

    // 2) 网络数据--总风量
    double Q = 100;

    // 解算通风网络
    bool ret = VNO(dg, ed, fd, nd, Q);

    //PrintVN(dg,eid,nid,ed,fd,nd,Q);
    // 打印解算结果
    if(!ret)
    {
        cout<<"解算失败"<<endl;
    }
    else
    {
        cout<<"解算成功"<<endl;
        PrintVN(dg,eid,nid,ed,fd,nd,Q);
//.........这里部分代码省略.........
开发者ID:hunanhd,项目名称:vns,代码行数:101,代码来源:test.cpp

示例4: vno_test2

void vno_test2()
{
    cout<<"【测试】直接调用vno库进行网络解算..."<<endl;
    // 1) 通风网络
    Digraph dg;
    // 记录节点编号
    NodeIdMap nid(dg);
    //记录分支编号
    EdgeIdMap eid(dg);
    // 3) 分支数据--风阻、计算风量
    VNO_EdgeMap ed(dg,0);
    // 4) 风机数据
    VNO_FanMap fd(dg,0);
    //节点数据
    VNO_NodeMap nd(dg,0);

    // 构建通风网络
    Digraph::Node v1 = dg.addNode();
    Digraph::Node v2 = dg.addNode();
    Digraph::Node v3 = dg.addNode();
    Digraph::Node v4 = dg.addNode();
    Digraph::Node v5 = dg.addNode();
    Digraph::Node v6 = dg.addNode();
    Digraph::Node v7 = dg.addNode();
    Digraph::Node v8 = dg.addNode();
    Digraph::Node v9 = dg.addNode();
    Digraph::Node v10 = dg.addNode();
    Digraph::Node v11 = dg.addNode();
    Digraph::Node v12 = dg.addNode();
    Digraph::Arc e1 = dg.addArc(v1, v2); // v1 -> v2
    Digraph::Arc e2 = dg.addArc(v1, v5); // v2 -> v3
    Digraph::Arc e3 = dg.addArc(v2, v3); // v2 -> v4
    Digraph::Arc e4 = dg.addArc(v3, v4); // v3 -> v5
    Digraph::Arc e5 = dg.addArc(v5, v4); // v4 -> v5
    Digraph::Arc e6 = dg.addArc(v2, v6); // v3 -> v4
    Digraph::Arc e7 = dg.addArc(v3, v7); // v5 -> v6
    Digraph::Arc e8 = dg.addArc(v4, v9); // v1 -> v2
    Digraph::Arc e9 = dg.addArc(v5, v10); // v2 -> v3
    Digraph::Arc e10 = dg.addArc(v6, v7); // v2 -> v4
    Digraph::Arc e11 = dg.addArc(v7, v8); // v3 -> v5
    Digraph::Arc e12 = dg.addArc(v9, v8); // v4 -> v5
    Digraph::Arc e13 = dg.addArc(v9, v10); // v3 -> v4
    Digraph::Arc e14 = dg.addArc(v6, v11); // v5 -> v6
    Digraph::Arc e15 = dg.addArc(v8, v11); // v1 -> v2
    Digraph::Arc e16 = dg.addArc(v10, v11); // v2 -> v3
    Digraph::Arc e17 = dg.addArc(v11, v12); // v2 -> v3

    nid[v1]=1; nid[v2]=2; nid[v3]=3; nid[v4]=4; nid[v5]=5; nid[v6]=6;
    nid[v7]=7; nid[v8]=8; nid[v9]=9; nid[v10]=10; nid[v11]=11; nid[v12]=12;
    eid[e1]=1; eid[e2]=2; eid[e3]=3; eid[e4]=4; eid[e5]=5; eid[e6]=6; eid[e7]=7;
    eid[e8]=8; eid[e9]=9; eid[e10]=10; eid[e11]=11; eid[e12]=12; eid[e13]=13; eid[e14]=14;
    eid[e15]=15; eid[e16]=16; eid[e17]=17;

    ed[e1]=CreateEdgeData(0.08);
    ed[e2]=CreateEdgeData(0.14);
    ed[e3]=CreateEdgeData(0.20);
    ed[e4]=CreateEdgeData(0.65);
    ed[e5]=CreateEdgeData(0.20);
    ed[e6]=CreateEdgeData(1.02);
    ed[e7]=CreateEdgeData(1.0);
    ed[e8]=CreateEdgeData(1.0);
    ed[e9]=CreateEdgeData(1.2);
    ed[e10]=CreateEdgeData(0.3);
    ed[e11]=CreateEdgeData(0.32);
    ed[e12]=CreateEdgeData(0.33);
    ed[e13]=CreateEdgeData(0.30);
    ed[e14]=CreateEdgeData(0.80);
    ed[e15]=CreateEdgeData(0.12);
    ed[e16]=CreateEdgeData(0.34);
    ed[e17]=CreateEdgeData(0.13);

    nd[v1] = CreateNodeData(0,0);
    nd[v2] = CreateNodeData(0,0);
    nd[v3] = CreateNodeData(0,0);
    nd[v4] = CreateNodeData(0,0);
    nd[v5] = CreateNodeData(0,0);
    nd[v6] = CreateNodeData(0,0);
    nd[v7] = CreateNodeData(0,0);
    nd[v8] = CreateNodeData(0,0);
    nd[v9] = CreateNodeData(0,0);
    nd[v10] = CreateNodeData(0,0);
    nd[v11] = CreateNodeData(0,0);
    nd[v12] = CreateNodeData(0,0);

    fd[e17]=CreateFanData(12955.83, 407.38775, -3.8775);

    double q = 250;

    bool ret = VNO(dg, ed, fd, nd, q, 0.0001, 1000);

    //Printvn(dg,eid,nid,ed,fd,nd,q);
    if(!ret)
    {
        cout<<"解算失败"<<endl;
    }
    else
    {
        cout<<"解算成功"<<endl;
        PrintVN(dg,eid,nid,ed,fd,nd,q);

//.........这里部分代码省略.........
开发者ID:hunanhd,项目名称:vns,代码行数:101,代码来源:test.cpp

示例5: constructCondensedGraph

int TarjanHD::constructCondensedGraph(const Digraph& g,
                                      const DoubleArcMap& w,
                                      const NodeNodeMap& mapToOrgG,
                                      const NodeNodeMap& G2T,
                                      const ArcList& sortedArcs,
                                      const IntNodeMap& comp,
                                      const NodeSetVector& components,
                                      const NodeVector& roots,
                                      const int j,
                                      Digraph& c,
                                      DoubleArcMap& ww,
                                      NodeNodeMap& mapCToOrgG,
                                      NodeNodeMap& C2T,
                                      ArcList& newSortedArcs)
{
  // construct the condensed graph:
  // each strongly connected component is collapsed into a single node, and
  // from the resulting sets of multiple arcs retain only those with minimum weight
  lemon::DynArcLookUp<Digraph> lookUpArc(c);
  
  // first construct the nodes
  const size_t numSCC = components.size();
  NodeVector nodesOfC(numSCC, lemon::INVALID);
  for (size_t k = 0; k < numSCC; ++k)
  {
    Node v = nodesOfC[k] = c.addNode();
    
    if (components[k].size() == 1)
    {
      mapCToOrgG[v] = mapToOrgG[*components[k].begin()];
      C2T[v] = G2T[*components[k].begin()];
    }
    else
    {
      mapCToOrgG[v] = lemon::INVALID;
      C2T[v] = roots[k];
    }
  }
  
  // next construct the arcs: O(m) time
  for (ArcListIt arcIt = sortedArcs.begin(); arcIt != sortedArcs.end(); ++arcIt)
  {
    Arc a = *arcIt;
    Node u = g.source(a);
    Node v = g.target(a);
    
    Node uu = nodesOfC[comp[u]];
    Node vv = nodesOfC[comp[v]];
    if (uu != vv)
    {
      Arc aa = lookUpArc(uu, vv);
      if (aa == lemon::INVALID)
      {
        aa = c.addArc(uu, vv);
        newSortedArcs.push_back(aa);
        ww[aa] = w[a];
      }
#ifdef DEBUG
      else
      {
        assert(w[a] > ww[aa]);
      }
#endif
    }
  }
  
  return get_i(newSortedArcs, ww, w[getArcByRank(sortedArcs, j)]);
}
开发者ID:melkebir,项目名称:htarjan,代码行数:68,代码来源:tarjanhd.cpp


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