Package edu.cmu.graphchi.walks.distributions

Examples of edu.cmu.graphchi.walks.distributions.DiscreteDistribution


        }
    }

    @Test
    public void testTopWithOnes() {
        DiscreteDistribution d1 = new DiscreteDistribution(new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,20,21,22,23,200,298});
        DiscreteDistribution avoidDist = DiscreteDistribution.createAvoidanceDistribution(new int[]{12, 15, 20});
        IdCount[] top = d1.getTop(10);
        assertEquals(10, top.length);

        DiscreteDistribution mergedWithAvoid = DiscreteDistribution.merge(d1, avoidDist);
        IdCount[] top2 = mergedWithAvoid.getTop(10);
        assertEquals(10, top2.length);
    }
View Full Code Here


        assertEquals(10, top2.length);
    }

    @Test
    public void testFiltering() {
        DiscreteDistribution d1 = new DiscreteDistribution(new int[] {1,1,1,8,8,8,9,22,22,22,22,22,333,333,333,333,333,333,333,333});
        assertEquals(3, d1.getCount(1));
        assertEquals(3, d1.getCount(8));
        assertEquals(1, d1.getCount(9));
        assertEquals(5, d1.getCount(22));
        assertEquals(8, d1.getCount(333));

        DiscreteDistribution notReallyFiltered = d1.filteredAndShift(1);
        assertTrue(notReallyFiltered == d1);

        DiscreteDistribution filtered = d1.filteredAndShift(4);
        assertEquals(0, filtered.getCount(1));
        assertEquals(0, filtered.getCount(8));
        assertEquals(0, filtered.getCount(9));
        assertEquals(5 - 3, filtered.getCount(22));
        assertEquals(8 - 3, filtered.getCount(333));
        assertEquals(2, filtered.size());

        // Check that avoided ones are not filtered
        DiscreteDistribution filteredWithAnAvoid = DiscreteDistribution.merge(d1,
                DiscreteDistribution.createAvoidanceDistribution(new int[]{99, 108})).filteredAndShift(4);

        assertEquals(0, filteredWithAnAvoid.getCount(1));
        assertEquals(0, filteredWithAnAvoid.getCount(8));
        assertEquals(0, filteredWithAnAvoid.getCount(9));
        assertEquals(5 - 3, filteredWithAnAvoid.getCount(22));
        assertEquals(8 - 3, filteredWithAnAvoid.getCount(333));
        assertEquals(-1, filteredWithAnAvoid.getCount(99));
        assertEquals(-1, filteredWithAnAvoid.getCount(108));

        DiscreteDistribution filteredAll = d1.filteredAndShift(100);
        DiscreteDistribution filteredAll2 = filtered.filteredAndShift(100);

        assertEquals(0, filteredAll.getCount(1));
        assertEquals(0, filteredAll.getCount(8));
        assertEquals(0, filteredAll.getCount(9));
        assertEquals(0, filteredAll.getCount(22));
        assertEquals(0, filteredAll.getCount(333));
        assertEquals(0, filteredAll2.getCount(1));
        assertEquals(0, filteredAll2.getCount(8));
        assertEquals(0, filteredAll2.getCount(9));
        assertEquals(0, filteredAll2.getCount(22));
        assertEquals(0, filteredAll2.getCount(333));

        assertEquals(0, filteredAll.size());
        assertEquals(0, filteredAll2.size());
    }
View Full Code Here

                n = r.nextInt(10000);
            } while (countToId.containsKey(n)); // Unique count keys
            countToId.put(n, i);
            insertMultiple(workArr, i, n);
        }
        DiscreteDistribution dist = new DiscreteDistribution(toIntArray(workArr));


        /* Then insert some edges to avoid */
        int[] avoids = new int[] {0, 2, 4, 32,33, 66, 67,6899, 102, 184};
        DiscreteDistribution avoidDistr = DiscreteDistribution.createAvoidanceDistribution(avoids);

        // Test the merge works both ways
        DiscreteDistribution mergedL = DiscreteDistribution.merge(dist, avoidDistr);
        DiscreteDistribution mergedR = DiscreteDistribution.merge(avoidDistr, dist);

        for(int a : avoids) {
            assertEquals(-1, avoidDistr.getCount(a));
            assertEquals(-1, mergedL.getCount(a));
            assertEquals(-1, mergedR.getCount(a));
        }

        IdCount[] top = dist.getTop(10);
        int j = 0;
        HashSet<Integer> avoidSet = new HashSet<Integer>();
View Full Code Here

TOP

Related Classes of edu.cmu.graphchi.walks.distributions.DiscreteDistribution

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.