List of usage examples for org.apache.commons.math3.util CombinatoricsUtils combinationsIterator
public static Iterator<int[]> combinationsIterator(int n, int k)
From source file:com.github.braully.graph.operation.GraphCalcCaratheodoryNumberBinaryStrategy.java
public OperationConvexityGraphResult findCaratheodroySetBruteForce( UndirectedSparseGraphTO<Integer, Integer> graph, int currentSize) { OperationConvexityGraphResult processedHullSet = null; if (graph == null || graph.getVertexCount() <= 0) { return processedHullSet; }// w w w .j av a2 s.co m Collection vertices = graph.getVertices(); int veticesCount = vertices.size(); Iterator<int[]> combinationsIterator = CombinatoricsUtils.combinationsIterator(graph.getVertexCount(), currentSize); while (combinationsIterator.hasNext()) { int[] currentSet = combinationsIterator.next(); OperationConvexityGraphResult hsp3g = hsp3(graph, currentSet); if (hsp3g != null) { processedHullSet = hsp3g; break; } } return processedHullSet; }
From source file:com.github.braully.graph.hn.GraphWS.java
public Set<Integer> findHullSetBruteForce(UndirectedSparseGraphTO<Integer, Integer> graph, int currentSetSize) { Set<Integer> hullSet = null; if (graph == null || graph.getVertexCount() <= 0) { return hullSet; }/*from w w w . j a va 2 s. co m*/ Collection vertices = graph.getVertices(); Iterator<int[]> combinationsIterator = CombinatoricsUtils.combinationsIterator(graph.getVertexCount(), currentSetSize); while (combinationsIterator.hasNext()) { int[] currentSet = combinationsIterator.next(); if (checkIfHullSet(graph, currentSet)) { hullSet = new HashSet<>(currentSetSize); for (int i : currentSet) { hullSet.add(i); } break; } } return hullSet; }