• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java KruskalMinimumSpanningTree类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: printSpanningTree

import org.jgrapht.alg.KruskalMinimumSpanningTree; //导入依赖的package包/类
protected void printSpanningTree()
{
	logger.info("In Spanning Tree " );
	KruskalMinimumSpanningTree<DBCMVertex, DBCMEdge> ins = new KruskalMinimumSpanningTree<DBCMVertex, DBCMEdge>(graph);
	
	logger.info("Number of vertices " + graph.vertexSet().size());
	logger.info(" Edges  " + ins.getEdgeSet().size());
	Iterator <DBCMEdge> csIterator = ins.getEdgeSet().iterator();
	int count = 0;
	while(csIterator.hasNext())
	{
			DBCMEdge vert = csIterator.next();
			//writeStatus("Set " + count + ">>>> " + vert.getProperty(Constants.EDGE_NAME));
			//logger.info("Set " + count + ">>>> " + vert.getProperty(Constants.EDGE_NAME));
	}
	count++;
}
 
开发者ID:SEMOSS,项目名称:semoss,代码行数:18,代码来源:GraphPlaySheet.java


示例2: actionPerformed

import org.jgrapht.alg.KruskalMinimumSpanningTree; //导入依赖的package包/类
/**
 * Method actionPerformed.
 *
 * @param e ActionEvent
 */
@Override
public void actionPerformed( ActionEvent e ) {

	// gets the view from the playsheet
	// gets the jGraphT graph
	// runs the kruskal on it
	// Creates the edges and sets it on the edge painter
	// repaints it
	// I cannot add this to the interface because not all of them will be forced to have it
	// yes, which means the menu cannot be generic too - I understand
	logger.debug( "Getting the base graph" );
	Graph graph = ps.asSimpleGraph();
	KruskalMinimumSpanningTree<SEMOSSVertex, SEMOSSEdge> kmst
			= new KruskalMinimumSpanningTree<>( graph );

	EdgeStrokeTransformer tx = (EdgeStrokeTransformer) ps.getView().getRenderContext()
			.getEdgeStrokeTransformer();
	tx.setSelected( kmst.getEdgeSet() );

	// repaint it
	ps.getView().repaint();
	int originalSize = ps.getVisibleGraph().getEdgeCount();
	int shortestPathSize = kmst.getEdgeSet().size();
	GuiUtility.showMessage( "Minimum Spanning Tree uses " + shortestPathSize
			+ " edges out of " + originalSize + " original edges" );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:32,代码来源:MSTPopupMenuListener.java


示例3: generateMinimalSpanningTree

import org.jgrapht.alg.KruskalMinimumSpanningTree; //导入依赖的package包/类
public Multigraph<GameRoom, NoDuplicateEdge> generateMinimalSpanningTree(Array<GameCell> cells, float remainingEdgesMultiplier) {
        Gdx.app.log("GraphGenerator", "----------------- Generating minimal spanning tree -----------------");

        Array<GameRoom> rooms = GameMap.extractRooms(cells);
        ShortArray trianglesIndices = generateTrianglesIndices(cells);

        Multigraph<GameRoom, NoDuplicateEdge> graph = getGraphFromTriangulation(trianglesIndices, rooms);

        Set<NoDuplicateEdge> minEdges = new KruskalMinimumSpanningTree(graph).getMinimumSpanningTreeEdgeSet();
//        Set<NoDuplicateEdge> minEdges = new PrimMinimumSpanningTree(graph).getMinimumSpanningTreeEdgeSet();

        minimumSpanningTreeFromGraph(graph, minEdges, remainingEdgesMultiplier);

        Gdx.app.log("GraphGenerator", "  --> Graph is now a minimal spanning tree. Edge count: " + graph.edgeSet().size());

        return graph;
    }
 
开发者ID:LeonardBesson,项目名称:DunGen,代码行数:18,代码来源:GraphGenerator.java


示例4: getMST

import org.jgrapht.alg.KruskalMinimumSpanningTree; //导入依赖的package包/类
public KruskalMinimumSpanningTree<Room, Hallway> getMST() {
    return new KruskalMinimumSpanningTree<Room, Hallway>(getFullGraph());
}
 
开发者ID:horschi,项目名称:OpenTeufel,代码行数:4,代码来源:NaiveDungeonGenerator.java


示例5: step2

import org.jgrapht.alg.KruskalMinimumSpanningTree; //导入依赖的package包/类
/**
	 * Find the minimal spanning tree, T1, of G1. (If there are several minimal spanning trees, pick an arbitrary one.)
	 * @param g1
	 * @return
	 */
	private WeightedMultigraph<Node, DefaultLink> step2(Pseudograph<Node, DefaultLink> g1) {

		logger.debug("<enter");

		KruskalMinimumSpanningTree<Node, DefaultLink> mst =
            new KruskalMinimumSpanningTree<Node, DefaultLink>(g1);

//    	logger.debug("Total MST Cost: " + mst.getSpanningTreeCost());

        Set<DefaultLink> edges = mst.getEdgeSet();

		WeightedMultigraph<Node, DefaultLink> g2 = 
			new WeightedMultigraph<Node, DefaultLink>(DefaultLink.class);
		
		List<DefaultLink> edgesSortedById = new ArrayList<DefaultLink>();
		
		for (DefaultLink e : edges) 
			edgesSortedById.add(e);
		
		Collections.sort(edgesSortedById);
		
		for (DefaultLink edge : edgesSortedById) {
			g2.addVertex(edge.getSource());
			g2.addVertex(edge.getTarget());
			g2.addEdge( edge.getSource(), edge.getTarget(), edge); 
		}
		
		logger.debug("exit>");

		return g2;
	}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:37,代码来源:SteinerTree.java


示例6: step4

import org.jgrapht.alg.KruskalMinimumSpanningTree; //导入依赖的package包/类
/**
	 * Find the minimal spanning tree, Ts, of Gs. (If there are several minimal spanning trees, pick an arbitrary one.)
	 * @param g3
	 * @return
	 */
	private WeightedMultigraph<Node, DefaultLink> step4(WeightedMultigraph<Node, DefaultLink> g3) {

		logger.debug("<enter");

		KruskalMinimumSpanningTree<Node, DefaultLink> mst =
            new KruskalMinimumSpanningTree<Node, DefaultLink>(g3);

//    	logger.debug("Total MST Cost: " + mst.getSpanningTreeCost());

        Set<DefaultLink> edges = mst.getEdgeSet();

		WeightedMultigraph<Node, DefaultLink> g4 = 
			new WeightedMultigraph<Node, DefaultLink>(DefaultLink.class);
		
		List<DefaultLink> edgesSortedById = new ArrayList<DefaultLink>();
		
		for (DefaultLink e : edges) 
			edgesSortedById.add(e);
		
		Collections.sort(edgesSortedById);
		
		for (DefaultLink edge : edgesSortedById) {
			g4.addVertex(edge.getSource());
			g4.addVertex(edge.getTarget());
			g4.addEdge( edge.getSource(), edge.getTarget(), edge); 
		}
		
		logger.debug("exit>");

		return g4;
	}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:37,代码来源:SteinerTree.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CachePoolInfo类代码示例发布时间:2022-05-22
下一篇:
Java DebugDrawer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap