4
class GameTests(unittest.TestCase):
7
self.failUnless(isinstance(g, Graph))
8
g = Graph.GRG(50, 0.2, True)
9
self.failUnless(isinstance(g, Graph))
10
g, xs, ys = Graph.GRG(50, 0.2, True, True)
11
self.failUnless(isinstance(g, Graph))
12
self.failUnless(isinstance(xs, list))
13
self.failUnless(isinstance(ys, list))
14
self.failUnless(isinstance(Layout(zip(xs,ys)), Layout))
16
def testForestFire(self):
17
g=Graph.Forest_Fire(100, 0.1)
18
self.failUnless(isinstance(g, Graph) and g.is_directed() == False)
19
g=Graph.Forest_Fire(100, 0.1, directed=True)
20
self.failUnless(isinstance(g, Graph) and g.is_directed() == True)
22
def testRecentDegree(self):
23
g=Graph.Recent_Degree(100, 5, 10)
24
self.failUnless(isinstance(g, Graph))
26
def testPreference(self):
27
g=Graph.Preference(100, [1, 1], [[1, 0], [0, 1]])
28
self.failUnless(isinstance(g, Graph) and len(g.clusters()) == 2)
30
g=Graph.Preference(100, [1, 1], [[1, 0], [0, 1]], attribute="type")
31
l=g.vs.get_attribute_values("type")
32
self.failUnless(min(l) == 0 and max(l) == 1)
34
def testAsymmetricPreference(self):
35
g=Graph.Asymmetric_Preference(100, [[0, 1], [1, 0]], [[0, 1], [1, 0]])
36
self.failUnless(isinstance(g, Graph) and len(g.clusters()) == 2)
38
g=Graph.Asymmetric_Preference(100, [[0, 1], [1, 0]], [[1, 0], [0, 1]],\
40
l=g.vs.get_attribute_values("type")
43
self.failUnless(min(l1) == 0 and max(l1) == 1 and
44
min(l2) == 0 and max(l2) == 1)
46
g=Graph.Asymmetric_Preference(100, [[0, 1], [1, 0]], [[1, 0], [0, 1]])
47
self.failUnless(isinstance(g, Graph) and len(g.clusters()) == 1)
49
def testWattsStrogatz(self):
50
g=Graph.Watts_Strogatz(1, 20, 1, 0.2)
51
self.failUnless(isinstance(g, Graph) and g.vcount()==20 and g.ecount()==20)
54
game_suite = unittest.makeSuite(GameTests)
55
return unittest.TestSuite([game_suite])
58
runner = unittest.TextTestRunner()
61
if __name__ == "__main__":