<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_to_graph(self, nodes, edges, nesting):
 """ Adds nodes and edges to the graph as long as the maximum number of nodes is not exceeded. All edges are expected to have a reference to an entry in nodes. If the list of nodes is not added in the first hop due to graph size limitations, they are stored in hopNodes. If the graph was extended the function returns True, otherwise the result will be False. """

        if (len(nodes) + len(self.added)) > self.max_nodes:
            if nesting < 2:
                self.hopNodes = nodes
                self.hopEdges = edges
            self.truncated = nesting
            return False
        else:
            for n in nodes:
                self.dot.node(n.ident, **n.attribs)
            for e in edges:
                if len(e) == 5:
                    self.dot.edge(e[0].ident, e[1].ident, style=e[2],
                                  color=e[3], label=e[4])
                else:
                    self.dot.edge(e[0].ident, e[1].ident, style=e[2],
                                  color=e[3])
            self.added.update(nodes)
            return True