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++);
}
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2012-08-27
disgoseek
Did you figure out what's the problem, becuase i am facing the same problem
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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++);
}
}
disgoseek
Did you figure out what's the problem, becuase i am facing the same problem
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