Skip to content

Commit

Permalink
slightly improve performance of getting graph size
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellwrosen committed Nov 15, 2023
1 parent df59d01 commit 7084077
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions reactive-banana/src/Reactive/Banana/Prim/Low/Graph.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ listConnectedVertices :: (Eq v, Hashable v) => Graph v e -> [v]
listConnectedVertices Graph{incoming,outgoing} =
Map.keys $ outgoing `Map.union` incoming

-- | Number of connected vertices,
-- | O(v) Number of connected vertices,
-- i.e. vertices on which at least one edge is incident.
size :: (Eq v, Hashable v) => Graph v e -> Int
size Graph{incoming,outgoing} =
Map.size $ outgoing `Map.union` incoming
size Graph{levels} =
Map.size levels

-- | Number of edges.
edgeCount :: (Eq v, Hashable v) => Graph v e -> Int
Expand Down

0 comments on commit 7084077

Please sign in to comment.