X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graphviz%2Fscl%2FVisualization%2FGGraph.scl;h=3179ab74db0d7ce8bf67e67a741653f8ef6f1277;hb=cc084b2c81c8b47adfd1d33b507164c6c42728fa;hp=9c141aaf55a4669b7414d939f98802ec38fdcd68;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.graphviz/scl/Visualization/GGraph.scl b/bundles/org.simantics.graphviz/scl/Visualization/GGraph.scl index 9c141aaf5..3179ab74d 100644 --- a/bundles/org.simantics.graphviz/scl/Visualization/GGraph.scl +++ b/bundles/org.simantics.graphviz/scl/Visualization/GGraph.scl @@ -1,32 +1,35 @@ -import "Visualization/Graphviz" -import "MMap" as MMap -include "Visualization/Graphviz/Property" - -data GGraph a e = GGraph Graph (MMap.T a Node) (a -> [Property]) - -newGGraph :: [Property] -> (a -> [Property]) -> GGraph a e -newGGraph properties f = GGraph (newGraph properties) (MMap.create ()) f - -@private -toNode :: GGraph a e -> a -> Node -toNode (GGraph graph nodeMap f) r = - match MMap.get nodeMap r with - Just n -> n - Nothing -> do - n = newNode graph (f r) - MMap.put nodeMap r n - n - -newGEdge :: GGraph a e -> a -> a -> [Property] -> Edge -newGEdge graph r1 r2 properties = edge - where - edge = newEdge (toNode graph r1) (toNode graph r2) properties - -newGNode :: GGraph a e -> a -> Node -newGNode = toNode - -showGGraph :: GGraph a e -> () -showGGraph (GGraph graph _ _) = showGraph graph - -showGGraphWithAlgorithm :: String -> GGraph a e -> () -showGGraphWithAlgorithm algorithm (GGraph graph _ _) = showGraphWithAlgorithm graph algorithm +import "Visualization/Graphviz" +import "MMap" as MMap +include "Visualization/Graphviz/Property" + +data GGraph a e = GGraph Graph (MMap.T a Node) (a -> [Property]) + +newGGraph :: [Property] -> (a -> [Property]) -> GGraph a e +newGGraph properties f = GGraph (newGraph properties) (MMap.create ()) f + +@private +toNode :: GGraph a e -> a -> Node +toNode (GGraph graph nodeMap f) r = + match MMap.get nodeMap r with + Just n -> n + Nothing -> do + n = newNode graph (f r) + MMap.put nodeMap r n + n + +newGEdge :: GGraph a e -> a -> a -> [Property] -> Edge +newGEdge graph r1 r2 properties = edge + where + edge = newEdge (toNode graph r1) (toNode graph r2) properties + +newGNode :: GGraph a e -> a -> Node +newGNode = toNode + +showGGraph :: GGraph a e -> () +showGGraph (GGraph graph _ _) = showGraph graph + +showGGraphWithAlgorithm :: String -> GGraph a e -> () +showGGraphWithAlgorithm algorithm (GGraph graph _ _) = showGraphWithAlgorithm graph algorithm + +showGGraphWithNamedWindow :: String -> String -> GGraph a e -> () +showGGraphWithNamedWindow windowName algorithm (GGraph graph _ _) = showGraphWithNamedWindow windowName graph algorithm