def graphviz_lines(nodes, node_filter, format_node):
    """Generate source lines for a Graphviz graph definition"""
    all_nodes = set()
    collect_nodes(all_nodes, *nodes)
    if node_filter:
        all_nodes = [n for n in all_nodes if node_filter(n)]
    all_nodes = sorted(all_nodes, key=id)
    input_nodes = [n for n in all_nodes if isinstance(n, Input)]

    yield 'digraph gr {'
    yield '  graph [ dpi = 48 ];'
    yield '  rankdir = LR;'
    yield '  { rank = source;'
    for node in input_nodes:
        yield '    n{};'.format(id(node))
    yield '  }'
    for node in all_nodes:
        for line in format_node('n{}'.format(id(node)), node):
            yield line
        for other in node._dependents:
            if all_nodes in other:
                yield ('  n{node} -> n{other};'
                       .format(node=id(node), other=id(other)))
    yield '}'
dataset/ETHPy150Open akaihola/lusmu/lusmu/visualization.py/graphviz_lines/swapped operands of `in`