def save_graphml(
    G: nx.MultiDiGraph,
    filepath: str | Path | None = None,
    *,
    gephi: bool = False,
    encoding: str = "utf-8",
) -> None:
    """
    Save graph to disk as GraphML file.

    Parameters
    ----------
    G
        The graph to save as.
    filepath
        Path to the GraphML file including extension. If None, use default
        `settings.data_folder/graph.graphml`.
    gephi
        If True, give each edge a unique key/id for compatibility with Gephi's
        interpretation of the GraphML specification.
    encoding
        The character encoding of the saved GraphML file.
    """
    # default filepath if none was provided
    filepath = Path(settings.data_folder) / "graph.graphml" if filepath is None else Path(filepath)

    # if save folder does not already exist, create it
    filepath.parent.mkdir(parents=True, exist_ok=True)

    # make a copy to not mutate original graph object caller passed in
    G = G.copy()

    if gephi:
        # for gephi compatibility, each edge's key must be unique as an id
        uvkd = [(u, v, k, d) for k, (u, v, d) in enumerate(G.edges(keys=False, data=True))]
        G.clear_edges()
        G.add_edges_from(uvkd)

    # stringify all the graph attribute values
    for attr, value in G.graph.items():
        G.graph[attr] = str(value)

    # stringify all the node attribute values
    for _, data in G.nodes(data=True):
        for attr, value in data.items():
            data[attr] = str(value)

    # stringify all the edge attribute values
    for _, _, data in G.edges(keys=False, data=True):
        for attr, value in data.items():
            data[attr] = str(value)

    nx.write_graphml(G, path=filepath, encoding=encoding)
    msg = f"Saved graph as GraphML file at {str(filepath)!r}"
    utils.log(msg, level=lg.INFO)

    Save graph to disk as GraphML file.

    Parameters
    ----------
    G
        The graph to save as.
    filepath
        Path to the GraphML file including extension. If None, use default
        `settings.data_folder/graph.graphml`.
    gephi
        If True, give each edge a unique key/id for compatibility with Gephi's
        interpretation of the GraphML specification.
    encoding
        The character encoding of the saved GraphML file.
    
osmnx/io.py