Added NetworkDumper to Denis' Generator
This commit is contained in:
parent
ad87916472
commit
89cf73f20f
@ -6,10 +6,12 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import analysis.NetworkDumper;
|
||||
|
||||
import node.Node;
|
||||
|
||||
public class RandomGenerator {
|
||||
public static int initNodeCount = 20;
|
||||
public static int initNodeCount = 99;
|
||||
public static double initBirthRate = 0.50;
|
||||
public static double initDeathRate = 0.20;
|
||||
public static int initRounds = 13;
|
||||
@ -47,8 +49,16 @@ public class RandomGenerator {
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case "br":
|
||||
//
|
||||
case "dump":
|
||||
nodes.get(0).gatherInformationOfNetwork();
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
NetworkDumper d = new NetworkDumper(nodes.get(0));
|
||||
d.write(d.networkToDot(nodes.get(0).getNetwork()));
|
||||
break;
|
||||
case "add":
|
||||
add(count);
|
||||
|
||||
@ -26,7 +26,7 @@ public class RandomGenerator2 {
|
||||
public RandomGenerator2() {
|
||||
firstNode = new Node();
|
||||
nodes.add(firstNode);
|
||||
new NetworkDumper(firstNode);
|
||||
new NetworkDumper(firstNode).start();
|
||||
|
||||
for (int i = 0; i < START_NODES - 1; i++) {
|
||||
spawn();
|
||||
|
||||
@ -17,6 +17,9 @@ public class NetworkDumper implements Runnable {
|
||||
public NetworkDumper(Node n) {
|
||||
this.node = n;
|
||||
|
||||
}
|
||||
|
||||
public void start() {
|
||||
new Thread(this).start();
|
||||
}
|
||||
|
||||
@ -50,7 +53,7 @@ public class NetworkDumper implements Runnable {
|
||||
return s.split(":")[1];
|
||||
}
|
||||
|
||||
private void write(String s) {
|
||||
public void write(String s) {
|
||||
try {
|
||||
// Create file
|
||||
FileWriter fstream = new FileWriter("graphs/"
|
||||
|
||||
@ -33,7 +33,7 @@ public class Node {
|
||||
/**
|
||||
* Saves the neighbor of each node in the network
|
||||
*/
|
||||
private Map<String, List<String>> network = new HashMap<>();
|
||||
private Map<String, List<String>> network = new HashMap<String, List<String>>();
|
||||
|
||||
private volatile Thread thread;
|
||||
private UDPHandler udpListen;
|
||||
@ -221,6 +221,8 @@ public class Node {
|
||||
}
|
||||
|
||||
public void gatherInformationOfNetwork() {
|
||||
network = new HashMap<String, List<String>>();
|
||||
|
||||
try {
|
||||
byte[] myAddr = BufferUtil.addrToBytes(((InetSocketAddress) channel
|
||||
.getLocalAddress()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user