def build_sg_graph_dict(sg):
    """ Builds a dictionary of dependencies for each node, where each node can have either component
    or supplier dependents or both. If a node has no dependents of a certain type, the key is missing.
    A node with no dependents has an empty dictionary."""
    def type_tag(node):
        return list(filter(lambda t: t in ("component", "supplier"), sg.nodes[node].tags))[0]

    g = {n: {} for n in sg.nodes.keys()}
    for e in sg.edges:
        if "potential" not in e.tags:
            g[e.dst][type_tag(e.src)] = g[e.dst].get(type_tag(e.src), []) + [e.src]

    return g