| 538 | if n.contains(x, y): return n |
| 539 | |
| 540 | def _add_node_copy(self, n, **kwargs): |
| 541 | # Magical fairy dust to copy subclasses of Node. |
| 542 | # We assume that the subclass constructor takes an optional "text" parameter |
| 543 | # (Text objects in NodeBox for OpenGL's implementation are expensive). |
| 544 | try: |
| 545 | new = self.add_node(n.id, root=kwargs.get("root",False), text=False) |
| 546 | except TypeError: |
| 547 | new = self.add_node(n.id, root=kwargs.get("root",False)) |
| 548 | new.__class__ = n.__class__ |
| 549 | new.__dict__.update((k, deepcopy(v)) for k,v in n.__dict__.iteritems() |
| 550 | if k not in ("graph", "links", "_x", "_y", "force", "_weight", "_centrality")) |
| 551 | |
| 552 | def _add_edge_copy(self, e, **kwargs): |
| 553 | if kwargs.get("node1", e.node1).id not in self \ |