Skip to content
Snippets Groups Projects
Commit a8c2d4e4 authored by gsavin's avatar gsavin
Browse files

Add constructors to customize maxDistance and maxDegree.

parent 2fe540ea
Branches
Tags
No related merge requests found
......@@ -68,7 +68,32 @@ public class LobsterGenerator extends BaseGenerator {
* Main constructor to a Lobster generator.
*/
public LobsterGenerator() {
nodes = new LinkedList<Data>();
this(2, -1);
}
/**
* Constructor allowing to customize maximum distance to the root path and
* maximum degree of nodes.
*
* @param maxDistance
* max distance to root path
* @param maxDegree
* max degree of nodes
*/
public LobsterGenerator(int maxDistance, int maxDegree) {
this.maxDistance = maxDistance;
this.maxDegree = maxDegree;
this.nodes = new LinkedList<Data>();
}
/**
* Constructor allowing to customize maximum distance to the root path.
*
* @param maxDistance
* max distance to root path
*/
public LobsterGenerator(int maxDistance) {
this(maxDistance, -1);
}
/*
......@@ -92,7 +117,7 @@ public class LobsterGenerator extends BaseGenerator {
do {
connectTo = nodes.get(random.nextInt(nodes.size()));
} while (connectTo.distance >= maxDistance
|| connectTo.degree() >= maxDegree);
|| (maxDegree > 0 && connectTo.degree() >= maxDegree));
Data newData = null;
......
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