def sample_points(G: nx.MultiGraph, n: int) -> gpd.GeoSeries:
    """
    Randomly sample points constrained to a spatial graph.

    This generates a graph-constrained uniform random sample of points. Unlike
    typical spatially uniform random sampling, this method accounts for the
    graph's geometry. And unlike equal-length edge segmenting, this method
    guarantees uniform randomness.

    Parameters
    ----------
    G
        Graph from which to sample points. Should be undirected (to avoid
        oversampling bidirectional edges) and projected (for accurate point
        interpolation).
    n
        How many points to sample.

    Returns
    -------
    points
        The sampled points, multi-indexed by `(u, v, key)` of the edge from
        which each point was sampled.
    """
    if nx.is_directed(G):  # pragma: no cover
        msg = "`G` should be undirected to avoid oversampling bidirectional edges."
        warn(msg, category=UserWarning, stacklevel=2)
    gdf_edges = convert.graph_to_gdfs(G, nodes=False)[["geometry", "length"]]
    weights = gdf_edges["length"] / gdf_edges["length"].sum()
    idx = np.random.default_rng().choice(gdf_edges.index, size=n, p=weights)
    lines = gdf_edges.loc[idx, "geometry"]
    return lines.interpolate(np.random.default_rng().random(n), normalized=True)

    Randomly sample points constrained to a spatial graph.

    This generates a graph-constrained uniform random sample of points. Unlike
    typical spatially uniform random sampling, this method accounts for the
    graph's geometry. And unlike equal-length edge segmenting, this method
    guarantees uniform randomness.

    Parameters
    ----------
    G
        Graph from which to sample points. Should be undirected (to avoid
        oversampling bidirectional edges) and projected (for accurate point
        interpolation).
    n
        How many points to sample.

    Returns
    -------
    points
        The sampled points, multi-indexed by `(u, v, key)` of the edge from
        which each point was sampled.
    
osmnx/utils_geo.py