Results 1 to 3 of 3
  1. #1
    javakar is offline Member
    Join Date
    Mar 2014
    Posts
    1
    Rep Power
    0

    Lightbulb what is this error on hasnext code in webgraph

    i wrote piece of code ( below) and i work on web graph However, I am using the web graph package include
    Java Code:
    it.unimi.dsi.webgraph.ImmutableGraph
    but show error in
    Java Code:
    hasnext()
    Java Code:
     (while(iter.hasNext())
    and show java doc not found. I work with netbeans7.4 and webgraph package 3.3.1 .
    Java Code:
    package aolgraphexample;
     
    import java.io.IOException;
    import it.unimi.dsi.webgraph.ImmutableGraph;
    import it.unimi.dsi.webgraph.NodeIterator;
    import it.unipi.di.graph.GraphLabeler;
    import it.unipi.di.util.Utils;
     
    public class AOLGraphExample {
     
        /**
         * Invoke this class using two parameters: 1) the WebGraph basename (string
         * "webgraph/wg-aol" for the AOL dataset) 2) the GraphLabeler configuration
         * file (string "graphlabeler/graphlabeler.conf" for the AOL dataset)
         */
        public static void main(String[] args) throws Exception {
     
            // -----------------------------------------------------
            // PART ONE
     
            // WebGraph basename
            // String graphFile = args[0];
            String graphFile = "webgraph/wg-aol";
     
            // Name of the GraphLabeler configuration file
            String labelerFile = "graphlabeler/graphlabeler.conf";
     
            System.out.print(" >> Opening databases... ");
     
            // Take the starting time
            long start = System.currentTimeMillis();
     
            // load the graph structure in memory (i.e. WebGraph)
            ImmutableGraph graph = ImmutableGraph.load(graphFile);
     
            // load the data structure for the vertex/edge labels in memory (i.e.
            // GraphLabeler)
            GraphLabeler labeler = GraphLabeler.load(labelerFile);
     
            // print the elapsed time for the first part
            System.out.println("done in: " + Utils.elapsedTime(start, System.currentTimeMillis()));
            // -----------------------------------------------------
     
            System.out.println(" >> Running test N.1");
     
            // [TEST 1]
            //
            // For each vertex, fetch the labels of its adjacent vertices in the
            // graph.
            // This method will fetch ~21.5 million of textual labels (edges are
            // undirected).
            neighborsLabeling(graph, labeler);
     
            System.out.println(" >> Running test N.2");
     
            // [TEST 2]
            //
            // For each vertex, fetch the value of the attribute "click" for each of
            // its outgoing edges.
            // This method will fetch ~21.5 million textual values (edges are
            // undirected).
            // Recall that the available attributes are: "click", "session", "time"
            // and "rank"
            fetchAttribute(graph, labeler, "click");
     
            // close the labeler and release its resources
            labeler.close();
        }
     
        private static void neighborsLabeling(ImmutableGraph graph, GraphLabeler labeler) throws IOException {
     
            // count how many labels has been fetched so far
            int counter = 0;
     
            // the total number of nodes in the graph
            int numNodes = graph.numNodes();
     
            // take the starting time
            long start = System.currentTimeMillis();
     
            double perc = 0;
     
            // iterate over the vertices of the graph
            NodeIterator iter = graph.nodeIterator();
     
        [COLOR="#FF0000"]    while (iter.hasNext()) [/COLOR]{
     
                // the next node
                int node = iter.next();
     
                // print the percentage of nodes examined so far
                perc = printPerc(node, numNodes, perc);
     
                // fetch the adjacency list of the current "node" by using WebGraph
                // valid positions are those from 0 to outdegree(node)
                int[] succ = iter.successorArray();
     
                // fetch the labels in memory (then discard it)
                String[] labels = labeler.getVertexLabels(succ, 0, iter.outdegree());
     
                // count how many strings have been fetched so far
                counter += labels.length;
            }
     
            // compute the overall elapsed time
            long elapsed = System.currentTimeMillis() - start;
     
            // print some statistics on stdout
            printStats(counter, elapsed);
        }
     
        private static void fetchAttribute(ImmutableGraph graph, GraphLabeler labeler, String attribute) throws IOException {
     
            // count how many labels have been fetched so far
            int counter = 0;
     
            // the total number of nodes in the graph
            int numNodes = graph.numNodes();
     
            // take the starting time
            long start = System.currentTimeMillis();
     
            double perc = 0;
            for (int node = 0; node < numNodes; node++) {
     
                // print the percentage of nodes examined so far
                perc = printPerc(node, numNodes, perc);
     
                // fetch the value of the requested "attribute" for each edge
                // outgoing from "node"
                String[] values = labeler.getOutgoingAttribute(node, attribute);
     
                // count how many labels have been fetched so far
                counter += values.length;
            }
     
            // compute the overall elapsed time
            long elapsed = System.currentTimeMillis() - start;
     
            // print some statistics on stdout
            printStats(counter, elapsed);
        }
     
        private static double printPerc(int node, int numNodes, double percLimit) {
            int perc = (int)(node / (double)numNodes * 100);
            if (perc >= percLimit || node == 0) {
                if (node == 0)
                    System.out.print(" >> Progress: ");
                System.out.print(perc + "% ");
                percLimit += 10;
            }
     
            return percLimit;
        }
     
        private static void printStats(int count, long elapsed) {
     
            printPerc(1, 1, 0); // print 100%
     
            int rate = (int)(count / (elapsed / 1000d)); // strings/sec
     
            System.out.println();
            System.out.println(" >> Rate: " + rate + " string/sec");
            System.out.println(" >> Fetched strings: " + count);
            System.out.println(" >> Overall time: " + Utils.elapsedTime(elapsed));
        }
    }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,021
    Rep Power
    6

    Default Re: what is this error on hasnext code in webgraph

    Please show the exact error as it is displayed. And it is not necessary to comment every single line of code. Only comment those lines of code which do something which is not obvious. This will actually make you code easier to both read and maintain.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default Re: what is this error on hasnext code in webgraph

    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. WebGraph 3.0
    By java software in forum Java Software
    Replies: 0
    Last Post: 10-11-2011, 07:44 PM
  2. hasNext call
    By scotts in forum New To Java
    Replies: 4
    Last Post: 06-20-2010, 04:58 PM
  3. WebGraph 2.3
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 04-29-2008, 07:09 PM
  4. WebGraph 2.2
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 04-15-2008, 07:50 PM
  5. WebGraph 2.0
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 07-07-2007, 03:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •