Esempio n. 1
0
    def test_snowball_dirnet(self):
        net = pynet.Net()
        net[0][1] = 1
        net[0][2] = 2
        net[1][2] = 12
        net[2][1] = 21
        net[2][3] = 23
        net[4][3] = 43

        sball = transforms.snowball(net, 0, 1)
        self.assertTrue(len(sball) == 3)
        self.assertTrue(len([1 for i, j, w in sball.edges if w > 0]) == 2)
        self.assertTrue(isinstance(sball, type(net)))
        for i, j, w in sball.edges:
            self.assertTrue(w == net[i][j])

        sball = transforms.snowball(net, 0, 1, True)
        self.assertTrue(len(sball) == 3)
        self.assertTrue(len([1 for i, j, w in sball.edges if w > 0]) == 4)
        for i, j, w in sball.edges:
            self.assertTrue(w == net[i][j])

        sball = transforms.snowball(net, 3, 2, False)
        self.assertTrue(len(sball) == 5)
        self.assertTrue(len([1 for i, j, w in sball.edges if w > 0]) == 5)
        for i, j, w in sball.edges:
            self.assertTrue(w == net[i][j])

        sball = transforms.snowball(net, 3, 2, True)
        self.assertTrue(len(sball) == 5)
        self.assertTrue(len([1 for i, j, w in sball.edges if w > 0]) == 6)
        for i, j, w in sball.edges:
            self.assertTrue(w == net[i][j])
Esempio n. 2
0
	def test_snowball_dirnet(self):
		net = pynet.Net()
		net[0][1] = 1
		net[0][2] = 2
		net[1][2] = 12
		net[2][1] = 21
		net[2][3] = 23
		net[4][3] = 43

		sball = transforms.snowball(net, 0, 1)
		self.assertTrue(len(sball) == 3)
		self.assertTrue(len([1 for i,j,w in sball.edges if w > 0]) == 2)
		self.assertTrue(isinstance(sball, type(net)))
		for i,j,w in sball.edges:
			self.assertTrue(w == net[i][j])

		sball = transforms.snowball(net, 0, 1, True)
		self.assertTrue(len(sball) == 3)
		self.assertTrue(len([1 for i,j,w in sball.edges if w > 0]) == 4)
		for i,j,w in sball.edges:
			self.assertTrue(w == net[i][j])

		sball = transforms.snowball(net, 3, 2, False)
		self.assertTrue(len(sball) == 5)
		self.assertTrue(len([1 for i,j,w in sball.edges if w > 0]) == 5)
		for i,j,w in sball.edges:
			self.assertTrue(w == net[i][j])
		
		sball = transforms.snowball(net, 3, 2, True)
		self.assertTrue(len(sball) == 5)
		self.assertTrue(len([1 for i,j,w in sball.edges if w > 0]) == 6)		
		for i,j,w in sball.edges:
			self.assertTrue(w == net[i][j])
Esempio n. 3
0
    def test_snowball_symmnet(self):
        net = pynet.SymmNet()
        net[0][1] = 1
        net[0][2] = 2
        net[1][2] = 12
        net[2][3] = 23
        net[3][4] = 34

        sball = transforms.snowball(net, 0, 1)
        self.assertTrue(len(sball) == 3)
        self.assertTrue(len(list(sball.edges)) == 2)
        self.assertTrue(isinstance(sball, type(net)))
        for i, j, w in sball.edges:
            self.assertTrue(w == net[i][j])

        sball = transforms.snowball(net, 0, 1, True)
        self.assertTrue(len(list(sball.edges)) == 3)
        for i, j, w in sball.edges:
            self.assertTrue(w == net[i][j])

        sball = transforms.snowball(net, 3, 2, False)
        self.assertTrue(len(sball) == 5)
        self.assertTrue(len(list(sball.edges)) == 4)
        for i, j, w in sball.edges:
            self.assertTrue(w == net[i][j])

        sball = transforms.snowball(net, 3, 2, True)
        self.assertTrue(len(sball) == 5)
        self.assertTrue(len(list(sball.edges)) == 5)
        for i, j, w in sball.edges:
            self.assertTrue(w == net[i][j])
Esempio n. 4
0
	def test_snowball_symmnet(self):
		net = pynet.SymmNet()
		net[0][1] = 1
		net[0][2] = 2
		net[1][2] = 12
		net[2][3] = 23
		net[3][4] = 34

		sball = transforms.snowball(net, 0, 1)
		self.assertTrue(len(sball) == 3)
		self.assertTrue(len(list(sball.edges)) == 2)
		self.assertTrue(isinstance(sball, type(net)))
		for i,j,w in sball.edges:
			self.assertTrue(w == net[i][j])

		sball = transforms.snowball(net, 0, 1, True)
		self.assertTrue(len(list(sball.edges)) == 3)
		for i,j,w in sball.edges:
			self.assertTrue(w == net[i][j])

		sball = transforms.snowball(net, 3, 2, False)
		self.assertTrue(len(sball) == 5)
		self.assertTrue(len(list(sball.edges)) == 4)
		for i,j,w in sball.edges:
			self.assertTrue(w == net[i][j])
		
		sball = transforms.snowball(net, 3, 2, True)
		self.assertTrue(len(sball) == 5)
		self.assertTrue(len(list(sball.edges)) == 5)
		for i,j,w in sball.edges:
			self.assertTrue(w == net[i][j])