Java Code Examples for org.apache.commons.math3.distribution.IntegerDistribution#sample()
The following examples show how to use
org.apache.commons.math3.distribution.IntegerDistribution#sample() .
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: SyntheticOptions.java From beam with Apache License 2.0 | 6 votes |
public static Sampler fromIntegerDistribution(final IntegerDistribution dist) { return new Sampler() { private static final long serialVersionUID = 0L; @Override public double sample(long seed) { dist.reseedRandomGenerator(seed); return dist.sample(); } @Override public Object getDistribution() { return dist; } }; }
Example 2
Source File: ResizableDoubleArrayTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testWithInitialCapacity() { ResizableDoubleArray eDA2 = new ResizableDoubleArray(2); Assert.assertEquals("Initial number of elements should be 0", 0, eDA2.getNumElements()); final IntegerDistribution randomData = new UniformIntegerDistribution(100, 1000); final int iterations = randomData.sample(); for( int i = 0; i < iterations; i++) { eDA2.addElement( i ); } Assert.assertEquals("Number of elements should be equal to " + iterations, iterations, eDA2.getNumElements()); eDA2.addElement( 2.0 ); Assert.assertEquals("Number of elements should be equals to " + (iterations +1), iterations + 1 , eDA2.getNumElements() ); }
Example 3
Source File: ResizableDoubleArrayTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testWithInitialCapacity() { ResizableDoubleArray eDA2 = new ResizableDoubleArray(2); Assert.assertEquals("Initial number of elements should be 0", 0, eDA2.getNumElements()); final IntegerDistribution randomData = new UniformIntegerDistribution(100, 1000); final int iterations = randomData.sample(); for( int i = 0; i < iterations; i++) { eDA2.addElement( i ); } Assert.assertEquals("Number of elements should be equal to " + iterations, iterations, eDA2.getNumElements()); eDA2.addElement( 2.0 ); Assert.assertEquals("Number of elements should be equals to " + (iterations +1), iterations + 1 , eDA2.getNumElements() ); }
Example 4
Source File: ResizableDoubleArrayTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testWithInitialCapacity() { ResizableDoubleArray eDA2 = new ResizableDoubleArray(2); Assert.assertEquals("Initial number of elements should be 0", 0, eDA2.getNumElements()); final IntegerDistribution randomData = new UniformIntegerDistribution(100, 1000); final int iterations = randomData.sample(); for( int i = 0; i < iterations; i++) { eDA2.addElement( i ); } Assert.assertEquals("Number of elements should be equal to " + iterations, iterations, eDA2.getNumElements()); eDA2.addElement( 2.0 ); Assert.assertEquals("Number of elements should be equals to " + (iterations +1), iterations + 1 , eDA2.getNumElements() ); }
Example 5
Source File: ResizableDoubleArrayTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testWithInitialCapacity() { ResizableDoubleArray eDA2 = new ResizableDoubleArray(2); Assert.assertEquals("Initial number of elements should be 0", 0, eDA2.getNumElements()); final IntegerDistribution randomData = new UniformIntegerDistribution(100, 1000); final int iterations = randomData.sample(); for( int i = 0; i < iterations; i++) { eDA2.addElement( i ); } Assert.assertEquals("Number of elements should be equal to " + iterations, iterations, eDA2.getNumElements()); eDA2.addElement( 2.0 ); Assert.assertEquals("Number of elements should be equals to " + (iterations +1), iterations + 1 , eDA2.getNumElements() ); }
Example 6
Source File: AggregateSummaryStatisticsTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Generates a random sample of double values. * Sample size is random, between 10 and 100 and values are * uniformly distributed over [-100, 100]. * * @return array of random double values */ private double[] generateSample() { final IntegerDistribution size = new UniformIntegerDistribution(10, 100); final RealDistribution randomData = new UniformRealDistribution(-100, 100); final int sampleSize = size.sample(); final double[] out = randomData.sample(sampleSize); return out; }
Example 7
Source File: AggregateSummaryStatisticsTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Generates a random sample of double values. * Sample size is random, between 10 and 100 and values are * uniformly distributed over [-100, 100]. * * @return array of random double values */ private double[] generateSample() { final IntegerDistribution size = new UniformIntegerDistribution(10, 100); final RealDistribution randomData = new UniformRealDistribution(-100, 100); final int sampleSize = size.sample(); final double[] out = randomData.sample(sampleSize); return out; }
Example 8
Source File: AggregateSummaryStatisticsTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Generates a random sample of double values. * Sample size is random, between 10 and 100 and values are * uniformly distributed over [-100, 100]. * * @return array of random double values */ private double[] generateSample() { final IntegerDistribution size = new UniformIntegerDistribution(10, 100); final RealDistribution randomData = new UniformRealDistribution(-100, 100); final int sampleSize = size.sample(); final double[] out = randomData.sample(sampleSize); return out; }
Example 9
Source File: AggregateSummaryStatisticsTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Generates a random sample of double values. * Sample size is random, between 10 and 100 and values are * uniformly distributed over [-100, 100]. * * @return array of random double values */ private double[] generateSample() { final IntegerDistribution size = new UniformIntegerDistribution(10, 100); final RealDistribution randomData = new UniformRealDistribution(-100, 100); final int sampleSize = size.sample(); final double[] out = randomData.sample(sampleSize); return out; }
Example 10
Source File: AggregateSummaryStatisticsTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Generates a random sample of double values. * Sample size is random, between 10 and 100 and values are * uniformly distributed over [-100, 100]. * * @return array of random double values */ private double[] generateSample() { final IntegerDistribution size = new UniformIntegerDistribution(10, 100); final RealDistribution randomData = new UniformRealDistribution(-100, 100); final int sampleSize = size.sample(); final double[] out = randomData.sample(sampleSize); return out; }
Example 11
Source File: AggregateSummaryStatisticsTest.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Generates a random sample of double values. * Sample size is random, between 10 and 100 and values are * uniformly distributed over [-100, 100]. * * @return array of random double values */ private double[] generateSample() { final IntegerDistribution size = new UniformIntegerDistribution(10, 100); final RealDistribution randomData = new UniformRealDistribution(-100, 100); final int sampleSize = size.sample(); final double[] out = randomData.sample(sampleSize); return out; }
Example 12
Source File: ResizableDoubleArrayTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testWithInitialCapacityAndExpansionFactor() { ResizableDoubleArray eDA3 = new ResizableDoubleArray(3, 3.0f, 3.5f); Assert.assertEquals("Initial number of elements should be 0", 0, eDA3.getNumElements() ); final IntegerDistribution randomData = new UniformIntegerDistribution(100, 3000); final int iterations = randomData.sample(); for( int i = 0; i < iterations; i++) { eDA3.addElement( i ); } Assert.assertEquals("Number of elements should be equal to " + iterations, iterations,eDA3.getNumElements()); eDA3.addElement( 2.0 ); Assert.assertEquals("Number of elements should be equals to " + (iterations +1), iterations +1, eDA3.getNumElements() ); Assert.assertEquals("Expansion factor should equal 3.0", 3.0f, eDA3.getExpansionFactor(), Double.MIN_VALUE); }
Example 13
Source File: UnivariateStatisticAbstractTest.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Tests consistency of weighted statistic computation. * For statistics that support weighted evaluation, this test case compares * the result of direct computation on an array with repeated values with * a weighted computation on the corresponding (shorter) array with each * value appearing only once but with a weight value equal to its multiplicity * in the repeating array. */ @Test public void testWeightedConsistency() { // See if this statistic computes weighted statistics // If not, skip this test UnivariateStatistic statistic = getUnivariateStatistic(); if (!(statistic instanceof WeightedEvaluation)) { return; } // Create arrays of values and corresponding integral weights // and longer array with values repeated according to the weights final int len = 10; // length of values array final double mu = 0; // mean of test data final double sigma = 5; // std dev of test data double[] values = new double[len]; double[] weights = new double[len]; // Fill weights array with random int values between 1 and 5 int[] intWeights = new int[len]; final IntegerDistribution weightDist = new UniformIntegerDistribution(1, 5); for (int i = 0; i < len; i++) { intWeights[i] = weightDist.sample(); weights[i] = intWeights[i]; } // Fill values array with random data from N(mu, sigma) // and fill valuesList with values from values array with // values[i] repeated weights[i] times, each i final RealDistribution valueDist = new NormalDistribution(mu, sigma); List<Double> valuesList = new ArrayList<Double>(); for (int i = 0; i < len; i++) { double value = valueDist.sample(); values[i] = value; for (int j = 0; j < intWeights[i]; j++) { valuesList.add(new Double(value)); } } // Dump valuesList into repeatedValues array int sumWeights = valuesList.size(); double[] repeatedValues = new double[sumWeights]; for (int i = 0; i < sumWeights; i++) { repeatedValues[i] = valuesList.get(i); } // Compare result of weighted statistic computation with direct computation // on array of repeated values WeightedEvaluation weightedStatistic = (WeightedEvaluation) statistic; TestUtils.assertRelativelyEquals(statistic.evaluate(repeatedValues), weightedStatistic.evaluate(values, weights, 0, values.length), 10E-12); // Check consistency of weighted evaluation methods Assert.assertEquals(weightedStatistic.evaluate(values, weights, 0, values.length), weightedStatistic.evaluate(values, weights), Double.MIN_VALUE); }
Example 14
Source File: ResizableDoubleArrayTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testWithInitialCapacityAndExpansionFactor() { ResizableDoubleArray eDA3 = new ResizableDoubleArray(3, 3.0, 3.5); Assert.assertEquals("Initial number of elements should be 0", 0, eDA3.getNumElements() ); final IntegerDistribution randomData = new UniformIntegerDistribution(100, 3000); final int iterations = randomData.sample(); for( int i = 0; i < iterations; i++) { eDA3.addElement( i ); } Assert.assertEquals("Number of elements should be equal to " + iterations, iterations,eDA3.getNumElements()); eDA3.addElement( 2.0 ); Assert.assertEquals("Number of elements should be equals to " + (iterations +1), iterations +1, eDA3.getNumElements() ); Assert.assertEquals("Expansion factor should equal 3.0", 3.0f, eDA3.getExpansionFactor(), Double.MIN_VALUE); }
Example 15
Source File: ResizableDoubleArrayTest.java From astor with GNU General Public License v2.0 | 4 votes |
@Test public void testWithInitialCapacityAndExpansionFactor() { ResizableDoubleArray eDA3 = new ResizableDoubleArray(3, 3.0, 3.5); Assert.assertEquals("Initial number of elements should be 0", 0, eDA3.getNumElements() ); final IntegerDistribution randomData = new UniformIntegerDistribution(100, 3000); final int iterations = randomData.sample(); for( int i = 0; i < iterations; i++) { eDA3.addElement( i ); } Assert.assertEquals("Number of elements should be equal to " + iterations, iterations,eDA3.getNumElements()); eDA3.addElement( 2.0 ); Assert.assertEquals("Number of elements should be equals to " + (iterations +1), iterations +1, eDA3.getNumElements() ); Assert.assertEquals("Expansion factor should equal 3.0", 3.0f, eDA3.getExpansionFactor(), Double.MIN_VALUE); }
Example 16
Source File: UnivariateStatisticAbstractTest.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Tests consistency of weighted statistic computation. * For statistics that support weighted evaluation, this test case compares * the result of direct computation on an array with repeated values with * a weighted computation on the corresponding (shorter) array with each * value appearing only once but with a weight value equal to its multiplicity * in the repeating array. */ @Test public void testWeightedConsistency() { // See if this statistic computes weighted statistics // If not, skip this test UnivariateStatistic statistic = getUnivariateStatistic(); if (!(statistic instanceof WeightedEvaluation)) { return; } // Create arrays of values and corresponding integral weights // and longer array with values repeated according to the weights final int len = 10; // length of values array final double mu = 0; // mean of test data final double sigma = 5; // std dev of test data double[] values = new double[len]; double[] weights = new double[len]; // Fill weights array with random int values between 1 and 5 int[] intWeights = new int[len]; final IntegerDistribution weightDist = new UniformIntegerDistribution(1, 5); for (int i = 0; i < len; i++) { intWeights[i] = weightDist.sample(); weights[i] = intWeights[i]; } // Fill values array with random data from N(mu, sigma) // and fill valuesList with values from values array with // values[i] repeated weights[i] times, each i final RealDistribution valueDist = new NormalDistribution(mu, sigma); List<Double> valuesList = new ArrayList<Double>(); for (int i = 0; i < len; i++) { double value = valueDist.sample(); values[i] = value; for (int j = 0; j < intWeights[i]; j++) { valuesList.add(new Double(value)); } } // Dump valuesList into repeatedValues array int sumWeights = valuesList.size(); double[] repeatedValues = new double[sumWeights]; for (int i = 0; i < sumWeights; i++) { repeatedValues[i] = valuesList.get(i); } // Compare result of weighted statistic computation with direct computation // on array of repeated values WeightedEvaluation weightedStatistic = (WeightedEvaluation) statistic; TestUtils.assertRelativelyEquals(statistic.evaluate(repeatedValues), weightedStatistic.evaluate(values, weights, 0, values.length), 10E-12); // Check consistency of weighted evaluation methods Assert.assertEquals(weightedStatistic.evaluate(values, weights, 0, values.length), weightedStatistic.evaluate(values, weights), Double.MIN_VALUE); }
Example 17
Source File: UnivariateStatisticAbstractTest.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Tests consistency of weighted statistic computation. * For statistics that support weighted evaluation, this test case compares * the result of direct computation on an array with repeated values with * a weighted computation on the corresponding (shorter) array with each * value appearing only once but with a weight value equal to its multiplicity * in the repeating array. */ @Test public void testWeightedConsistency() { // See if this statistic computes weighted statistics // If not, skip this test UnivariateStatistic statistic = getUnivariateStatistic(); if (!(statistic instanceof WeightedEvaluation)) { return; } // Create arrays of values and corresponding integral weights // and longer array with values repeated according to the weights final int len = 10; // length of values array final double mu = 0; // mean of test data final double sigma = 5; // std dev of test data double[] values = new double[len]; double[] weights = new double[len]; // Fill weights array with random int values between 1 and 5 int[] intWeights = new int[len]; final IntegerDistribution weightDist = new UniformIntegerDistribution(1, 5); for (int i = 0; i < len; i++) { intWeights[i] = weightDist.sample(); weights[i] = intWeights[i]; } // Fill values array with random data from N(mu, sigma) // and fill valuesList with values from values array with // values[i] repeated weights[i] times, each i final RealDistribution valueDist = new NormalDistribution(mu, sigma); List<Double> valuesList = new ArrayList<Double>(); for (int i = 0; i < len; i++) { double value = valueDist.sample(); values[i] = value; for (int j = 0; j < intWeights[i]; j++) { valuesList.add(new Double(value)); } } // Dump valuesList into repeatedValues array int sumWeights = valuesList.size(); double[] repeatedValues = new double[sumWeights]; for (int i = 0; i < sumWeights; i++) { repeatedValues[i] = valuesList.get(i); } // Compare result of weighted statistic computation with direct computation // on array of repeated values WeightedEvaluation weightedStatistic = (WeightedEvaluation) statistic; TestUtils.assertRelativelyEquals(statistic.evaluate(repeatedValues), weightedStatistic.evaluate(values, weights, 0, values.length), 10E-12); // Check consistency of weighted evaluation methods Assert.assertEquals(weightedStatistic.evaluate(values, weights, 0, values.length), weightedStatistic.evaluate(values, weights), Double.MIN_VALUE); }
Example 18
Source File: UnivariateStatisticAbstractTest.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Tests consistency of weighted statistic computation. * For statistics that support weighted evaluation, this test case compares * the result of direct computation on an array with repeated values with * a weighted computation on the corresponding (shorter) array with each * value appearing only once but with a weight value equal to its multiplicity * in the repeating array. */ @Test public void testWeightedConsistency() { // See if this statistic computes weighted statistics // If not, skip this test UnivariateStatistic statistic = getUnivariateStatistic(); if (!(statistic instanceof WeightedEvaluation)) { return; } // Create arrays of values and corresponding integral weights // and longer array with values repeated according to the weights final int len = 10; // length of values array final double mu = 0; // mean of test data final double sigma = 5; // std dev of test data double[] values = new double[len]; double[] weights = new double[len]; // Fill weights array with random int values between 1 and 5 int[] intWeights = new int[len]; final IntegerDistribution weightDist = new UniformIntegerDistribution(1, 5); for (int i = 0; i < len; i++) { intWeights[i] = weightDist.sample(); weights[i] = intWeights[i]; } // Fill values array with random data from N(mu, sigma) // and fill valuesList with values from values array with // values[i] repeated weights[i] times, each i final RealDistribution valueDist = new NormalDistribution(mu, sigma); List<Double> valuesList = new ArrayList<Double>(); for (int i = 0; i < len; i++) { double value = valueDist.sample(); values[i] = value; for (int j = 0; j < intWeights[i]; j++) { valuesList.add(new Double(value)); } } // Dump valuesList into repeatedValues array int sumWeights = valuesList.size(); double[] repeatedValues = new double[sumWeights]; for (int i = 0; i < sumWeights; i++) { repeatedValues[i] = valuesList.get(i); } // Compare result of weighted statistic computation with direct computation // on array of repeated values WeightedEvaluation weightedStatistic = (WeightedEvaluation) statistic; TestUtils.assertRelativelyEquals(statistic.evaluate(repeatedValues), weightedStatistic.evaluate(values, weights, 0, values.length), 10E-12); // Check consistency of weighted evaluation methods Assert.assertEquals(weightedStatistic.evaluate(values, weights, 0, values.length), weightedStatistic.evaluate(values, weights), Double.MIN_VALUE); }
Example 19
Source File: MultiLabelSynthesizer.java From pyramid with Apache License 2.0 | 4 votes |
/** * y0: w=(0,1) * y1: w=(1,1) * y2: w=(1,0) * y3: w=(1,-1) * @param numData * @return */ public static MultiLabelClfDataSet flipOneNonUniform(int numData){ int numClass = 4; int numFeature = 2; MultiLabelClfDataSet dataSet = MLClfDataSetBuilder.getBuilder().numFeatures(numFeature) .numClasses(numClass) .numDataPoints(numData) .build(); // generate weights Vector[] weights = new Vector[numClass]; for (int k=0;k<numClass;k++){ Vector vector = new DenseVector(numFeature); weights[k] = vector; } weights[0].set(0,0); weights[0].set(1,1); weights[1].set(0, 1); weights[1].set(1, 1); weights[2].set(0, 1); weights[2].set(1, 0); weights[3].set(0,1); weights[3].set(1,-1); // generate features for (int i=0;i<numData;i++){ for (int j=0;j<numFeature;j++){ dataSet.setFeatureValue(i,j,Sampling.doubleUniform(-1, 1)); } } // assign labels for (int i=0;i<numData;i++){ for (int k=0;k<numClass;k++){ double dot = weights[k].dot(dataSet.getRow(i)); if (dot>=0){ dataSet.addLabel(i,k); } } } int[] indices = {0,1,2,3}; double[] probs = {0.4,0.2,0.2,0.2}; IntegerDistribution distribution = new EnumeratedIntegerDistribution(indices,probs); // flip for (int i=0;i<numData;i++){ int toChange = distribution.sample(); MultiLabel label = dataSet.getMultiLabels()[i]; if (label.matchClass(toChange)){ label.removeLabel(toChange); } else { label.addLabel(toChange); } } return dataSet; }
Example 20
Source File: CallGraphGenerator.java From fasten with Apache License 2.0 | 4 votes |
/** Generates <code>np</code> call graphs. Each call graph is obtained using {@link #preferentialAttachmentDAG(int, int, IntegerDistribution, RandomGenerator)} (with * specified initial graph size (<code>initialGraphSizeDistribution</code>), graph size (<code>graphSizeDistribution</code>), outdegree distribution (<code>outdegreeDistribution</code>). * Then a dependency DAG is generated between the call graphs, once more using {@link #preferentialAttachmentDAG(int, int, IntegerDistribution, RandomGenerator)} (this * time the initial graph size is 1, whereas the outdegree distribution is <code>outdegreeDistribution</code>). * Then to each node of each call graph a new set of outgoing arcs is generated (their number is chosen using <code>externalOutdegreeDistribution</code>): the target * call graph is generated using the indegree distribution of the dependency DAG; the target node is chosen according to the reverse indegree distribution within the revision call graph. * * @param np number of revision call graphs to be generated. * @param graphSizeDistribution the distribution of the graph sizes (number of functions per call graph). * @param initialGraphSizeDistribution the distribution of the initial graph sizes (the initial independent set from which the preferential attachment starts). * @param outdegreeDistribution the distribution of internal outdegrees (number of internal calls per function). * @param externalOutdegreeDistribution the distribution of external outdegrees (number of external calls per function). * @param depExponent exponent of the Zipf distribution used to establish the dependencies between call graphs. * @param random the random object used for the generation. */ public void generate(final int np, final IntegerDistribution graphSizeDistribution, final IntegerDistribution initialGraphSizeDistribution, final IntegerDistribution outdegreeDistribution, final IntegerDistribution externalOutdegreeDistribution, final IntegerDistribution dependencyOutdegreeDistribution, final RandomGenerator random) { rcgs = new ArrayListMutableGraph[np]; nodePermutation = new int[np][]; final FenwickTree[] td = new FenwickTree[np]; deps = new IntOpenHashSet[np]; source2Targets = new ObjectOpenCustomHashSet[np]; // Generate rcg of the np revisions, and the corresponding reverse preferential distribution; cumsize[i] is the sum of all nodes in packages <i for ( int i = 0; i < np; i++) { deps[i] = new IntOpenHashSet(); final int n = graphSizeDistribution.sample(); final int n0 = Math.min(initialGraphSizeDistribution.sample(), n); rcgs[i] = preferentialAttachmentDAG(n, n0, outdegreeDistribution, random); td[i] = getPreferentialDistribution(rcgs[i].immutableView(), true); nodePermutation[i] = Util.identity(n); Collections.shuffle(IntArrayList.wrap(nodePermutation[i]), new Random(random.nextLong())); } // Generate the dependency DAG between revisions using preferential attachment starting from 1 node final ArrayListMutableGraph depDAG = preferentialAttachmentDAG(np, 1, dependencyOutdegreeDistribution, random); // For each source package, generate function calls so to cover all dependencies for (int sourcePackage = 0; sourcePackage < np; sourcePackage++) { source2Targets[sourcePackage] = new ObjectOpenCustomHashSet<>(IntArrays.HASH_STRATEGY); final int outdegree = depDAG.outdegree(sourcePackage); if (outdegree == 0) continue; // No calls needed (I'm kinda busy) final int numFuncs = rcgs[sourcePackage].numNodes(); final int[] externalArcs = new int[numFuncs]; int allExternalArcs = 0; // We decide how many calls to dispatch from each function for (int sourceNode = 0; sourceNode < numFuncs; sourceNode++) allExternalArcs += (externalArcs[sourceNode] = externalOutdegreeDistribution.sample()); // We create a global list of external successors by shuffling final int[] targetPackage = new int[allExternalArcs]; final int[] succ = depDAG.successorArray(sourcePackage); for(int i = 0; i < outdegree; i++) deps[sourcePackage].add(succ[i]); for(int i = 0; i < allExternalArcs; i++) targetPackage[i] = succ[i % outdegree]; MathArrays.shuffle(targetPackage, random); for (int sourceNode = allExternalArcs = 0; sourceNode < numFuncs; sourceNode++) { final int externalOutdegree = externalArcs[sourceNode]; for (int t = 0; t < externalOutdegree; t++) { final int targetNode = td[targetPackage[allExternalArcs + t]].sample(random) - 1; source2Targets[sourcePackage].add(new int[] { sourceNode, targetPackage[allExternalArcs + t], targetNode }); } allExternalArcs += externalOutdegree; } } }