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


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

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


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

示例1: createTinyDigraph

Digraph< int > createTinyDigraph( void )
{
	Array< int > edges = {
		0, 1,
		0, 5,
		0, 6,
		2, 0,
		2, 3,
		3, 5,
		5, 4,
		6, 4,
		6, 9,
		7, 6,
		8, 7,
		9, 10,
		9, 11,
		9, 12,
		11, 12,
	};

	Digraph< int > d;
	for ( int i = 0; i < edges.size() / 2; i++ ) {
		d.addEdge( edges[ i * 2 ], edges[ i * 2 + 1 ] );
	}

	return d;
}
开发者ID:hhsaez,项目名称:crimild,代码行数:27,代码来源:DigraphTest.cpp

示例2: reverse

Digraph* Digraph::reverse() {
	Digraph* dg = new Digraph(n(), e());
	for (int v = 0; v < n(); v++)
		for (int w = first(v); w < n(); w = next(v, w))
			dg->addEdge(w, v, getWeight(v, w));
	return dg;
}
开发者ID:therdes,项目名称:DataStructure,代码行数:7,代码来源:Digraph.cpp

示例3: main

int main()
{
  int V = 4;

  Digraph *G = new Digraph(V);

  BasicBlock a, b, c, d;
  a.i = 0;
  b.i = 1;
  c.i = 2;
  d.i = 3;

  G->addEdge(&a, &b);
  G->addEdge(&a, &c);
  G->addEdge(&c, &b);
  G->addEdge(&a, &d);

  DirectedDFS DD(G, &c);

  printf("%d,%d,%d,%d\n", DD.marked(&a), DD.marked(&b), DD.marked(&c), DD.marked(&d));

  TransitiveClosure TC(G);

  for (Digraph::GraphIteratorTy I = G->begin(), E = G->end(); I != E; ++I) {
    BasicBlock *A = I->first;
    
    for (Digraph::GraphIteratorTy J = G->begin(), F = G->end(); J!= F; ++J) {
      BasicBlock *B = J->first;

      if (TC.reachable(A, B)) {
        std::cout << A->i << " reaches " << B->i << std::endl;
      }
    }
  }

  delete G;

  return 0;
}
开发者ID:JiadingGai,项目名称:LLVMPractice,代码行数:39,代码来源:Digraph.cpp

示例4: reverseGraph

  Digraph* reverseGraph()
  {
    Digraph *R = new Digraph(V);
    
    for (GraphIteratorTy I = begin(), E = end(); I != E; ++I) {
      BasicBlock *A = I->first;
      std::vector<BasicBlock *> B = I->second;

      for (AdjIteratorTy II = B.begin(), EE = B.end(); II != EE; ++I) {
        R->addEdge(*II, A);
      }
    }

    return R;
  }
开发者ID:JiadingGai,项目名称:LLVMPractice,代码行数:15,代码来源:Digraph.cpp


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