Package edu.cmu.graphchi.util

Examples of edu.cmu.graphchi.util.IdCount


        final TreeSet<IdCount> topList = new TreeSet<IdCount>(new Comparator<IdCount>() {
            public int compare(IdCount a, IdCount b) {
                return (a.count > b.count ? -1 : (a.count == b.count ? (a.id < b.id ? -1 : (a.id == b.id ? 0 : 1)) : 1)); // Descending order
            }
        });
        IdCount least = null;
        for(int i=0; i<uniqueCount; i++) {
            if (topList.size() < topN) {
                topList.add(new IdCount(ids[i], counts[i]));
                least = topList.last();
            } else {
                if (counts[i] > least.count) {
                    topList.remove(least);
                    topList.add(new IdCount(ids[i], counts[i]));
                    least = topList.last();
                }
            }
            if (topList.size() > topN) throw new RuntimeException("Top list too big: " + topList.size());
View Full Code Here


        /* Take only top */
        int k = 20;
        TreeSet<IdCount> counts = new TreeSet<IdCount>();
        for(Map.Entry<Integer, Integer> e : friendsOfFriends.entrySet()) {
            if (counts.size() < k) {
                counts.add(new IdCount(translator.backward(e.getKey()), e.getValue()));
            } else {
                int smallest = counts.last().count;
                if (e.getValue() > smallest) {
                    //counts.remove(counts.last());
                    counts.pollLast();
                    counts.add(new IdCount(translator.backward(e.getKey()), e.getValue()));
                }
            }
        }

        String result = "";
View Full Code Here

        IdCount[] top = dist.getTop(10);


        int j = 0;
        for(Map.Entry <Integer, Integer> e : countToId.entrySet()) {
            IdCount topEntryJ = top[j];
            assertEquals((int)e.getValue(), topEntryJ.id);
            assertEquals((int)e.getKey(), topEntryJ.count);
            j++;
            if (top.length <= j) {
                assertEquals(10, j);
View Full Code Here

        IdCount[] top = dist.getTop(10);
        int j = 0;
        HashSet<Integer> avoidSet = new HashSet<Integer>();
        for(int a : avoids) avoidSet.add(a);
        for(Map.Entry <Integer, Integer> e : countToId.entrySet()) {
            IdCount topEntryJ = top[j];

            if (!avoidSet.contains(e.getKey())) {
                assertEquals((int)e.getValue(), topEntryJ.id);
                assertEquals((int)e.getKey(), topEntryJ.count);
                j++;
View Full Code Here

TOP

Related Classes of edu.cmu.graphchi.util.IdCount

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.