<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def insert_graph(cur, nodelist, edgelist, encoded_data=None):
 """Insert a graph into the cache. A graph is stored by number of nodes, number of edges and a json-encoded list of edges. Args: cur (:class:`sqlite3.Cursor`):
 An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. nodelist (list):
 The nodes in the graph. edgelist (list):
 The edges in the graph. encoded_data (dict, optional):
 If a dictionary is provided, it will be populated with the serialized data. This is useful for preventing encoding the same information many times. Notes: This function assumes that the nodes are index-labeled and range from 0 to num_nodes - 1. In order to minimize the total size of the cache, it is a good idea to sort the nodelist and edgelist before inserting. Examples: 3 2 '[[0,1],[1,2]]' """

    if encoded_data is None:
        encoded_data = {}

    if 'num_nodes' not in encoded_data:
        encoded_data['num_nodes'] = len(nodelist)
    if 'num_edges' not in encoded_data:
        encoded_data['num_edges'] = len(edgelist)
    if 'edges' not in encoded_data:
        encoded_data['edges'] = json.dumps(edgelist, separators=(',', ':'))

    insert = \
        """
        INSERT OR IGNORE INTO graph(num_nodes, num_edges, edges)
        VALUES (:num_nodes, :num_edges, :edges);
        """

    cur.execute(insert, encoded_data)