Page 1 of 1

in Haskell please solve maxNodeID and insertNode

Posted: Sat Nov 27, 2021 2:19 pm
by answerhappygod
in Haskell
please solve maxNodeID and insertNode
In Haskell Please Solve Maxnodeid And Insertnode 1
In Haskell Please Solve Maxnodeid And Insertnode 1 (92.56 KiB) Viewed 70 times
In Haskell Please Solve Maxnodeid And Insertnode 2
In Haskell Please Solve Maxnodeid And Insertnode 2 (97.14 KiB) Viewed 70 times
The file includes a function named maxNode ID of type Graph a -> Maybe NodeID that returns the largest Node ID in a Graph. The file includes a function named insertNode of type a -> Graph a -> Graph a that inserts a new Node with the given value into a Graph. The new NodeID should be the previously largest NodeID plus one. If the graph has no nodes, then NodeID should be 0. The fi in

data Graph a = Graph { getNodes :: [Node a] Til||||1 l, getEdges :: [Edge] } deriving (Show, Eq) type Edge = (NodeID, NodeID) type NodeID = Int data Node a = Node { getNodeID :: NodeID, ILITI||| .getNodeVal :: a } deriving (Show, Eq,ord)