@cached<EOL><INDENT>def neighbors(self):<DEDENT>
neighbors = dict(<EOL>(vertex, []) for vertex<EOL>in range(self.num_vertices)<EOL>)<EOL>for a, b in self.edges:<EOL><INDENT>neighbors[a].append(b)<EOL>neighbors[b].append(a)<EOL><DEDENT>neighbors = dict((key, frozenset(val)) for key, val in neighbors.items())<EOL>return neighbors<EOL>
A dictionary with neighbors

           The dictionary will have the following form:
           ``{vertexX: (vertexY1, vertexY2, ...), ...}``
           This means that vertexX and vertexY1 are connected etc. This also
           implies that the following elements are part of the dictionary:
           ``{vertexY1: (vertexX, ...), vertexY2: (vertexX, ...), ...}``.