@Test public void testPushPullKtree() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting PP test on KTree\n"); KTree<DiffusionEdge> KT8 = new KTree(8, "DiffusionEdge"); for (int i = 0; i < 100; i++) { KT8.addRandomVertex(); } DiffusionMechanism diffuse = new DiffusionMechanism(); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = KT8.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.PushPull(KT8, seed); System.out.println(rst.getStats()); assertEquals(KT8.getVertexCount(), rst.getInfectionSize()); System.out.println("Test Complete"); }
@Test public void testPushPullKtree() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting PP test on Ephemeral KTree\n"); KTree<TimeStampEdge> KT8 = new KTree(8, "TimeStampEdge"); for (int i = 0; i < 100; i++) { KT8.addRandomVertex(); } 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 = KT8.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.PushPull(KT8, seed); System.out.println(rst.getStats()); assertEquals(KT8.getVertexCount(), rst.getInfectionSize()); System.out.println("Test Complete"); }
@Test public void testLinearThresholdKtree() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting LT test on KTree \n"); KTree<DiffusionEdge> KT8 = new KTree(8, "DiffusionEdge"); for (int i = 0; i < 92; i++) { KT8.addRandomVertex(); } DiffusionMechanism diffuse = new DiffusionMechanism(); diffuse.setThreshold(0.0); System.out.println("Setting Threshold to 0%\n"); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = KT8.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.LinearThreshold(KT8, seed); System.out.println(rst.getStats()); assertEquals(KT8.getVertexCount(), rst.getInfectionSize()); diffuse.setThreshold(1.0); System.out.println("Setting Threshold to 100%\n"); rst = diffuse.LinearThreshold(KT8, seed); System.out.println(rst.getStats()); assertEquals(3, rst.getInfectionSize()); System.out.println("Test Complete"); }
@Test public void testTimeRespectingDiffusionKtree() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting Time Dependent test on ephemeral KTree \n"); KTree<TimeStampEdge> KT8 = new KTree(8, "TimeStampEdge"); for (int i = 0; i < 92; i++) { KT8.addRandomVertex(); } EphemeralDiffusion diffuse = new EphemeralDiffusion(); diffuse.setInfectProb(1); 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 = KT8.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.TimeRespectingCascade(KT8, seed); System.out.println(rst.getStats()); assertEquals(KT8.getVertexCount(), rst.getInfectionSize()); diffuse.setInfectProb(0.0); System.out.println("Setting infection probability to 0% \n"); rst = diffuse.TimeRespectingCascade(KT8, seed); System.out.println(rst.getStats()); assertEquals(3, rst.getInfectionSize()); System.out.println("Test Complete"); }