From 6955053447c15b2080eb07376e8281114fa46d7a Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Tue, 8 Feb 2022 12:33:27 -0600 Subject: [PATCH] allow getting edges --- src/Graph.elm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Graph.elm b/src/Graph.elm index 0d705f6..f8f7d93 100644 --- a/src/Graph.elm +++ b/src/Graph.elm @@ -1,4 +1,4 @@ -module Graph exposing (Graph, empty, insertEdge, insertNode, neighbors, node, nodes, updateEdge) +module Graph exposing (Graph, edgesFrom, empty, insertEdge, insertNode, neighbors, node, nodes, updateEdge) import Dict exposing (Dict) @@ -66,6 +66,11 @@ nodes (Graph guts) = guts.nodes +edgesFrom : Int -> Graph node edge -> Maybe (Dict Int edge) +edgesFrom id (Graph guts) = + Dict.get id guts.edges + + neighbors : Int -> Graph node edge -> Maybe (Dict Int edge) neighbors id (Graph { edges }) = Dict.get id edges