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


Java BreadthFirstIterator.hasNext方法代码示例

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


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

示例6: 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

示例7: 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

示例8: 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

示例9: testBFS

import org.jgrapht.traverse.BreadthFirstIterator; //导入方法依赖的package包/类
/**
 * Rigourous Test :-)
 */
public void testBFS() {

	DefaultDirectedGraph<Vertex, Double> graph = new DefaultDirectedGraph<Vertex, Double>(
			Double.class);
	Vertex v = null;
	for (int i = 0; i < this.numOfVertices; i++) {
		v = new Vertex("v" + i);
		graph.addVertex(v);
	}
	
	// use last vertex as start point of search
	Vertex lastVertex = v;

	Set<Vertex> vertices = graph.vertexSet();

	// add edges to graph
	Random rand = new Random();
	Double nextEdge = 0.0;
	for (Vertex start : vertices)
		for (Vertex end : vertices)
			if (!start.equals(end) && !graph.containsEdge(start, end)) {
				nextEdge = rand.nextDouble();
				if (nextEdge > 0.9)
					graph.addEdge(start, end, nextEdge);
			}

	System.out.println("Vertices: " + vertices.size());
	System.out.println("Edges: " + graph.edgeSet().size());

	BreadthFirstIterator<Vertex, Double> bfsIter = new BreadthFirstIterator<Vertex, Double>(
			graph, lastVertex);

	BFS<Double> bfs = new BFS<Double>(graph);
	Vertex[] bfsResult = bfs.breadthFirstTree(lastVertex);

	for (int i = 0; i < this.numOfVertices && bfsIter.hasNext(); i++) {
		System.out.println(bfsResult[i] + " " + bfsIter.next());
	}

}
 
开发者ID:yubinbai,项目名称:javatemplates,代码行数:44,代码来源:BFSTest.java


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