Java Code Examples for org.jgrapht.graph.SimpleGraph#removeAllVertices()
The following examples show how to use
org.jgrapht.graph.SimpleGraph#removeAllVertices() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItalyTileModifier.java From Rails with GNU General Public License v2.0 | 6 votes |
@Override public void modifyMapGraph(NetworkGraph mapGraph) { SimpleGraph<NetworkVertex, NetworkEdge> graph = mapGraph.getGraph(); List<MapHex> italyMapHexes = new ArrayList<MapHex> (); // 1. check Phase // this is a violation of the assumption that the track network only dependents on the map configuration // but not on other things (like phases) int phaseIndex = root.getPhaseManager().getCurrentPhase().getIndex(); if (phaseIndex < 4 ) { log.debug("Italy active, index of phase = {}", phaseIndex); return; } // 2. retrieve Italy vertices ... String [] italyHexes = {"K1","K3","K7","K9","L2","L4","L6","L8","M3","M5","M7"}; for (String italyHex:italyHexes){ italyMapHexes.add(root.getMapManager().getHex(italyHex)); } Set<NetworkVertex> italyVertices = NetworkVertex.getVerticesByHexes(graph.vertexSet(), italyMapHexes); // 3 ... and remove them from the graph graph.removeAllVertices(italyVertices); log.debug("Italy inactive, index of phase = {}", phaseIndex); }
Example 2
Source File: BzHTileModifier.java From Rails with GNU General Public License v2.0 | 6 votes |
@Override public void modifyMapGraph(NetworkGraph mapGraph) { SimpleGraph<NetworkVertex, NetworkEdge> graph = mapGraph.getGraph(); // 1. check Phase // this is a violation of the assumption that the track network only dependents on the map configuration // but not on other things (like phases) int phaseIndex = root.getPhaseManager().getCurrentPhase().getIndex(); if (phaseIndex >= 3 ) { log.debug("Boznia-Herzegovina active, index of phase = {}", phaseIndex); return; } // 2. retrieve BzH vertices ... String[] bzhHexes = {"L16","L18","L20","L22","M17","M19","M21","N18","N20"}; for(String bzhHex:bzhHexes){ bzhMapHexes.add(root.getMapManager().getHex(bzhHex)); } Set<NetworkVertex> bzhVertices = NetworkVertex.getVerticesByHexes(graph.vertexSet(), bzhMapHexes); // 3 ... and remove them from the graph graph.removeAllVertices(bzhVertices); log.debug("Bosnia Herzegovina inactive, index of phase = {}", phaseIndex); }
Example 3
Source File: BirminghamTileModifier.java From Rails with GNU General Public License v2.0 | 6 votes |
@Override public void modifyMapGraph(NetworkGraph mapGraph) { // TODO (Rails 2.0): Add root reference to modifiers SimpleGraph<NetworkVertex, NetworkEdge> graph = mapGraph.getGraph(); // 1. check Phase // this is a violation of the assumption that the track network only dependents on the map configuration // but not on other things (like phases) int phaseIndex = root.getPhaseManager().getCurrentPhase().getIndex(); if (phaseIndex >= 2 ) { log.debug("Birmingham active, index of phase = {}", phaseIndex); return; } // 2. retrieve Birmingham vertices ... MapHex birmingHex = root.getMapManager().getHex("J12"); Set<NetworkVertex> birmingVertices = NetworkVertex.getVerticesByHex(graph.vertexSet(), birmingHex); // 3 ... and remove them from the graph graph.removeAllVertices(birmingVertices); log.debug("Birmingham inactive, index of phase = {}", phaseIndex); }
Example 4
Source File: ElsasModifier.java From Rails with GNU General Public License v2.0 | 6 votes |
@Override public void modifyMapGraph(NetworkGraph mapGraph) { SimpleGraph<NetworkVertex, NetworkEdge> graph = mapGraph.getGraph(); // Check if (one of the elsasHex has zero value ... MapHex hex = root.getMapManager().getHex("M5"); if (hex.getCurrentValueForPhase(root.getPhaseManager().getCurrentPhase()) == 0) { // .. then remove both Set<NetworkVertex> vertices = NetworkVertex.getVerticesByHex(graph.vertexSet(), hex); graph.removeAllVertices(vertices); hex = root.getMapManager().getHex("N4"); vertices = NetworkVertex.getVerticesByHex(graph.vertexSet(), hex); graph.removeAllVertices(vertices); log.debug("Elsas is inactive"); } }
Example 5
Source File: F21Modifier.java From Rails with GNU General Public License v2.0 | 5 votes |
@Override public void modifyMapGraph(NetworkGraph mapGraph) { SimpleGraph<NetworkVertex, NetworkEdge> graph = mapGraph.getGraph(); // Check if F21 has zero value MapHex hex = root.getMapManager().getHex("F21"); if (hex.getCurrentValueForPhase(root.getPhaseManager().getCurrentPhase()) == 0) { // ... then remove those vertices Set<NetworkVertex> vertices = NetworkVertex.getVerticesByHex(graph.vertexSet(), hex); graph.removeAllVertices(vertices); } }
Example 6
Source File: SpecialRight.java From Rails with GNU General Public License v2.0 | 5 votes |
@Override public void modifyRouteGraph(NetworkGraph routeGraph, PublicCompany company) { // 1. check operating company if it has the right then it is excluded from the removal // TODO: Only use one right for all companies instead of one per company if (this.getOriginalCompany() != company || company.hasRight(this)) return; SimpleGraph<NetworkVertex, NetworkEdge> graph = routeGraph.getGraph(); // 2. find vertices to hex and remove the station Set<NetworkVertex> verticesToRemove = NetworkVertex.getVerticesByHexes(graph.vertexSet(), locations); // 3 ... and remove them from the graph graph.removeAllVertices(verticesToRemove); }