def parse_leda(lines):
    """Parse LEDA.GRAPH format from string or iterable.
    Returns an Graph or DiGraph."""
    if is_string_like(lines): lines=iter(lines.split('\n'))
    lines = iter([line.rstrip('\n') for line in lines \
            if not (line.startswith('#') or line.startswith('\n') or line=='')])
    for i in range(3):
        lines.next()
    # Graph
    du = int(lines.next())	# -1 directed, -2 undirected
    if du==-1:
        G = networkx.DiGraph()
    else:
        G = networkx.Graph()