def graph_to_dict_form(graph):
    """Convert query_graph or knowledge_graph to dict form."""
    return {
        "nodes": {node["id"]: node for node in graph["nodes"]},
        "edges": {edge["id"]: edge for edge in graph["edges"]},
    }