コード例 #1
0
 def smart_add_vertex(self, path):
     v = Vertex()
     v.name = path
     v.x = choice(range(self.width))
     v.y = choice(range(self.height))
     if not v in self.V:
         self.V.append(v)
コード例 #2
0
 def smart_add_edge(self, v1_name, v2_name):
     for name in (v1_name, v2_name):
         v = Vertex()
         v.name = name
         v.x = choice(range(self.width))
         v.y = choice(range(self.height))
         v_seen = False
         for vertex in self.V:
             if v == vertex:
                 v_seen = True
         if not v_seen:
             self.V.append(v)
     v1 = v1_name
     for vert in self.V:
         if v1 == vert.name:
             v1 = vert
             break
     v2 = v2_name
     for vert2 in self.V:
         if v2 == vert2.name:
             v2 = vert2
             break
     e = self.edges_class(v1, v2)
     edge_seen = False
     for edge in self.E:
         if edge == e:
             edge_seen = True
     if not edge_seen:
         self.E.append(e)
コード例 #3
0
 def add_vertex(self):
     #reset dampening
     self.dampen = self.original_dampen
     v = Vertex()
     v.x = choice(range(self.width))
     v.y = choice(range(self.height))
     self.V.append(v)