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


Java Multigraph.edgeSet方法代码示例

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


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

示例1: generateCorridors

import org.jgrapht.graph.Multigraph; //导入方法依赖的package包/类
public Array<Rectangle> generateCorridors(Array<GameCell> cells, Multigraph<GameRoom, NoDuplicateEdge> corridorsGraph) throws MapGenException {

        Gdx.app.log("CorridorGenerator", "------------- Generating corridors -------------");
        Array<Rectangle> corridors = new Array<>();
        Set<NoDuplicateEdge> edges = corridorsGraph.edgeSet();

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

        for (NoDuplicateEdge edge : edges) {
            Gdx.app.log("CorridorGenerator", "  Generating corridor for edge: " + edge);

            GameRoom sourceRoom = corridorsGraph.getEdgeSource(edge);
            GameRoom targetRoom = corridorsGraph.getEdgeTarget(edge);

            corridors = generateCorridor(rooms, corridors, sourceRoom, targetRoom);
        }

        return corridors;
    }
 
开发者ID:LeonardBesson,项目名称:DunGen,代码行数:20,代码来源:CorridorGenerator.java

示例2: drawMinimalSpanningTree

import org.jgrapht.graph.Multigraph; //导入方法依赖的package包/类
private void drawMinimalSpanningTree(ShapeRenderer shapeRenderer) {
    shapeRenderer.setColor(MIN_SPANNING_TREE_COLOR);

    Multigraph<GameRoom, NoDuplicateEdge> minSpanningTree = map.minimalSpanningTree;

    Set<NoDuplicateEdge> edges = minSpanningTree.edgeSet();

    for (NoDuplicateEdge edge : edges) {

        Vector2 sourceRoomCenter = new Vector2();
        Vector2 targetRoomCenter = new Vector2();

        minSpanningTree.getEdgeSource(edge).getCenter(sourceRoomCenter);
        minSpanningTree.getEdgeTarget(edge).getCenter(targetRoomCenter);

        shapeRenderer.line(sourceRoomCenter.x, sourceRoomCenter.y, targetRoomCenter.x, targetRoomCenter.y);
    }
}
 
开发者ID:LeonardBesson,项目名称:DunGen,代码行数:19,代码来源:MapGenDebugRenderer.java

示例3: minimumSpanningTreeFromGraph

import org.jgrapht.graph.Multigraph; //导入方法依赖的package包/类
private void minimumSpanningTreeFromGraph(Multigraph<GameRoom, NoDuplicateEdge> graph, Set<NoDuplicateEdge> minEdges, float remainingEdgesMultiplier) {

        Gdx.app.log("GraphGenerator", "  --> Removing useless edges from graph");

        Set<NoDuplicateEdge> allEdges = graph.edgeSet();

        HashSet<NoDuplicateEdge> unusedEdges = new HashSet<>(allEdges);
        unusedEdges.removeAll(minEdges);

        int minEdgeSize = minEdges.size();
        int remainingEdgeCount = Math.round(minEdgeSize * remainingEdgesMultiplier);
        Gdx.app.log("GraphGenerator", "  --> " + remainingEdgeCount + " (" + minEdgeSize + " x " + remainingEdgesMultiplier + ") " + (remainingEdgeCount > 1 ? "edges" : "edge") + " will remain from the triangulation graph");
        remainingEdgeCount = MathUtils.clamp(remainingEdgeCount, 0, unusedEdges.size());
        Gdx.app.log("GraphGenerator", "      --> Clamped to " + remainingEdgeCount);

        while (remainingEdgeCount > 0) {
            int remainingEdgeIndex = new RandomDataGenerator().nextInt(0, unusedEdges.size() - 1);

            NoDuplicateEdge edge = (NoDuplicateEdge) unusedEdges.toArray()[remainingEdgeIndex];

            if (minEdges.contains(edge)) continue;

            unusedEdges.remove(edge);

            remainingEdgeCount--;
        }

        unusedEdges.forEach(graph::removeEdge);
    }
 
开发者ID:LeonardBesson,项目名称:DunGen,代码行数:30,代码来源:GraphGenerator.java


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