@Test public void testRemoveLoops() { Graph<String, String> graph = new SparseMultigraph<>(); graph.addVertex("v1"); graph.addVertex("v2"); graph.addVertex("v3"); graph.addEdge("e1", "v1", "v2", EdgeType.DIRECTED); graph.addEdge("e2", "v2", "v1", EdgeType.DIRECTED); graph.addEdge("e3", "v1", "v3", EdgeType.DIRECTED); DependencyGraph.removeLoops(graph); assertEquals(3, graph.getVertexCount()); assertEquals(2, graph.getEdgeCount()); assertTrue(graph.getEdges().contains("e1")); assertTrue(graph.getEdges().contains("e3")); }
public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } }
DependencyGraph implements IPipelineOrderer { public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } } }
DependencyGraph implements IPipelineOrderer { public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } }  }
DependencyGraph implements IPipelineOrderer { public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } }  @Override List<AnalysisEngine> orderPipeline(List<AnalysisEngine> analysisEngines); static boolean overlaps(
      Set<Class<? extends Annotation>> s1, Set<Class<? extends Annotation>> s2); static void removeLoops(Graph<V, E> graph); static Set<V> removeLayer(Graph<V, E> graph); }
DependencyGraph implements IPipelineOrderer { public static <V, E> void removeLoops(Graph<V, E> graph) { for (V v : graph.getVertices()) { for (E e : graph.getOutEdges(v)) { V dest = graph.getDest(e); E returnEdge = graph.findEdge(dest, v); if (returnEdge != null) { LOGGER.warn( "Loop detected between {} and {}. Original order will be preserved.", getName(v), getName(dest)); graph.removeEdge(returnEdge); } } } }  @Override List<AnalysisEngine> orderPipeline(List<AnalysisEngine> analysisEngines); static boolean overlaps(
      Set<Class<? extends Annotation>> s1, Set<Class<? extends Annotation>> s2); static void removeLoops(Graph<V, E> graph); static Set<V> removeLayer(Graph<V, E> graph);  }