@Test public void testPushPullER() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting PP test on ephemeral Erdos-Renyi Graph\n"); ERModel<TimeStampEdge> ER100 = new ERModel<>(0.75, 100, "TimeStampEdge"); EphemeralDiffusion diffuse = new EphemeralDiffusion(); System.out.println( "Setting timestamp parameters to N = 10 with a bound of 10\n" + "Equivalent to IC on normal graph with at most 10 infection periods\n"); diffuse.setTimestampParams(10, 10); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = ER100.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.PushPull(ER100, seed); System.out.println(rst.getStats()); assertEquals(ER100.getVertexCount(), rst.getInfectionSize()); System.out.println("Test Complete"); }
@Test public void testLinearThresholdER() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting LT test on Erdos-Renyi Graph\n"); ERModel<DiffusionEdge> ER100 = new ERModel<>(1.0, 100, "DiffusionEdge"); DiffusionMechanism diffuse = new DiffusionMechanism(); diffuse.setThreshold(0.0); System.out.println("setting Threshold to 0%\n"); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = ER100.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.LinearThreshold(ER100, seed); System.out.println(rst.getStats()); assertEquals(ER100.getVertexCount(), rst.getInfectionSize()); System.out.println("setting Threshold to 100%\n"); diffuse.setThreshold(1.0); rst = diffuse.LinearThreshold(ER100, seed); System.out.println(rst.getStats()); assertEquals(3, rst.getInfectionSize()); System.out.println("Test Complete"); }
@Test public void testInitialCascadeER() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting IC test on Erdos-Renyi Graph\n"); ERModel<DiffusionEdge> ER100 = new ERModel<>(0.75, 100, "DiffusionEdge"); DiffusionMechanism diffuse = new DiffusionMechanism(); diffuse.setInfectProb(1.0); System.out.println("Setting infection probability to 100%\n"); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = ER100.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.InitialCascade(ER100, seed); System.out.println(rst.getStats()); assertEquals(ER100.getVertexCount(), rst.getInfectionSize()); diffuse.setInfectProb(0.0); System.out.println("Setting infection probability to 0%\n"); rst = diffuse.InitialCascade(ER100, seed); System.out.println(rst.getStats()); assertEquals(3, rst.getInfectionSize()); System.out.println("Test Complete"); }
@Test public void testTimeRespectingDiffusionER() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting Time Respecting Diffusion test on ephemeral Erdos-Renyi graph \n"); ERModel<TimeStampEdge> ER8 = new ERModel<>(0.75, 8, "TimeStampEdge"); for (int i = 0; i < 92; i++) { ER8.addRandomNode(); } EphemeralDiffusion diffuse = new EphemeralDiffusion(); diffuse.setInfectProb(1.0); System.out.println("Setting infection probability to 100%\n"); System.out.println("Setting timestamp parameters to N = 10 with a bound of 10\n"); diffuse.setTimestampParams(10, 10); System.out.println("Setting the lifespan of an infection to 10"); diffuse.setInfectionLifeTime(10); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = ER8.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.TimeRespectingCascade(ER8, seed); System.out.println(rst.getStats()); assertEquals(ER8.getVertexCount(), rst.getInfectionSize()); diffuse.setInfectProb(0.0); System.out.println("Setting infection probability to 0%\n"); rst = diffuse.TimeRespectingCascade(ER8, seed); System.out.println(rst.getStats()); assertEquals(3, rst.getInfectionSize()); System.out.println("Test Complete"); }
@Test public void testPushPullER() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting PP test on Erdos-Renyi Graph\n"); ERModel<DiffusionEdge> ER100 = new ERModel<>(0.75, 100, "DiffusionEdge"); DiffusionMechanism diffuse = new DiffusionMechanism(); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = ER100.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.PushPull(ER100, seed); System.out.println(rst.getStats()); assertEquals(ER100.getVertexCount(), rst.getInfectionSize()); System.out.println("Test Complete"); }