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

map_vertex iterates same node multiple times #110

Closed
anwarmamat opened this issue Sep 30, 2020 · 3 comments
Closed

map_vertex iterates same node multiple times #110

anwarmamat opened this issue Sep 30, 2020 · 3 comments

Comments

@anwarmamat
Copy link

I am using Persistent.Digraph.ConcreteLabeled for one my applications. map_vertex is visiting the nodes more than one time.

@anwarmamat anwarmamat changed the title map_vertex iterate same node multiple times map_vertex iterates same node multiple times Sep 30, 2020
@backtracking
Copy link
Owner

You're right. If we consider this a bug, this could be fixed by inserting a memo pattern such as

    let module H = Hashtbl.Make(V) in
    let vtable = H.create 1024 in
    let f v = try H.find vtable v
              with Not_found -> let v' = f v in H.add vtable v v'; v' in

in the code of map_vertex (in file blocks.ml).

@backtracking
Copy link
Owner

In the meantime, you can use such a workaround on your side, by applying the same memo pattern to the function you are passing to map_vertex.
I agree that it would be nicer to have map_vertex doing it, but at least that's an immediate fix if this is blocking for you.

@anwarmamat
Copy link
Author

thanks

avsm pushed a commit to ocaml/opam-repository that referenced this issue Aug 31, 2023
CHANGES:

  - ❗ OCamlGraph now requires OCaml >= 4.08
  - ❗ [Traverse]: fixed [Dfs.fold] and [Dfs.fold_component],
    which were not implementing a proper DFS
  - [Classic]: new functions [cycle] and [grid]
  - [Eulerian]: Eulerian paths (new module)
  - [Components]: strong articulation points (see functors [Connectivity]
    and [BiConnectivity]) (Timothy Bourke)
  - [Dominator]: non-trivial dominators (Timothy Bourke)
  - backtracking/ocamlgraph#31: fixed documentation of [map_vertex]: the supplied function
    must be injective
  - backtracking/ocamlgraph#110: ensure that map_vertex applies the function only once per vertex
nberth pushed a commit to nberth/opam-repository that referenced this issue Jun 18, 2024
CHANGES:

  - ❗ OCamlGraph now requires OCaml >= 4.08
  - ❗ [Traverse]: fixed [Dfs.fold] and [Dfs.fold_component],
    which were not implementing a proper DFS
  - [Classic]: new functions [cycle] and [grid]
  - [Eulerian]: Eulerian paths (new module)
  - [Components]: strong articulation points (see functors [Connectivity]
    and [BiConnectivity]) (Timothy Bourke)
  - [Dominator]: non-trivial dominators (Timothy Bourke)
  - backtracking/ocamlgraph#31: fixed documentation of [map_vertex]: the supplied function
    must be injective
  - backtracking/ocamlgraph#110: ensure that map_vertex applies the function only once per vertex
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

2 participants