def graph_parameters(nodes):
    """Gather all required and optional inputs and outputs."""

    out = set(nodes)
    rin, oin = set(), set()

    for node in nodes.values():
        rin |= node["required"]
        oin |= set(node["optional"])

    return (rin - out, oin, out)