def copy(self, empty=False):
g = graph(self.layout.n, self.distance, self.layout.type)<EOL>g.layout = self.layout.copy(g)<EOL>g.styles = self.styles.copy(g)<EOL>g.events = self.events.copy(g)<EOL>if not empty:<EOL><INDENT>for n in self.nodes:<EOL><INDENT>g.add_node(n.id, n.r, n.style, n.category, n.label, (n == self.root), n.__dict__)<EOL><DEDENT>for e in self.edges:<EOL><INDENT>g.add_edge(e.node1.id, e.node2.id, e.weight, e.length, e.label, e.__dict__)<EOL><DEDENT><DEDENT>return g<EOL>
Create a copy of the graph (by default with nodes and edges).