diff python/testgraph.py @ 277:046017431c6a

Started register allocator
author Windel Bouwman
date Thu, 26 Sep 2013 21:14:25 +0200
parents
children 9fca39eebe50
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/testgraph.py	Thu Sep 26 21:14:25 2013 +0200
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import unittest
+import graph
+
+class GraphTestCase(unittest.TestCase):
+    def testEdge(self):
+        g = graph.Graph(False)
+        n1 = g.newNode()
+        n2 = g.newNode()
+        g.addEdge(n1, n2)
+        self.assertTrue(g.hasEdge(n2, n1))
+        self.assertTrue(g.hasEdge(n1, n2))
+        g.delNode(n1)
+        g.delNode(n2)
+
+    def testDegree(self):
+        g = graph.Graph(False)
+        n1 = g.newNode()
+        n2 = g.newNode()
+        n3 = g.newNode()
+        g.addEdge(n1, n2)
+        g.addEdge(n1, n3)
+        self.assertEqual(2, n1.Degree)
+        self.assertEqual(1, n2.Degree)
+        g.delNode(n2)
+        self.assertEqual(1, n1.Degree)
+
+class DigraphTestCase(unittest.TestCase):
+    pass
+        
+
+if __name__ == '__main__':
+    unittest.main()
+