@Test public void testPushPullBA() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting PP test on ephemeral Barabosi-Albert Graph\n"); Barabasi_AlbertModel<TimeStampEdge> BA100 = new Barabasi_AlbertModel<>(3, 2, "TimeStampEdge"); for (int i = 0; i < 97; i++) { BA100.addRandomNode(); } 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 = BA100.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.PushPull(BA100, seed); System.out.println(rst.getStats()); assertEquals(BA100.getVertexCount(), rst.getInfectionSize()); }
@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 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 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 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 testLinearThresholdBA() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting LT test on Barabosi-Albert Graph\n"); Barabasi_AlbertModel<DiffusionEdge> BA100 = new Barabasi_AlbertModel<>(3, 2, "DiffusionEdge"); for (int i = 0; i < 97; i++) { BA100.addRandomNode(); } DiffusionMechanism diffuse = new DiffusionMechanism(); diffuse.setThreshold(0.0); System.out.println("Setting Threshold to 0%\n"); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = BA100.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.LinearThreshold(BA100, seed); System.out.println(rst.getStats()); assertEquals(BA100.getVertexCount(), rst.getInfectionSize()); diffuse.setThreshold(1.0); System.out.println("Setting Threshold to 100%\n"); rst = diffuse.LinearThreshold(BA100, seed); System.out.println(rst.getStats()); assertEquals(seed.size(), 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"); }
@Test public void testPushPullBA() throws Exception { System.out.println("-------------------------------------------"); System.out.println("Starting PP test on Barabosi-Albert Graph\n"); Barabasi_AlbertModel<DiffusionEdge> BA100 = new Barabasi_AlbertModel<>(3, 2, "DiffusionEdge"); for (int i = 0; i < 97; i++) { BA100.addRandomNode(); } DiffusionMechanism diffuse = new DiffusionMechanism(); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = BA100.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.PushPull(BA100, seed); System.out.println(rst.getStats()); assertEquals(BA100.getVertexCount(), rst.getInfectionSize()); }
@Test public void testTimeRespectinDiffusionBA() throws Exception { System.out.println("-------------------------------------------"); System.out.println( "Starting Time Respecting Diffusion test on ephemeral Barabosi-Albert Graph\n"); Barabasi_AlbertModel<TimeStampEdge> BA100 = new Barabasi_AlbertModel<>(3, 2, "TimeStampEdge"); for (int i = 0; i < 97; i++) { BA100.addRandomNode(); } EphemeralDiffusion diffuse = new EphemeralDiffusion(); System.out.println("Setting timestamp parameters to N = 10 with a bound of 10\n"); diffuse.setTimestampParams(10, 10); diffuse.setInfectProb(1.0); System.out.println("Setting infection probability to 100%\n"); System.out.println("Setting the lifespan of an infection to 10"); diffuse.setInfectionLifeTime(10); ArrayList<DiffusionVertex> seed = new ArrayList<>(); Iterator<DiffusionVertex> iter = BA100.getVertices().iterator(); for (int i = 0; i < 3; i++) { seed.add(iter.next()); } ResultSet rst = diffuse.TimeRespectingCascade(BA100, seed); System.out.println(rst.getStats()); assertEquals(BA100.getVertexCount(), rst.getInfectionSize()); diffuse.setInfectionLifeTime(2); diffuse.setInfectProb(0.5); System.out.println("Setting prob to 20% with lifetime of 2\n"); rst = diffuse.TimeRespectingCascade(BA100, seed); System.out.println(rst.getStats()); assertTrue( (seed.size() < rst.getInfectionSize()) && rst.getInfectionSize() < BA100.getVertexCount()); System.out.println("Test Complete"); }