Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: what is this error in hasnext in webgraph

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb what is this error in hasnext in webgraph

    i wrote piece of code ( below) and i work on web graph However, I am using the web graph package include

    it.unimi.dsi.webgraph.ImmutableGraph
    but show error in
    hasnext()
     (while(iter.hasNext()))
    and show java doc not found. I work with netbeans.

    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
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: what is this error in hasnext in webgraph

    Please copy the full text of the error message and paste it here. It has important info about the error.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what is this error in hasnext in webgraph

    cannot find symbol
    symbol: method hasNext()
    location: variable iter of type NodeIterator. any variable i created not recognize like iter.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: what is this error in hasnext in webgraph

    You need to read the API doc for the class to see the correct method to use.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Mar 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what is this error in hasnext in webgraph

    please more explain with example

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: what is this error in hasnext in webgraph

    I don't have the API doc for that package and those classes. You need to find the API doc for them and read them so you know what methods the NodeIterator class has and how to use them.

    --- Update ---

    Also posted at: what is this error on hasnext code in webgraph
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. CheckBox/Spinner error Error
    By vandy22 in forum Android Development
    Replies: 1
    Last Post: February 15th, 2014, 04:05 AM
  2. Replies: 3
    Last Post: November 30th, 2013, 05:52 PM
  3. Problems with A* Map Search - GC Overload Error and Null Error
    By puneeth.meruva in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 18th, 2013, 03:01 PM
  4. Replies: 4
    Last Post: October 15th, 2013, 04:33 AM
  5. Big problems with my hasNext method and outer loop! Please help!
    By Eclecstatic in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 26th, 2012, 08:55 AM

Tags for this Thread