Commit 6ce144de authored by gsavin's avatar gsavin

Fix the way where a node is selected to be connected to the new one.

parent 69d5d279
...@@ -75,18 +75,18 @@ import org.graphstream.algorithm.Toolkit; ...@@ -75,18 +75,18 @@ import org.graphstream.algorithm.Toolkit;
* <h2>Complexity</h2> * <h2>Complexity</h2>
* *
* <p> * <p>
* At each call to {@link #nextEvents()} at max k operations are run with * At each call to {@link #nextEvents()} at max k operations are run with k the
* k the average degree. * average degree.
* </p> * </p>
* *
* <h2>Example</h2> * <h2>Example</h2>
* *
* <pre> * <pre>
* Graph graph = new SingleGraph("Random"); * Graph graph = new SingleGraph(&quot;Random&quot;);
* Generator gen = new RandomGenerator(); * Generator gen = new RandomGenerator();
* gen.addSinkg(graph); * gen.addSinkg(graph);
* gen.begin(); * gen.begin();
* for(int i=0; i<100; i++) * for (int i = 0; i &lt; 100; i++)
* gen.nextEvents(); * gen.nextEvents();
* gen.end(); * gen.end();
* graph.display(); * graph.display();
...@@ -195,7 +195,11 @@ public class RandomGenerator extends BaseGenerator { ...@@ -195,7 +195,11 @@ public class RandomGenerator extends BaseGenerator {
// to the new node. // to the new node.
for (int i = 0; i < degree; ++i) { for (int i = 0; i < degree; ++i) {
String otherId = Toolkit.randomNode(internalGraph, random).getId(); String otherId;
do
otherId = Toolkit.randomNode(internalGraph, random).getId();
while (otherId == id && internalGraph.getNodeCount() > 1);
if (otherId != id) { if (otherId != id) {
String edgeId = getEdgeId(id, otherId); String edgeId = getEdgeId(id, otherId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment