<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_graphviz_lines(lines):
 """ Render a .dot file with graph definition from a given set of data :type lines list[dict] :rtype: str """

    # first, prepare the unique list of all nodes (sources and targets)
    lines_nodes = set()

    for line in lines:
        lines_nodes.add(line['source'])
        lines_nodes.add(line['target'])

    # generate a list of all nodes and their names for graphviz graph
    nodes = OrderedDict()

    for i, node in enumerate(sorted(lines_nodes)):
        nodes[node] = 'n{}'.format(i+1)

    # print(lines_nodes, nodes)

    graph = list()

    # some basic style definition
    # https://graphviz.gitlab.io/_pages/doc/info/lang.html
    graph.append('digraph G {')

    # https://graphviz.gitlab.io/_pages/doc/info/shapes.html#record
    graph.append('\tgraph [ center=true, margin=0.75, nodesep=0.5, ranksep=0.75, rankdir=LR ];')
    graph.append('\tnode [ shape=box, style="rounded,filled" width=0, height=0, '
                 'fontname=Helvetica, fontsize=11 ];')
    graph.append('\tedge [ fontname=Helvetica, fontsize=9 ];')

    # emit nodes definition
    graph.append('\n\t// nodes')

    # https://www.graphviz.org/doc/info/colors.html#brewer
    group_colors = dict()

    for label, name in nodes.items():
        if ':' in label:
            (group, label) = str(label).split(':', 1)

            # register a new group for coloring
            if group not in group_colors:
                group_colors[group] = len(group_colors.keys()) + 1
        else:
            group = None

        label = escape_graphviz_entry(label)

        graph.append('\t{name} [label="{label}"{group}];'.format(
            name=name,
            label="{}\\n{}".format(group, label) if group is not None else label,
            group=' group="{}" colorscheme=pastel28 color={}'.format(
                group, group_colors[group]) if group is not None else ''
        ))

    # now, connect the nodes
    graph.append('\n\t// edges')
    for line in lines:
        label = line.get('metadata', '')

        graph.append('\t{source} -> {target} [{label}];'.format(
            source=nodes[line['source']],
            target=nodes[line['target']],
            label='label="{}"'.format(escape_graphviz_entry(label)) if label != '' else ''
        ))

    graph.append('}')

    return '\n'.join(graph)