mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-07 18:25:19 +00:00
This commit modifies the Graph class so that it permits dangling edges; that is to say, edges whose src or dst are not present in the graph. Dangling edges may be directly added to the graph, or existing edges may become dangling if their src or dst is removed. This change is prerequisite to #1136; if we require that nodes have metadata, we should also make it possible to add edges to nodes that don't yet exist, as the plugin creating an edge may not have access to the full metadata needed to add the node. To support this change, there is now an `isDanglingEdge` method on the graph, which reports whether or not the edge is dangling. Also, `Graph.edges` requires that the client make an explicit choice on whether dangling edges are desired. This ensures that we do not accidentally include dangling edges in a case where they are inappropriate (e.g. creating a Markov chain) or accidentally discard dangling edges when they are needed (e.g. when merging or serializing). The Graph's invariant checker has been updated to reflect the new semantics. The Graph compat version has been bumped, since this is a break in backwards compatibility. Note that this commit does not change the behavior of any plugins; that is to say, no plugins create dangling edges (yet). Test plan: The advanced graph test case has been updated to include dangling edges. The tests for Graph, PagerankGraph, and GraphToMarkovChain have been updated. `yarn test --full` passes.