def construct_edges(lst_contents, md_links, root=None):
    """
    Given the list of Markdown files referenced by the LST file, find
    all links between them.
    """

    edges = []

    for md in lst_contents:

        key = md.filename

        if root:
            key = key.relative_to(root)

        if key in md_links:

            for rl in md_links[key]:
                edges.append((key, str(rl)))

    return edges