InconsistencyParameterization extends ConsistencyParameterization { public static Tree<Treatment, FoldedEdge<Treatment, Study>> findSpanningTree(Collection<Study> studies, UndirectedGraph<Treatment, FoldedEdge<Treatment, Study>> cGraph) { boolean hasCompleteBaseline = findStudyBaselines(studies, cGraph) != null; int nFunctional = cGraph.getEdgeCount() - cGraph.getVertexCount() + 1; int maxPossible = hasCompleteBaseline ? nFunctional : nFunctional - 1; int max = -1; Tree<Treatment, FoldedEdge<Treatment, Study>> best = null; Treatment root = CompareUtil.findLeast(cGraph.getVertices(), TreatmentComparator.INSTANCE); SpanningTreeIterable<Treatment, FoldedEdge<Treatment, Study>> spanningTreeIterable = new SpanningTreeIterable<Treatment, FoldedEdge<Treatment, Study>>(NetworkModel.toDirected(cGraph), root, TreatmentComparator.INSTANCE); for (Tree<Treatment, FoldedEdge<Treatment, Study>> tree : spanningTreeIterable) { Map<Partition, Set<List<Treatment>>> cycleClasses = getCycleClasses(cGraph, tree); int icd = getInconsistencyDegree(cycleClasses); if (icd > max && icd <= maxPossible) { if (hasCompleteBaseline || findStudyBaselines(studies, cGraph, cycleClasses) != null) { max = icd; best = tree; } } if (max == maxPossible) { return best; } } return best; } InconsistencyParameterization(Network network, Tree<Treatment, FoldedEdge<Treatment, Study>> tree, Map<Partition, Set<List<Treatment>>> cycleClasses, Map<Study, Treatment> baselines); static InconsistencyParameterization create(Network network); static Map<Partition, Set<List<Treatment>>> getCycleClasses(UndirectedGraph<Treatment, FoldedEdge<Treatment, Study>> cGraph, Tree<Treatment, FoldedEdge<Treatment, Study>> tree); static int getInconsistencyDegree(Map<Partition, Set<List<Treatment>>> cycleClasses); static boolean isInconsistencyCycle(Partition p); static Map<Study, Treatment> findStudyBaselines(Collection<Study> studies, UndirectedGraph<Treatment, FoldedEdge<Treatment, Study>> cGraph); static Map<Study, Treatment> findStudyBaselines(Collection<Study> studies, UndirectedGraph<Treatment, FoldedEdge<Treatment, Study>> cGraph, Map<Partition, Set<List<Treatment>>> cycleClasses); static Tree<Treatment, FoldedEdge<Treatment, Study>> findSpanningTree(Collection<Study> studies, UndirectedGraph<Treatment, FoldedEdge<Treatment, Study>> cGraph); static List<Treatment> standardizeCycle(List<Treatment> cycle); @Override List<NetworkParameter> getParameters();  }
@Test public void testFindSpanningTree() { UndirectedGraph<Treatment, FoldedEdge<Treatment, Study>> cGraph = NetworkModel.createComparisonGraph(d_network); Tree<Treatment, FoldedEdge<Treatment, Study>> tree = InconsistencyParameterization.findSpanningTree(d_network.getStudies(), cGraph); Map<Partition, Set<List<Treatment>>> cycleClasses = InconsistencyParameterization.getCycleClasses(cGraph, tree); assertEquals(2, InconsistencyParameterization.getInconsistencyDegree(cycleClasses)); }