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


Java TopologicalOrderIterator.next方法代码示例

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


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

示例1: getParameterOrdering

import org.jgrapht.traverse.TopologicalOrderIterator; //导入方法依赖的package包/类
private List<Field> getParameterOrdering(DirectedGraph<Field, DefaultEdge> dependencyGraph) {
	CycleDetector<Field, DefaultEdge> cycleDetector = new CycleDetector<Field, DefaultEdge>(dependencyGraph);
	if (cycleDetector.detectCycles()) {
		throw new RuntimeException("Cyclic dependency detected!");
	} else {
		TopologicalOrderIterator<Field, DefaultEdge> orderIterator;
		Field f;
		orderIterator = new TopologicalOrderIterator<Field, DefaultEdge>(dependencyGraph);
	
		List<Field> output = new ArrayList<>(dependencyGraph.vertexSet().size());

		while (orderIterator.hasNext()) {
			f = orderIterator.next();
			output.add(f);
		}

		return output;
	}
}
 
开发者ID:isse-augsburg,项目名称:minibrass,代码行数:20,代码来源:ConfigurationProvider.java

示例2: build

import org.jgrapht.traverse.TopologicalOrderIterator; //导入方法依赖的package包/类
private void build(Task task, ImmutableList.Builder<RunnableTaskDag> entriesBuilder, ImmutableMap.Builder<TaskId, Task> tasksBuilder)
{
    DefaultDirectedGraph<TaskId, DefaultEdge> graph = new DefaultDirectedGraph<>(DefaultEdge.class);
    worker(graph, task, null, tasksBuilder, Sets.newHashSet());

    CycleDetector<TaskId, DefaultEdge> cycleDetector = new CycleDetector<>(graph);
    if ( cycleDetector.detectCycles() )
    {
        throw new RuntimeException("The Task DAG contains cycles: " + task);
    }

    TopologicalOrderIterator<TaskId, DefaultEdge> orderIterator = new TopologicalOrderIterator<>(graph);
    while ( orderIterator.hasNext() )
    {
        TaskId taskId = orderIterator.next();
        Set<DefaultEdge> taskIdEdges = graph.edgesOf(taskId);
        Set<TaskId> processed = taskIdEdges
            .stream()
            .map(graph::getEdgeSource)
            .filter(edge -> !edge.equals(taskId) && !edge.getId().equals(""))
            .collect(Collectors.toSet());
        entriesBuilder.add(new RunnableTaskDag(taskId, processed));
    }
}
 
开发者ID:NirmataOSS,项目名称:workflow,代码行数:25,代码来源:RunnableTaskDagBuilder.java

示例3: orderDag

import org.jgrapht.traverse.TopologicalOrderIterator; //导入方法依赖的package包/类
private List<Handler<? extends Intent<? extends Resolution>>> orderDag(DirectedAcyclicGraph<Handler<? extends Intent<? extends Resolution>>, DefaultEdge> dag)
{
	TopologicalOrderIterator<Handler<? extends Intent<? extends Resolution>>, DefaultEdge> topOrder = new TopologicalOrderIterator<>(dag);

	List<Handler<? extends Intent<? extends Resolution>>> ordered = new ArrayList<>();
	while(topOrder.hasNext()) {
		Handler<? extends Intent<? extends Resolution>> handler = topOrder.next();
		ordered.add(handler);
		logger.debug("Added [{}] to ordered handler list", handler);
	}
	return ordered;
}
 
开发者ID:EngineerBetter,项目名称:cf-converger,代码行数:13,代码来源:HardcodedOrderedHandlerBuilder.java

示例4: testCycleDetection

import org.jgrapht.traverse.TopologicalOrderIterator; //导入方法依赖的package包/类
public void testCycleDetection() {
    DefaultDirectedGraph<String, Object> g = new DefaultDirectedGraph<String, Object>(Object.class);

    // Add vertices, e.g. equations.
    g.addVertex("A");
    g.addVertex("B");
    g.addEdge("A", "B");

    g.addVertex("D");
    g.addVertex("A");
    g.addEdge("D", "A");

    g.addVertex("B");
    g.addVertex("C");
    g.addEdge("B", "C");

    g.addVertex("G");
    g.addVertex("H");
    g.addEdge("G", "H");

    g.addVertex("C");
    g.addVertex("D");
    g.addEdge("C", "D");

    System.out.println(g.toString());

    // Are there cycles in the dependencies.
    CycleDetector<String, Object> cycleDetector = new CycleDetector<String, Object>(g);
    // Cycle(s) detected.
    if (cycleDetector.detectCycles()) {

        System.out.println("Cycles detected.");

        // Get all vertices involved in cycles.
        Set<String> cycleVertices = cycleDetector.findCycles();

        // Loop through vertices trying to find disjoint cycles.
        while (!cycleVertices.isEmpty()) {
            System.out.println("Cycle:");

            // Get a vertex involved in a cycle.
            Iterator<String> iterator = cycleVertices.iterator();
            String cycle = iterator.next();

            // Get all vertices involved with this vertex.
            Set<String> subCycle = cycleDetector.findCyclesContainingVertex(cycle);
            for (String sub : subCycle) {
                System.out.println("   " + sub);
                // Remove vertex so that this cycle is not encountered
                // again.
                cycleVertices.remove(sub);
            }
        }
    }

    // No cycles.  Just output properly ordered vertices.
    else {
        TopologicalOrderIterator<String, Object> orderIterator = new TopologicalOrderIterator<String, Object>(g);
        System.out.println("\nOrdering:");
        while (orderIterator.hasNext()) {
            String v = orderIterator.next();
            System.out.println(v);
        }
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:66,代码来源:TestCycleDetect.java

示例5: testClassfication

import org.jgrapht.traverse.TopologicalOrderIterator; //导入方法依赖的package包/类
@Test
public void testClassfication() {
    Automaton a = new RegExp("az+g(at|yg)").toAutomaton();

    Gnfa g = Converter.INSTANCE.getGnfaFromAutomaton(a);

    StateEliminator.INSTANCE.handleTrivialCases(g);


    TopologicalOrderIterator<State, Transition> topOrder =
            new TopologicalOrderIterator(g);

    while (topOrder.hasNext()) {
        State next = topOrder.next();
        LOGGER.debug(next.getDotLabel());
    }

    Classifier.INSTANCE.classify(g);
    LOGGER.debug(g.toDot());

}
 
开发者ID:julianthome,项目名称:autorex,代码行数:22,代码来源:TestClassification.java

示例6: getExtensionList

import org.jgrapht.traverse.TopologicalOrderIterator; //导入方法依赖的package包/类
@Override
public ExtensionList getExtensionList() {
    // Gets the list of all extensions
    List<ExtensionFeatureDescription> extensionFeatures = applicationContext.getBeansOfType(ExtensionFeature.class).values().stream()
            .map(ExtensionFeature::getFeatureDescription)
            .sorted(Comparator.comparing(ExtensionFeatureDescription::getName))
            .collect(Collectors.toList());

    // Computing the dependencies

    DefaultDirectedGraph<String, DefaultEdge> g = new DefaultDirectedGraph<>(DefaultEdge.class);

    // Adds the extensions as vertexes
    extensionFeatures.forEach(extensionFeatureDescription ->
                    g.addVertex(extensionFeatureDescription.getId())
    );

    // Adds the dependencies as edges
    extensionFeatures.forEach(source ->
            source.getOptions().getDependencies().forEach(target ->
                            g.addEdge(target, source.getId())
            ));

    // Cycle detection
    CycleDetector<String, DefaultEdge> cycleDetector = new CycleDetector<>(g);

    // If there are cycles
    if (cycleDetector.detectCycles()) {
        List<List<String>> cycles = new ArrayList<>();
        Set<String> cycleVertices = cycleDetector.findCycles();
        while (!cycleVertices.isEmpty()) {
            List<String> subCycleList = new ArrayList<>();
            // Get a vertex involved in a cycle.
            Iterator<String> iterator = cycleVertices.iterator();
            String cycle = iterator.next();
            // Get all vertices involved with this vertex.
            Set<String> subCycle = cycleDetector.findCyclesContainingVertex(cycle);
            for (String sub : subCycle) {
                subCycleList.add(sub);
                // Remove vertex so that this cycle is not encountered again.
                cycleVertices.remove(sub);
            }
            // Adds to the list of cycles
            cycles.add(subCycleList);
        }
        // Throws an exception
        throw new ExtensionCycleException(cycles);
    }

    // No cycle
    else {

        // Topological order to collect the leaf dependencies first
        // See https://en.wikipedia.org/wiki/Dependency_graph
        TopologicalOrderIterator<String, DefaultEdge> orderIterator =
                new TopologicalOrderIterator<>(g);

        // Order to extensions to load
        List<String> order = new ArrayList<>();
        while (orderIterator.hasNext()) {
            String extension = orderIterator.next();
            order.add(extension);
        }

        // Indexation of extensions per ID
        Map<String, ExtensionFeatureDescription> index = extensionFeatures.stream().collect(Collectors.toMap(
                ExtensionFeatureDescription::getId,
                Function.identity()
        ));

        // OK
        return new ExtensionList(
                order.stream()
                        .map(index::get)
                        .collect(Collectors.toList())
        );
    }
}
 
开发者ID:nemerosa,项目名称:ontrack,代码行数:79,代码来源:ExtensionManagerImpl.java

示例7: displayCyclesInfo

import org.jgrapht.traverse.TopologicalOrderIterator; //导入方法依赖的package包/类
public static void displayCyclesInfo(
		DefaultDirectedGraph<String, DefaultEdge> g) {
	// Are there cycles in the dependencies.
      CycleDetector<String, DefaultEdge> cycleDetector;
      cycleDetector = new CycleDetector<String, DefaultEdge>(g);
      // Cycle(s) detected.
      if (cycleDetector.detectCycles()) {
         Iterator<String> iterator;
         Set<String> cycleVertices;
         Set<String> subCycle;
         String cycle;

         System.out.println("Cycles detected.");

         // Get all vertices involved in cycles.
         cycleVertices = new HashSet<String>(cycleDetector.findCycles());
         System.out.println("cv: " + cycleVertices);
         
         for (String x1 : cycleVertices) {
        	 System.out.println("SUBCYC: " + x1 + "\n" + cycleDetector.findCyclesContainingVertex(x1));
         }
         
         if (true) {
        	 return;
         }

         // Loop through vertices trying to find disjoint cycles.
         while (! cycleVertices.isEmpty()) {
            System.out.println("Cycle:");

            // Get a vertex involved in a cycle.
            iterator = cycleVertices.iterator();
            cycle = iterator.next();

            // Get all vertices involved with this vertex.
            subCycle = cycleDetector.findCyclesContainingVertex(cycle);
            for (String sub : subCycle) {
               System.out.println("   " + sub);
               // Remove vertex so that this cycle is not encountered
               // again.
               cycleVertices.remove(sub);
            }
         }
      }

      // No cycles.  Just output properly ordered vertices.
      else {
         String v;
         TopologicalOrderIterator<String, DefaultEdge> orderIterator;

         orderIterator =
            new TopologicalOrderIterator<String, DefaultEdge>(g);
         System.out.println("\nOrdering:");
         while (orderIterator.hasNext()) {
            v = orderIterator.next();
            System.out.println(v);
         }
      }
}
 
开发者ID:gdela,项目名称:socomo-maven-plugin,代码行数:60,代码来源:JGraphTDemo.java


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