Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poor performance of Graph.replace_vertex/2 for large graphs #85

Open
stevensonmt opened this issue Jan 11, 2025 · 0 comments
Open

Poor performance of Graph.replace_vertex/2 for large graphs #85

stevensonmt opened this issue Jan 11, 2025 · 0 comments

Comments

@stevensonmt
Copy link
Contributor

stevensonmt commented Jan 11, 2025

Similar to #80 with likely similar fix. ~25x speedup for graph with 1M vertices/edges in iex for:

g = (Graph.new() |> Graph.add_edges(Enum.map(1..1_000_000, fn i -> {i, 1_000_000 - i} end)))
:timer.tc(fn -> Graph.replace_vertex(g, Enum.random(1..1_000_000), 1_000_001) end, :millisecond)
# {56, #Graph<type: directed, num_vertices: 999897, num_edges: 1000000>}
:timer.tc(fn -> Graph.replace_vertex_old(g, Enum.random(1..1_000_000), 1_000_001) end, :millisecond)
# {1399, #Graph<type: directed, num_vertices: 999897, num_edges: 1000000>}

Will add to PR #84 as related issues. Would like someone to double check that I haven't mixed up the in-edges and out-edges definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant