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

Bug in implementation of weight #141

Open
Engelberg opened this issue May 15, 2024 · 0 comments
Open

Bug in implementation of weight #141

Engelberg opened this issue May 15, 2024 · 0 comments

Comments

@Engelberg
Copy link
Contributor

The weight function is supposed to dispatch to the weight* protocol. The weight* protocol has implementors implement an arity for discovering the weight of an edge: (weight* g e). However, the weight function completely ignores this aspect of the protocol and never calls it for edges. The existing implementation of weight calls weight* instead on the src and dest nodes, which poses a problem for graphs where the edge is not uniquely determined by src and dest.

The correct implementation of weight which respects the full weight* protocol is:

(defn weight
  "Returns the weight of edge e or edge [n1 n2]"
  ([g] (partial weight g))
  ([g e] (weight* g e))
  ([g n1 n2] (weight* g n1 n2)))
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