mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-02 07:42:50 -06:00
Some performance improvements in the FA generation.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
-----------------------------------------------------------------------------
|
||||
module GF.Speech.Graph ( Graph(..), Node, Edge, Incoming, Outgoing
|
||||
, newGraph, nodes, edges
|
||||
, nmap, emap, newNode, newEdge, newEdges
|
||||
, nmap, emap, newNode, newNodes, newEdge, newEdges
|
||||
, incoming, outgoing, getOutgoing
|
||||
, getFrom, getTo, getLabel
|
||||
, reverseGraph, renameNodes
|
||||
@@ -52,6 +52,11 @@ emap f (Graph c ns es) = Graph c ns [(x,y,f l) | (x,y,l) <- es]
|
||||
newNode :: a -> Graph n a b -> (Graph n a b,n)
|
||||
newNode l (Graph (c:cs) ns es) = (Graph cs ((c,l):ns) es, c)
|
||||
|
||||
newNodes :: [a] -> Graph n a b -> (Graph n a b,[Node n a])
|
||||
newNodes ls (Graph cs ns es) = (Graph cs' (ns'++ns) es, ns')
|
||||
where (xs,cs') = splitAt (length ls) cs
|
||||
ns' = zip xs ls
|
||||
|
||||
newEdge :: Edge n b -> Graph n a b -> Graph n a b
|
||||
newEdge e (Graph c ns es) = Graph c ns (e:es)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user