import re


def generate_function_name(graph_name: str) -> str:
    """
    Takes the given graph name and constructs a valid function name from it.
    :param graph_name: The name of the graph.
    :return: the constructed function name.
    """
    function_name = "gen_" + re.sub(r"[-| ]", "_", graph_name.lower())
    return re.sub(r"[^0-9a-z_]", "", function_name)