Back to index

python3.2  3.2.2
Public Member Functions
test.test_set.TestGraphs Class Reference

List of all members.

Public Member Functions

def test_cube
def test_cuboctahedron

Detailed Description

Definition at line 1753 of file test_set.py.


Member Function Documentation

Definition at line 1755 of file test_set.py.

01755 
01756     def test_cube(self):
01757 
01758         g = cube(3)                             # vert --> {v1, v2, v3}
01759         vertices1 = set(g)
01760         self.assertEqual(len(vertices1), 8)     # eight vertices
01761         for edge in g.values():
01762             self.assertEqual(len(edge), 3)      # each vertex connects to three edges
01763         vertices2 = set(v for edges in g.values() for v in edges)
01764         self.assertEqual(vertices1, vertices2)  # edge vertices in original set
01765 
01766         cubefaces = faces(g)
01767         self.assertEqual(len(cubefaces), 6)     # six faces
01768         for face in cubefaces:
01769             self.assertEqual(len(face), 4)      # each face is a square

Here is the call graph for this function:

Definition at line 1770 of file test_set.py.

01770 
01771     def test_cuboctahedron(self):
01772 
01773         # http://en.wikipedia.org/wiki/Cuboctahedron
01774         # 8 triangular faces and 6 square faces
01775         # 12 indentical vertices each connecting a triangle and square
01776 
01777         g = cube(3)
01778         cuboctahedron = linegraph(g)            # V( --> {V1, V2, V3, V4}
01779         self.assertEqual(len(cuboctahedron), 12)# twelve vertices
01780 
01781         vertices = set(cuboctahedron)
01782         for edges in cuboctahedron.values():
01783             self.assertEqual(len(edges), 4)     # each vertex connects to four other vertices
01784         othervertices = set(edge for edges in cuboctahedron.values() for edge in edges)
01785         self.assertEqual(vertices, othervertices)   # edge vertices in original set
01786 
01787         cubofaces = faces(cuboctahedron)
01788         facesizes = collections.defaultdict(int)
01789         for face in cubofaces:
01790             facesizes[len(face)] += 1
01791         self.assertEqual(facesizes[3], 8)       # eight triangular faces
01792         self.assertEqual(facesizes[4], 6)       # six square faces
01793 
01794         for vertex in cuboctahedron:
01795             edge = vertex                       # Cuboctahedron vertices are edges in Cube
01796             self.assertEqual(len(edge), 2)      # Two cube vertices define an edge
01797             for cubevert in edge:
01798                 self.assertIn(cubevert, g)
01799 
01800 
01801 #==============================================================================

Here is the call graph for this function:


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