mirror of
https://github.com/rgleichman/glance.git
synced 2024-11-23 08:27:18 +03:00
Fix bug in GraphAlgorithms where a node counted as its own parent.
This commit is contained in:
parent
9c61368bd2
commit
dd821cbb47
@ -58,7 +58,7 @@ extractSyntaxNode = snd . snd
|
||||
|
||||
findParents :: ING.Graph gr => gr a b -> ING.Node -> [ING.Node]
|
||||
-- TODO, may need to use ING.pre or ING.neighbors instead of ING.suc'
|
||||
findParents = ING.suc
|
||||
findParents graph node = filter (/= node) $ ING.suc graph node
|
||||
|
||||
findChildren :: ING.Graph gr => gr a b -> ING.Node -> [ING.Node]
|
||||
findChildren = ING.pre
|
||||
@ -107,8 +107,6 @@ collapseNodes originalGraph = finalGraph where
|
||||
-- A node is a treeRoot if all of these conditions are true:
|
||||
-- 1. The SyntaxNode can embed other nodes (i.e. syntaxNodeCanEmbed is true)
|
||||
-- 2. The node has no parents that can embed it, or 2 or more parents that can embed it.
|
||||
-- TODO These rules should be revised to allow cycles to be embedded.
|
||||
-- Condition 2. should be revised such that if there is a parent that is a bind, it's a root even if other nodes can embed it.
|
||||
-- Note: A treeRoot may not actually have any embeddable children, since collapseTree will do nothing in that case.
|
||||
findTreeRoots :: ING.DynGraph gr => IngSyntaxGraph gr -> [ING.Node]
|
||||
findTreeRoots graph = filterNodes (isTreeRoot graph) graph
|
||||
|
@ -24,8 +24,8 @@ renderFile inputFilename includeComments = do
|
||||
let
|
||||
(parsedModule, comments) = Exts.fromParseResult parseResult
|
||||
drawings = drawingsFromModule parsedModule
|
||||
print parsedModule
|
||||
print "\n\n"
|
||||
--print parsedModule
|
||||
--print "\n\n"
|
||||
--print drawings
|
||||
|
||||
diagrams <- traverse renderDrawing drawings
|
||||
@ -34,7 +34,7 @@ renderFile inputFilename includeComments = do
|
||||
diagramsAndComments = vsep 2 $ zipWith (\x y -> x === strutY 0.4 === y) commentsInBoxes (fmap alignL diagrams)
|
||||
justDiagrams = vsep 1 $ fmap alignL diagrams
|
||||
diagramsAndMaybeComments = if includeComments == "c" then diagramsAndComments else justDiagrams
|
||||
print comments
|
||||
--print comments
|
||||
pure (bgFrame 1 (backgroundC colorScheme) diagramsAndMaybeComments :: Diagram B)
|
||||
|
||||
|
||||
|
@ -212,7 +212,9 @@ nestedTests = [
|
||||
"y = f [1,2]",
|
||||
"y = f [g 3, h 5]",
|
||||
"y = f $ g (\\x -> x)",
|
||||
"y = (f 3) 4"
|
||||
"y = (f 3) 4",
|
||||
"y = foo (3 + bazOf2) bazOf2 where bazOf2 = baz 2",
|
||||
"y = foo (3 + bazOf2) (8 * bazOf2) where bazOf2 = baz 2"
|
||||
]
|
||||
|
||||
dollarTests = [
|
||||
@ -474,7 +476,8 @@ collapseTestStrings = [
|
||||
"y = f x1 x2",
|
||||
"y = f (g x)",
|
||||
"y = g (\\x -> x)",
|
||||
"y = f $ g (\\x -> x)"
|
||||
"y = f $ g (\\x -> x)",
|
||||
"y = foo (3 + bazOf2) (8 * bazOf2) where bazOf2 = baz 2"
|
||||
]
|
||||
|
||||
makeCollapseTest :: String -> IO (Diagram B)
|
||||
|
Loading…
Reference in New Issue
Block a user