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


Java Graph.simpleCycles方法代码示例

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


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

示例1: testNoCycles

import org.aikodi.rejuse.graph.Graph; //导入方法依赖的package包/类
@Test
public void testNoCycles() {
  Graph<Integer> graph = new Graph<>(new UniEdgeFactory<>());
  for(int i = 0; i < 10; i++) {
    graph.addNode(i);
  }
  for(int i = 0; i < 9; i++) {
    graph.addEdge(i, i+1);
  }
  List<Path<Integer>> simpleCycles = graph.simpleCycles();
  assertTrue(simpleCycles.isEmpty());
  graph.addEdge(8, 0);
  simpleCycles = graph.simpleCycles();
  assertEquals(1,simpleCycles.size());
  
  graph.addEdge(5, 2);
  simpleCycles = graph.simpleCycles();
  assertEquals(2,simpleCycles.size());
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:20,代码来源:TestGraph.java

示例2: testCycles

import org.aikodi.rejuse.graph.Graph; //导入方法依赖的package包/类
@Test
public void testCycles() {
	Graph<Integer> graph = new Graph<>(new UniEdgeFactory<>());
	int size = 9;
  for(int i = 0; i < size; i++) {
    graph.addNode(i);
  }
  for(int i = 0; i < size - 1; i++) {
    graph.addEdge(i, i + 1);
  }
  graph.addEdge(size - 1, 0);
  List<Path<Integer>> simpleCycles = graph.simpleCycles();
  assertEquals(1, simpleCycles.size());
}
 
开发者ID:markovandooren,项目名称:rejuse,代码行数:15,代码来源:TestGraph.java

示例3: write

import org.aikodi.rejuse.graph.Graph; //导入方法依赖的package包/类
public void write(Graph<Type> graph, Writer stream) throws IOException {
  		List<Path<Type>> simpleCycles = graph.simpleCycles();
  		Set<Type> involvedInCycle = simpleCycles.stream().flatMap(p -> p.nodes().stream().map(x -> x.object())).collect(Collectors.toSet());
//  		Set<Edge<Type>> cycleEdges = simpleCycles.stream().flatMap(p -> p.getEdges().stream()).collect(Collectors.toSet());
  		stream.write("digraph G {\n");
  		writeNodes(graph,stream, involvedInCycle);
  		writeEdges(graph,stream, involvedInCycle);
  		stream.write("}\n");
  	}
 
开发者ID:markovandooren,项目名称:jnome,代码行数:10,代码来源:JavaDependencyAnalyzer.java


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