Thank you for the reply, Stefan.
After having broken down my code to a minimal working example, I suspect that it has something to do with attributes and the layout or rendering algorithm. Here is code that produces the problem on my end.
/* ================================================== */
public static void main(String[] args) {Graph graph = new SingleGraph("graph");
graph.display(true);
graph.addAttribute("ui.quality");
graph.addAttribute("ui.antialias");
graph.addAttribute("ui.quality");
Generator generator = new BarabasiAlbertGenerator();
generator.addSink(graph);
generator.begin();
for (int i = 0; i < 100; i++) {
generator.nextEvents();
}
generator.end();
graph.clear();
graph.addAttribute("ui.antialias");
/* ================================================== */
generator = new BarabasiAlbertGenerator();
generator.addSink(graph);
generator.begin();
for (int i = 0; i < 100; i++) {
generator.nextEvents();
}
generator.end();
}
And here is the stacktrace it produces.
Exception in thread "Thread-1" org.miv.pherd.IdAlreadyInUseException: a particle with the same identifier already exists (0)
at org.miv.pherd.ParticleBox.addParticle(ParticleBox.java:103)
at org.graphstream.ui.layout.springbox.BarnesHutLayout.addNode(BarnesHutLayout.java:519)
at org.graphstream.ui.layout.springbox.BarnesHutLayout.nodeAdded(BarnesHutLayout.java:680)
at org.graphstream.stream.SourceBase.sendNodeAdded(SourceBase.java:323)
at org.graphstream.stream.thread.ThreadProxyPipe.processMessage(ThreadProxyPipe.java:481)
at org.graphstream.stream.thread.ThreadProxyPipe.pump(ThreadProxyPipe.java:264)
at org.graphstream.ui.layout.LayoutRunner.run(LayoutRunner.java:179)
Best regards,
Jacob
On Sep 13, 2013, at 10:29 AM, Stefan Balev <stefan.balev AT gmail.com> wrote:
> Hi Jacob,
>
> I could not reproduce this exception. I used the following code:
>
> public static void main(String[] args) {
> Graph graph = new SingleGraph("test");
>
> Generator generator = new BarabasiAlbertGenerator();
> generator.addSink(graph);
> generator.begin();
> for (int i = 0; i < 100; i++) {
> generator.nextEvents();
> }
> generator.end();
>
> graph.clear();
>
> generator = new BarabasiAlbertGenerator();
> generator.addSink(graph);
> generator.begin();
> for (int i = 0; i < 100; i++) {
> generator.nextEvents();
> }
> generator.end();
> }
>
> which executes without exception. Are you sure that you really call graph.clear()? If this is the case, could you provide more details, such as a minimal code reproducing the exception and the stack trace?
>
> Best,
>
> --
> Stefan
>
>
> 2013/9/13 Jacob M. H. Smith <jacob.m.h.smith AT gmail.com>
> Hello.
>
> I'm using GraphStream 1.2 and I'm having the following problem.
>
> I use the BarabasiAlbertGenerator to populate my graph like this:
>
> /* ============================================== */
> Generator generator = new BarabasiAlbertGenerator();
> generator.addSink(graph);
> generator.begin();
> for (int i = 0; i < 100; i++) {
> generator.nextEvents();
> }
> generator.end();
> /* ============================================== */
>
> Later in my program I call the graph's clear() method and do the same thing again. The second time I get an IdAlreadyInUseException.
>
> What am I doing wrong? Am I using the generator or the graph in a way that wasn't intended?
>
> Best regards,
> Jacob
>
>
Archives gérées par MHonArc 2.6.16.