Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
817d2b28
Commit
817d2b28
authored
Jul 25, 2016
by
Duncan Coutts
Browse files
Add a couple Graph operations, direct deps and reverse deps
Needed for some new InstallPlan functions
parent
ba5297ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Cabal/Distribution/Compat/Graph.hs
View file @
817d2b28
...
...
@@ -60,6 +60,8 @@ module Distribution.Compat.Graph (
SCC
(
..
),
cycles
,
broken
,
neighbors
,
revNeighbors
,
closure
,
revClosure
,
topSort
,
...
...
@@ -266,6 +268,20 @@ cycles g = [ vs | CyclicSCC vs <- stronglyConnComp g ]
broken
::
Graph
a
->
[(
a
,
[
Key
a
])]
broken
g
=
graphBroken
g
-- | Lookup the immediate neighbors from a key in the graph.
-- Requires amortized construction of graph.
neighbors
::
IsNode
a
=>
Graph
a
->
Key
a
->
Maybe
[
a
]
neighbors
g
k
=
do
v
<-
graphKeyToVertex
g
k
return
(
map
(
graphVertexToNode
g
)
(
graphForward
g
!
v
))
-- | Lookup the immediate reverse neighbors from a key in the graph.
-- Requires amortized construction of graph.
revNeighbors
::
IsNode
a
=>
Graph
a
->
Key
a
->
Maybe
[
a
]
revNeighbors
g
k
=
do
v
<-
graphKeyToVertex
g
k
return
(
map
(
graphVertexToNode
g
)
(
graphAdjoint
g
!
v
))
-- | Compute the subgraph which is the closure of some set of keys.
-- Returns @Nothing@ if one (or more) keys are not present in
-- the graph.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment