• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TopologicalOrderIterator类的典型用法和代码示例

未分类 4次浏览

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

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

示例1: getParameterOrdering

点赞 3

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: getSpeciesInHierarchicalOrder

点赞 3

import org.jgrapht.traverse.TopologicalOrderIterator; //导入依赖的package包/类
private Iterable<SpeciesDescription> getSpeciesInHierarchicalOrder(final ModelDescription model) {
	final DirectedGraph<SpeciesDescription, Object> hierarchy = new SimpleDirectedGraph<>(Object.class);
	final DescriptionVisitor visitor = new DescriptionVisitor<SpeciesDescription>() {

		@Override
		public boolean visit(final SpeciesDescription desc) {
			if (desc instanceof ModelDescription)
				return true;
			final SpeciesDescription sd = desc.getParent();
			if (sd == null || sd == desc)
				return false;
			hierarchy.addVertex(desc);
			if (!sd.isBuiltIn()) {
				hierarchy.addVertex(sd);
				hierarchy.addEdge(sd, desc);
			}
			return true;
		}
	};
	model.visitAllSpecies(visitor);
	return () -> new TopologicalOrderIterator<>(hierarchy);
}
 

开发者ID:gama-platform,
项目名称:gama,
代码行数:23,
代码来源:ModelAssembler.java

示例3: sort

点赞 3

import org.jgrapht.traverse.TopologicalOrderIterator; //导入依赖的package包/类
public List<String> sort(List<Class<?>> classes) throws OrderSortCycleException {
    List<String> result = new ArrayList<>();
    SimpleDirectedGraph<String, DefaultEdge> graph = new SimpleDirectedGraph<>(DefaultEdge.class);
    
    for (OrderConstraint orderConstraint : getConstraints(classes)) {
        graph.addVertex(orderConstraint.getFirst());
        graph.addVertex(orderConstraint.getSecond());
        
        graph.addEdge(orderConstraint.getFirst(), orderConstraint.getSecond());
    }
    
    CycleDetector<String, DefaultEdge> cycleDetector = new CycleDetector<>(graph);
    if(!cycleDetector.detectCycles()) {
                    for (TopologicalOrderIterator<String, DefaultEdge> iterator = new TopologicalOrderIterator<>(graph); iterator.hasNext();) {
            result.add(iterator.next());
        }
    } else {
        String cycles = Joiner.on(", ").join(cycleDetector.findCycles());
        
        throw new OrderSortCycleException("The given order constraints contain (at least one) cycle. Cycles can only "
                + "be caused by static references because we have single inherintance only in Java (involved classes: '" + cycles + "').");
    }

    return result;
}
 

开发者ID:janScheible,
项目名称:knorxx,
代码行数:26,
代码来源:OrderSorter.java

示例4: build

点赞 3

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

示例5: sortChanges

点赞 2

import org.jgrapht.traverse.TopologicalOrderIterator; //导入依赖的package包/类
/**
 * Sorts the graph to provide a consistent topological ordering.
 *
 * @param graph      The input graph - all vertices in the graph will be returned in the output list
 * @param comparator The comparator on which to order the vertices to guarantee a consistent topological ordering
 */
public <T> ImmutableList<T> sortChanges(final DirectedGraph<T, DefaultEdge> graph, Comparator<? super T> comparator) {
    if (graph.vertexSet().isEmpty()) {
        return Lists.immutable.empty();
    }

    GraphUtil.validateNoCycles(graph);

    TopologicalOrderIterator<T, DefaultEdge> iterator = getTopologicalOrderIterator(graph, comparator);

    return Lists.immutable.withAll(IteratorUtils.toList(iterator));
}
 

开发者ID:goldmansachs,
项目名称:obevo,
代码行数:18,
代码来源:GraphSorter.java

示例6: orderDag

点赞 2

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


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)