Back to index

python-biopython  1.60
Public Member Functions
test_Pathway.MultiGraphTestCase Class Reference

List of all members.

Public Member Functions

def testEquals
def testNodes
def testEdges
def testRemoveNode

Detailed Description

Definition at line 78 of file test_Pathway.py.


Member Function Documentation

Definition at line 112 of file test_Pathway.py.

00112 
00113     def testEdges(self):
00114         a = MultiGraph(['a','b','c','d'])
00115         a.add_edge('a','b','label1')
00116         self.assertEqual(a.child_edges('a'), [('b','label1')]) #, "incorrect child edges")
00117         a.add_edge('a','b','label2')
00118         l = a.child_edges('a')
00119         l.sort()
00120         self.assertEqual(l, [('b','label1'),('b','label2')]) #, "incorrect child edges")
00121         a.add_edge('b','a','label2')
00122         self.assertEqual(a.parent_edges('a'), [('b','label2')]) #, "incorrect parent edges")
00123         a.add_edge('b','c','label3')
00124         self.assertEqual(a.parent_edges('c'), [('b','label3')]) #, "incorrect parent edges")
00125         l = a.children('b')
00126         l.sort()
00127         self.assertEqual(l, ['a', 'c'], "incorrect children")
00128         self.assertEqual(a.children('d'), [], "incorrect children for singleton")
00129         self.assertEqual(a.parents('a'), ['b'], "incorrect parents")

Definition at line 80 of file test_Pathway.py.

00080 
00081     def testEquals(self):
00082         a = MultiGraph(['a','b','c'])
00083         a.add_edge('a','b','label1')
00084         a.add_edge('b','c','label1')
00085         a.add_edge('b','a','label2')
00086         b = MultiGraph(['a','b','c'])
00087         self.assertNotEqual(a, b, "equal to similar nodes, no edges")
00088         b.add_edge('a','b','label1')
00089         self.assertNotEqual(a, b, "equal to similar nodes, edge subset")
00090         b.add_edge('b','c','label1')
00091         b.add_edge('b','a','label2')
00092         self.assertEqual(a, b, "not equal to similar")
00093         c = MultiGraph(['a','b','c'])
00094         c.add_edge('a','b','label2')
00095         c.add_edge('b','c','label2')
00096         c.add_edge('b','a','label1')
00097         self.assertNotEqual(a, c, "equal to similar with different labels")
00098         self.assertNotEqual(c, MultiGraph(), "equal to empty graph")
00099         self.assertEqual(MultiGraph(), MultiGraph(), "empty graph not equal to self")

Definition at line 100 of file test_Pathway.py.

00100 
00101     def testNodes(self):
00102         a = MultiGraph()
00103         self.assertEqual(a.nodes(), [], "default graph not empty")
00104         a.add_node('a')
00105         self.assertEqual(a.nodes(), ['a'], "one node not added")
00106         a.add_node('a')
00107         self.assertEqual(a.nodes(), ['a'], "duplicate node added")
00108         a.add_node('b')
00109         l = a.nodes()
00110         l.sort()
00111         self.assertEqual(l, ['a', 'b'], "second node not added")

Definition at line 130 of file test_Pathway.py.

00130 
00131     def testRemoveNode(self):
00132         a = MultiGraph(['a','b','c','d','e'])
00133         a.add_edge('a','e','label1')
00134         self.assertEqual(repr(a), "<MultiGraph: ('a': ('e', 'label1'))('b': )('c': )('d': )('e': )>")
00135         a.add_edge('b','e','label1')
00136         a.add_edge('c','e','label2')
00137         a.add_edge('d','e','label3')
00138         a.add_edge('e','d','label4')
00139         a.add_edge('a','b','label5')
00140         self.assertEqual(repr(a), "<MultiGraph: ('a': ('b', 'label5'),('e', 'label1'))('b': ('e', 'label1'))('c': ('e', 'label2'))('d': ('e', 'label3'))('e': ('d', 'label4'))>")
00141         a.remove_node('e')
00142         self.assertEqual(repr(a), "<MultiGraph: ('a': ('b', 'label5'))('b': )('c': )('d': )>")
00143         b = MultiGraph(['a','b','c','d'])
00144         b.add_edge('a','b','label5')
00145         self.assertEqual(repr(b), "<MultiGraph: ('a': ('b', 'label5'))('b': )('c': )('d': )>")
00146         self.assertEqual(repr(a), repr(b))
00147         self.assertEqual(a, b)#, "incorrect node removal")
00148 
        

The documentation for this class was generated from the following file: