Duplicated edges from Graph.edges(g, v) when v has a self-reference?
还没有人认领这个 Issue。
评估
调研方向
从 lib/graph.ex 约第 451 行开始,使用一条自引用边重现 Graph.edges(graph, metric_key)。将返回的边与 Graph.edges(graph) 进行比较,并检查 v_in 和 v_out 路径是如何组合和去重的。完成的标准是确定自引用的预期行为,并由回归测试覆盖。
由索引模型根据 Issue 内容生成。
描述
Hi and first of all, thanks for maintaining this library. It has turned out to be essential to me since I started using it.
I'm a big fan of pattern matching over edges in the graph and it's a very intuitive way to write complicated case handling. However I just discovered that I'm getting duplicated edges when I am matching on, eg.
case graph |> Graph.edges(metric_key) do
%{v1: ^metric_key, v2: ^metric_key} -> ...
... other cases
end
From a glance at the code, a possible cause could be if a self-referencing edge could be described by both v_in and v_out:
https://github.com/bitwalker/libgraph/blob/15ff0b9ba8c22a9dfec5bc04096fb7025e58f34b/lib/graph.ex#L451
But the description would have to differ, otherwise the MapSet would make it unique.. Do you think this is a correct cause and if so, is it an intended one?
I don't suppose there is any inherent disadvantage in just matching instead on all edges as such:
case graph |> Graph.edges() do
%{v1: ^metric_key, v2: ^metric_key} -> ...
... other cases
_ -> [] # not the stuff we're interested in
end |> List.flatten()
Looking at the code, it seems to be pretty much the same amount of work being done -- and in my situation, I always need to flat_map anyway in what I am doing.
However, someone else may be tripped up on it and have a situation where getting duplicates could cause confusion down the line.
Best regards,
Dennis
- 主要语言
- Elixir
- 星标
- 571
- 派生
- 76
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bitwalker/libgraph 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
Failing tests 未关闭
难度 3/5 1-2 天 新手友好度 35/100
-
难度 5/5 一周以上 新手友好度 25/100
查看 bitwalker/libgraph 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
carverauto/serviceradar#4596 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 75/100
agentjido/jido_harness#80 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
sevenseacat/cinder#235 ·