Package solvcon :: Package tests :: Module test_connection
[hide private]
[frames] | no frames]

Source Code for Module solvcon.tests.test_connection

 1  # -*- coding: UTF-8 -*- 
 2   
 3  from unittest import TestCase 
 4   
5 -class TestSpanningTree(TestCase):
6 - def test_spanningtree(self):
7 from ..connection import SpanningTreeNode 8 # graph data. 9 graph = [ 10 [1, 3, 5], 11 [0, 2, 3, 4], 12 [1, 4, 7], 13 [0, 1, 5, 6], 14 [1, 2, 6, 9], 15 [0, 3, 8], 16 [1, 3, 4, 8, 9], 17 [2, 9], 18 [5, 6], 19 [4, 6, 7], 20 ] 21 # construct spanning tree. 22 head = SpanningTreeNode(val=0, level=0) 23 visited = dict() 24 head.traverse(graph, visited) 25 # test results. 26 self.assertEqual(len(visited), len(graph))
27