Skip to content

Commit 5cdbecc

Browse files
authored
Add a maximal DAG in Graph benchmarks (#935)
1 parent fa1d1e7 commit 5cdbecc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

containers-tests/benchmarks/Graph.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ main = do
2222
, bgroup "stronglyConnCompR" $ forGs allGs $ nf G.stronglyConnCompR . getAdjList
2323
]
2424
where
25-
allGs = randGs ++ starGs ++ lineGs
25+
allGs = randGs ++ starGs ++ lineGs ++ maxDAGs
2626
randGs = map (uncurry buildRandG) [(100, 1000), (100, 10000), (10000, 100000), (100000, 1000000)]
2727
starGs = map buildStarG [100, 1000000]
2828
lineGs = map buildLineG [100, 1000000]
29+
maxDAGs = map buildMaxDAG [15, 1500]
2930

3031
-- Note: In practice it does not make sense to run topSort or bcc on a random
3132
-- graph. For topSort the graph should be acyclic and for bcc the graph should
@@ -74,3 +75,10 @@ buildLineG :: Int -> Graph
7475
buildLineG n = makeG label (1, n) (zip [1..n-1] [2..])
7576
where
7677
label = "line,n=" ++ show n
78+
79+
-- A maximal DAG. There is an edge from vertex i to j for every i, j when i < j.
80+
-- The number of edges is n * (n - 1) / 2.
81+
buildMaxDAG :: Int -> Graph
82+
buildMaxDAG n = makeG label (1, n) [(i, j) | i <- [1 .. n-1], j <- [i+1 .. n]]
83+
where
84+
label = "maxDAG,n=" ++ show n

0 commit comments

Comments
 (0)