DirectedSubgraph<Node, Object> subgraph = new DirectedSubgraph(_graph, _nodes, null); TopologicalOrderIterator it = new TopologicalOrderIterator<Node, Object>(subgraph); int stateIndex = 0;
@Override public String valueOf(Set<T> cycleComponent) { final StringBuilder sb = new StringBuilder(); final DirectedSubgraph<T, E> cycleSubgraph = new DirectedSubgraph<T, E>(graph, cycleComponent, null); DepthFirstIterator<T, E> iterator = new DepthFirstIterator<T, E>(cycleSubgraph) { boolean started = false;
@Override public String valueOf(Set<T> cycleComponent) { final StringBuilder sb = new StringBuilder(); final DirectedSubgraph<T, E> cycleSubgraph = new DirectedSubgraph<T, E>(graph, cycleComponent, null); DepthFirstIterator<T, E> iterator = new DepthFirstIterator<T, E>(cycleSubgraph) { boolean started = false;
/** Check whether the graph is connected, that is, if it is possible to connect every node to each other, but only in a subset of vertices (subgraph). * * @param graph The graph to analyze * @param vertices Subset of vertices * @return {@code true} if the subgraph is connected, and false otherwise */ public static boolean isConnected(org.jgrapht.Graph graph, SortedSet vertices) { Subgraph subgraph; if (graph instanceof DirectedGraph) subgraph = new DirectedSubgraph((DirectedGraph) graph, vertices, null); else if (graph instanceof UndirectedGraph) subgraph = new UndirectedSubgraph((UndirectedGraph) graph, vertices, null); else throw new RuntimeException("Bad"); return isConnected(subgraph); }
if (connectedSet.size() <= 1) continue; DirectedSubgraph<OWLClass, DefaultWeightedEdge> subgraph = new DirectedSubgraph<OWLClass, DefaultWeightedEdge>(existentialRestrictionGraph, connectedSet, null); double estimatedTreeSize = 1.0; for (OWLClass owlClass : connectedSet) {
if (connectedSet.size() <= 1) continue; DirectedSubgraph<OWLClass, DefaultWeightedEdge> subgraph = new DirectedSubgraph<OWLClass, DefaultWeightedEdge>(existentialRestrictionGraph, connectedSet, null); double estimatedTreeSize = 1.0; for (OWLClass owlClass : connectedSet) {
continue; final DirectedSubgraph<OWLClass, DefaultWeightedEdge> subgraph = new DirectedSubgraph<>(existentialRestrictionGraph, connectedSet, null); double estimatedTreeSize = 1.0; for (final OWLClass owlClass : connectedSet)
DirectedSubgraph<Node, Object> subgraph = new DirectedSubgraph(_graph, _nodes, null); TopologicalOrderIterator it = new TopologicalOrderIterator<Node, Object>(subgraph); int stateIndex = 0;
private void estimateTreeSizesForCycles(OptimizedDirectedMultigraph<OWLClass> existentialRestrictionGraph) { int maxSizeOfCompleteGraphToIgnore = getMaxSizeOfCompleteGraphToIgnore(m_MaxTreeSize); StrongConnectivityInspector<OWLClass, DefaultWeightedEdge> connectivityInspector = new StrongConnectivityInspector<OWLClass, DefaultWeightedEdge>(existentialRestrictionGraph); for (Set<OWLClass> connectedSet : connectivityInspector.stronglyConnectedSets()) { if (connectedSet.size() <= maxSizeOfCompleteGraphToIgnore) continue; DirectedSubgraph<OWLClass, DefaultWeightedEdge> subgraph = new DirectedSubgraph<OWLClass, DefaultWeightedEdge>(existentialRestrictionGraph, connectedSet, null); double estimatedTreeSize = 1.0; for (OWLClass owlClass : connectedSet) { estimatedTreeSize *= subgraph.outDegreeOf(owlClass); } if (estimatedTreeSize > m_MaxTreeSize) { Lint lint = m_LintFactory.make(); lint.addAllParticipatingClasses(connectedSet); lint.setSeverity(new Severity(estimatedTreeSize)); m_AccumulatedLints.add(lint); } } }
private void estimateTreeSizesForCycles(OptimizedDirectedMultigraph<OWLClass> existentialRestrictionGraph) { int maxSizeOfCompleteGraphToIgnore = getMaxSizeOfCompleteGraphToIgnore(m_MaxTreeSize); StrongConnectivityInspector<OWLClass, DefaultWeightedEdge> connectivityInspector = new StrongConnectivityInspector<OWLClass, DefaultWeightedEdge>(existentialRestrictionGraph); for (Set<OWLClass> connectedSet : connectivityInspector.stronglyConnectedSets()) { if (connectedSet.size() <= maxSizeOfCompleteGraphToIgnore) continue; DirectedSubgraph<OWLClass, DefaultWeightedEdge> subgraph = new DirectedSubgraph<OWLClass, DefaultWeightedEdge>(existentialRestrictionGraph, connectedSet, null); double estimatedTreeSize = 1.0; for (OWLClass owlClass : connectedSet) { estimatedTreeSize *= subgraph.outDegreeOf(owlClass); } if (estimatedTreeSize > m_MaxTreeSize) { Lint lint = m_LintFactory.make(); lint.addAllParticipatingClasses(connectedSet); lint.setSeverity(new Severity(estimatedTreeSize)); m_AccumulatedLints.add(lint); } } }
private void estimateTreeSizesForCycles(final OptimizedDirectedMultigraph<OWLClass> existentialRestrictionGraph) { final int maxSizeOfCompleteGraphToIgnore = getMaxSizeOfCompleteGraphToIgnore(_maxTreeSize); final StrongConnectivityAlgorithm<OWLClass, DefaultWeightedEdge> connectivityInspector = new KosarajuStrongConnectivityInspector<>(existentialRestrictionGraph); for (final Set<OWLClass> connectedSet : connectivityInspector.stronglyConnectedSets()) { if (connectedSet.size() <= maxSizeOfCompleteGraphToIgnore) continue; final DirectedSubgraph<OWLClass, DefaultWeightedEdge> subgraph = new DirectedSubgraph<>(existentialRestrictionGraph, connectedSet, null); double estimatedTreeSize = 1.0; for (final OWLClass owlClass : connectedSet) estimatedTreeSize *= subgraph.outDegreeOf(owlClass); if (estimatedTreeSize > _maxTreeSize) { final Lint lint = _LintFactory.make(); lint.addAllParticipatingClasses(connectedSet); lint.setSeverity(new Severity(estimatedTreeSize)); _accumulatedLints.add(lint); } } }
private void assertGraphs( SimpleDirectedGraph<String, Object> full, SimpleDirectedGraph<String, Object> contracted, SimpleDirectedGraph<String, Object> result ) { // Set<String> vertices = ElementGraphs.findClosureViaBiConnected( full, contracted ); Set<String> vertices = ElementGraphs.findClosureViaFloydWarshall( full, contracted ).getLhs(); // Set<String> vertices = ElementGraphs.findClosureViaKShortest( full, contracted ); DirectedSubgraph<String, Object> subgraph = new DirectedSubgraph<>( full, vertices, null ); // System.out.println( "subgraph = " + subgraph ); SimpleDirectedGraph<String, Object> clone = new SimpleDirectedGraph<>( Object.class ); Graphs.addGraph( clone, subgraph ); assertEquals( result, clone ); }