Skip to content

Bug in implementation of weight #141

@Engelberg

Description

@Engelberg

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)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions