Menu

NPE with KleinbergSmallWorldGenerator

Raymond
2009-11-14
2013-05-29
  • Raymond

    Raymond - 2009-11-14

    Hi, I'm trying to use the KleinbergSmallWorldGenerator to generate a graph, however I run into a NullPointerException when running the code.  Could someone help me with what's wrong?  The exception stack trace is:

        Exception in thread "main" java.lang.NullPointerException
    at edu.uci.ics.jung.algorithms.generators.random.KleinbergSmallWorldGenerator.create(KleinbergSmallWorldGenerator.java:165)
    at test.SmallWorldTest.main(SmallWorldTest.java:17)

    Here's the code I'm using:

        public class SmallWorldTest {

    public static void main(String args) {
    UndirectedSparseGraph.<Number, Number> getFactory();
    KleinbergSmallWorldGenerator<Number, Number> Generator = new KleinbergSmallWorldGenerator<Number, Number>(
    SparseGraph.<Number, Number> getFactory(), new VertexFactory(),
    new EdgeFactory(), 10, 1.6);
    Graph<Number, Number> graph22 = Generator.create();
    }

    private static class VertexFactory implements Factory<Number> {
    int i = 0;

    public Number create() {
    return new Integer(i++);
    }

    }

    private static class EdgeFactory implements Factory<Number> {
    int count = 0;

    public Number create() {
    return new Integer(count++);
    }

    }

     
  • Anonymous

    Anonymous - 2012-08-27

    disgoseek

    Did you figure out what's the problem, becuase i am facing the same problem

     
  • Joshua O'Madadhain

    Salvador, please post your complete stack trace and specify which version of JUNG you're using.  The original problem report doesn't appear to make any sense based on the current code (line 165 doesn't look like a likely place for an NPE).

    Joshua

     

Log in to post a comment.