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


Java BreadthFirstIterator类代码示例

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


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

示例1: getLargestConnectedComponent

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
public Set<Integer> getLargestConnectedComponent()
{
	Set<Integer> largestConnectedSet = new TreeSet();
	Set<Integer> connectedSet;
	List<Integer> vs = new ArrayList(vertexSet());
	
	while(vs.size() > 0)
	{
		connectedSet = new TreeSet();
		BreadthFirstIterator<Integer, MyEdge> bfsi = new BreadthFirstIterator<Integer, MyEdge>(this, vs.get(0));
		while(bfsi.hasNext())
			connectedSet.add(bfsi.next());
		if(connectedSet.size() > largestConnectedSet.size())
			largestConnectedSet = connectedSet;
		vs.removeAll(connectedSet);
	}
	
	return largestConnectedSet;
}
 
开发者ID:gaborgulyas,项目名称:salab,代码行数:20,代码来源:MyGraph.java

示例2: getSubclasses

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
public Set<String> getSubclasses(String className) {
	String classNameWithDots = ResourceList.getClassNameFromResourcePath(className);

	if (subclassCache.containsKey(classNameWithDots))
		return subclassCache.get(classNameWithDots);

	if (!inheritanceGraph.containsVertex(classNameWithDots)) {
           LoggingUtils.logWarnAtMostOnce(logger, "Class not in inheritance graph: " + classNameWithDots);
		return new LinkedHashSet<>();
	}

	// TreeSet so that classes are sorted by name and thus deterministic across platforms
	Set<String> result = new TreeSet<String>();
	BreadthFirstIterator<String, DefaultEdge> bfi = new BreadthFirstIterator<String, DefaultEdge>(
	        inheritanceGraph, classNameWithDots);
	while (bfi.hasNext()) {
		result.add(bfi.next());
	}
	subclassCache.put(classNameWithDots, result);
	return result;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:22,代码来源:InheritanceTree.java

示例3: getSuperclasses

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
public Set<String> getSuperclasses(String className) {
	String classNameWithDots = ResourceList.getClassNameFromResourcePath(className);
	if (!inheritanceGraph.containsVertex(classNameWithDots)) {
		LoggingUtils.logWarnAtMostOnce(logger, "Class not in inheritance graph: " + classNameWithDots);
		return new LinkedHashSet<>();
	}
	EdgeReversedGraph<String, DefaultEdge> reverseGraph = new EdgeReversedGraph<String, DefaultEdge>(
	        inheritanceGraph);

	// TreeSet so that classes are sorted by name and thus deterministic across platforms
	Set<String> result = new TreeSet<>();
	BreadthFirstIterator<String, DefaultEdge> bfi = new BreadthFirstIterator<String, DefaultEdge>(
	        reverseGraph, classNameWithDots);
	while (bfi.hasNext()) {
		result.add(bfi.next());
	}
	return result;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:19,代码来源:InheritanceTree.java

示例4: getOrderedSuperclasses

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
public List<String> getOrderedSuperclasses(String className) {
	String classNameWithDots = ResourceList.getClassNameFromResourcePath(className);
	if (!inheritanceGraph.containsVertex(classNameWithDots)) {
		LoggingUtils.logWarnAtMostOnce(logger, "Class not in inheritance graph: " + classNameWithDots);
		return new LinkedList<>();
	}
	EdgeReversedGraph<String, DefaultEdge> reverseGraph = new EdgeReversedGraph<String, DefaultEdge>(
	        inheritanceGraph);
	List<String> orderedList = new LinkedList<>();
	BreadthFirstIterator<String, DefaultEdge> bfi = new BreadthFirstIterator<String, DefaultEdge>(
	        reverseGraph, classNameWithDots);
	while (bfi.hasNext()) {
		orderedList.add(bfi.next());
	}
	return orderedList;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:17,代码来源:InheritanceTree.java

示例5: findResources

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
/**
 * Find the resources in {@link #resourcesGraph} matching the given {@code query}.
 *
 * @param query a location eventually containing wildcards
 * @param locationResolver the {@link LocationResolver} to perform the matching of graph nodes against the given
 *            {@code query}
 * @return an unmodifiable list of {@link Resources} that match the given {@code query}
 */
public List<Resource<L>> findResources(L query, LocationResolver<L> locationResolver) {
    graphLockRead.lock();
    try {
        List<Resource<L>> result = new ArrayList<Resource<L>>();
        GraphIterator<Resource<L>, DefaultEdge> it = new BreadthFirstIterator<Resource<L>, DefaultEdge>(
                this.resourcesGraph);
        while (it.hasNext()) {
            Resource<L> resource = it.next();
            if (locationResolver.matches(query, resource.getLocation())) {
                result.add(resource);
            }
        }
        return Collections.unmodifiableList(result);
    } finally {
        graphLockRead.unlock();
    }
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:26,代码来源:ResourceManager.java

示例6: graphToJt

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
private JunctionTree graphToJt (UndirectedGraph g)
{
  JunctionTree jt = new JunctionTree (g.vertexSet ().size ());
  Object root = g.vertexSet ().iterator ().next ();
  jt.add (root);

  for (Iterator it1 = new BreadthFirstIterator(g, root); it1.hasNext ();) {
    Object v1 = it1.next ();
    for (Iterator it2 = GraphHelper.neighborListOf(g, v1).iterator (); it2.hasNext ();) {
      Object v2 = it2.next ();
      if (jt.getParent (v1) != v2) {
        jt.addNode (v1, v2);
      }
    }
  }
  return jt;
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:18,代码来源:JunctionTreeInferencer.java

示例7: connectedSetOf

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
public Set<InfoVertex<T, C>> connectedSetOf(InfoVertex<T, C> vertex) {
	Set<InfoVertex<T, C>> connectedSet = vertexToConnectedSet.get(vertex);

	if (connectedSet == null) {
		connectedSet = new HashSet<InfoVertex<T, C>>();

		final BreadthFirstIterator<InfoVertex<T, C>, DependencyEdge> i = new BreadthFirstIterator<InfoVertex<T, C>, DependencyEdge>(
				graph, vertex);

		while (i.hasNext()) {
			connectedSet.add(i.next());
		}

		vertexToConnectedSet.put(vertex, connectedSet);
	}

	return connectedSet;
}
 
开发者ID:highsource,项目名称:jsonix-schema-compiler,代码行数:19,代码来源:ModelInfoGraphAnalyzer.java

示例8: traverseGraph

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
private void traverseGraph(DirectedGraph<V, E> graph, V startVertex, GraphVisitor<V, E> visitor, boolean depthFirst) {
	if (startVertex != null && !containsVertex(startVertex)) {
		return;
	}
	TraversalListener<V, E> listener = null;
	GraphIterator<V, E> iterator = null;
	if (depthFirst) {
		listener = new DepthFirstTraversalListener<V, E>(graph, visitor);
		iterator = new DepthFirstIterator<V, E>(graph, startVertex);
	} else {
		listener = new BreadthFirstTraversalListener<V, E>(visitor);
		iterator = new BreadthFirstIterator<V, E>(graph, startVertex);
	}
	iterator.addTraversalListener(listener);
	while (iterator.hasNext() && !visitor.finished()) {
		iterator.next();
	}
}
 
开发者ID:andreasbehnke,项目名称:javaan,代码行数:19,代码来源:ExtendedDirectedGraph.java

示例9: stopDirty

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
private void stopDirty()
{
   BreadthFirstIterator<AddonVertex, AddonDependencyEdge> iterator = new BreadthFirstIterator<AddonVertex, AddonDependencyEdge>(
            graph.getGraph());

   iterator.addTraversalListener(new TraversalListenerAdapter<AddonVertex, AddonDependencyEdge>()
   {
      @Override
      public void vertexTraversed(VertexTraversalEvent<AddonVertex> event)
      {
         if (event.getVertex().isDirty())
            lifecycleManager.stopAddon(event.getVertex().getAddon());
      };
   });

   while (iterator.hasNext())
      iterator.next();
}
 
开发者ID:forge,项目名称:furnace,代码行数:19,代码来源:MasterGraphChangeHandler.java

示例10: stopRemoved

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
private void stopRemoved()
{
   if (lastMasterGraph != null)
   {
      BreadthFirstIterator<AddonVertex, AddonDependencyEdge> iterator = new BreadthFirstIterator<AddonVertex, AddonDependencyEdge>(
               lastMasterGraph.getGraph());

      iterator.addTraversalListener(new TraversalListenerAdapter<AddonVertex, AddonDependencyEdge>()
      {
         @Override
         public void vertexTraversed(VertexTraversalEvent<AddonVertex> event)
         {
            if (event.getVertex().isDirty())
               lifecycleManager.stopAddon(event.getVertex().getAddon());
         };
      });

      while (iterator.hasNext())
         iterator.next();
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:22,代码来源:MasterGraphChangeHandler.java

示例11: sortTasks

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
/**
 * After this, the tasks will be in priority order in "sorted"
 * Generates priorities by topological sort from the source, and then reversing
 */
private void sortTasks() {
	BreadthFirstIterator<TaskDefinition, Edge> orderIterator = 
			new BreadthFirstIterator<TaskDefinition, Edge>(graph);
	while (orderIterator.hasNext()) {
		sorted.add(orderIterator.next());
	}
	Collections.reverse(sorted);
}
 
开发者ID:PERSISTLab,项目名称:mayfly-lang,代码行数:13,代码来源:TaskGraph.java

示例12: getObjectChangesRequiringRecompilation

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
/**
 * allow for use cases to redeploy changes that require recompiling
 * e.g. to add db objects to the change list to facilitate cases where it depends on another SP that is
 * changing, and so the dependent SP needs to get re-created also
 */
private MutableSet<Change> getObjectChangesRequiringRecompilation(ChangeType changeType, RichIterable<Change> fromSourceList, MutableCollection<Change> changedObjects) {
    if (fromSourceList.isEmpty()) {
        return Sets.mutable.empty();
    }
    // do not log errors as info or above here when creating the graph as we know that we don't have the full graph
    LOG.debug("START BLOCK: Ignore any 'Invalid change found?' errors in this block of code");
    DirectedGraph<Change, DefaultEdge> graph = enricher.createDependencyGraph(fromSourceList.select(Predicates.attributeEqual(Change.TO_CHANGE_TYPE, changeType)), false);
    LOG.debug("END BLOCK: Ignore any 'Invalid change found?' errors in this block of code");

    MutableCollection<Change> changesForType = changedObjects.select(
            Predicates.attributeEqual(Change.TO_CHANGE_TYPE, changeType));
    MutableMap<String, Change> changesForTypeMap = changesForType.toMap(
            Change.objectName(), Functions.<Change>getPassThru());

    MutableSet<Change> newChangesToAdd = HashingStrategySets.mutable.of(HashingStrategies.fromFunction(Change.objectName()));
    for (Change change : changesForType) {
        BreadthFirstIterator<Change, DefaultEdge> dependencyIterator = new BreadthFirstIterator<Change, DefaultEdge>(graph, change);

        MutableSet<Change> dependencies = ListAdapter.adapt(
                IteratorUtils.toList(dependencyIterator)).toSet();
        dependencies.remove(change);  // the iterator result includes the self; we can remove this

        for (Change changeToAddBack : dependencies) {
            if (!changesForTypeMap.containsKey(changeToAddBack.getObjectName())) {
                changeToAddBack.setReason("Re-deploying this object due to change in dependent object ["
                        + change.getObjectName() + "]");
                newChangesToAdd.add(changeToAddBack);
            }
        }
    }
    return newChangesToAdd;
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:38,代码来源:RerunnableChangeTypeCommandCalculator.java

示例13: createSubGraph

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
private MST<T> createSubGraph(SimpleWeightedGraph<MSTNode<T>, DefaultWeightedEdge> mst,
    MSTNode<T> startNode) throws Exception {
  List<MSTNode<T>> containedNodes = new ArrayList<>();
  GraphIterator<MSTNode<T>, DefaultWeightedEdge> iterator = new BreadthFirstIterator<>(mst,
      startNode);
  while (iterator.hasNext()) {
    MSTNode<T> next = iterator.next();
    containedNodes.add(next);
  }
  MST<T> newSubGraph = new MST<T>(hct);
  for (MSTNode<T> node : containedNodes) {
    newSubGraph.add(node.getValue());
  }
  return newSubGraph;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:16,代码来源:MST.java

示例14: allImportsOf

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
/**
 * @see msi.gama.lang.gaml.indexer.IModelIndexer#allImportsOf(org.eclipse.emf.common.util.URI)
 */
public static Iterator<URI> allImportsOf(final URI uri) {
	if (!indexes(uri))
		return Iterators.emptyIterator();
	final Iterator<URI> result = new BreadthFirstIterator(index, GamlResourceServices.properlyEncodedURI(uri));
	result.next(); // to eliminate the uri
	return result;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:11,代码来源:GamlResourceIndexer.java

示例15: getResourcesBreadthFirst

import org.jgrapht.traverse.BreadthFirstIterator; //导入依赖的package包/类
/**
 * Returns an immutable {@link List} of all {@link Resource}s contained in {@link #resourcesGraph} in breadth-first
 * order.
 *
 * @return the list of all {@link Resource}s
 */
public List<Resource<L>> getResourcesBreadthFirst() {
    graphLockRead.lock();
    try {
        List<Resource<L>> result = new ArrayList<Resource<L>>();

        Set<Resource<L>> roots = getRootResources();
        if (roots.isEmpty()) {
            return Collections.emptyList();
        }

        // loop over each root resource and traverse their tree hierarchy breadth-first
        // roots.forEach(root -> new BreadthFirstIterator<>(ResourceManager.this.resourcesGraph, root)
        //     .forEachRemaining(it -> result.add(it)));
        for (Resource<L> root : roots) {
            GraphIterator<Resource<L>, DefaultEdge> it = new BreadthFirstIterator<Resource<L>, DefaultEdge>(
                    ResourceManager.this.resourcesGraph, root);
            while (it.hasNext()) {
                result.add(it.next());
            }
        }

        return Collections.unmodifiableList(result);
    } finally {
        graphLockRead.unlock();
    }
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:33,代码来源:ResourceManager.java


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