Graph explorer with a Pregel engine in Haskell.
- GHC >= 9.0
- Cabal >= 3.0
cabal update
cabal buildThe graph file defines topology only (NODES, EDGES, optionally WEIGHTED or UNDIRECTED). Source, target, and algorithm are specified via CLI flags.
Sample graphs live in examples/.
cabal run graphaskell -- -g examples/grafo-simple.txt -s 0 -t 4 -a BFScabal run graphaskell -- -g examples/grafo-weighted.txt -s 0 -t 3 -a BELLMANFORDcabal run graphaskell -- -g examples/grafo-pagerank.txt -a PAGERANKConnected components (CC) treat the graph as undirected. Add the UNDIRECTED directive so each edge is stored in both directions; otherwise propagation follows outgoing edges only and may split a component that is connected in the undirected sense (e.g. a single edge 1 → 0 yields two components).
cabal run graphaskell -- -g examples/grafo-componentes.txt -a CCLabel propagation (LP) is defined on undirected graphs as well. Use UNDIRECTED in the graph file; with only directed edges, labels propagate along out-edges and results may differ from standard LPA.
cabal run graphaskell -- -g examples/grafo-lp-comunidades.txt -a LP| Flag | Description |
|---|---|
-g, --graph |
Path to the graph file |
-s, --source |
Source node (required for BFS and Bellman-Ford; optional otherwise) |
-t, --target |
Target node (required for BFS and Bellman-Ford) |
-a, --algorithm |
BFS, BELLMANFORD, PAGERANK, CC, LP |
--threads |
Worker cap per superstep (default: RTS capabilities) |
-v, --verbose |
Detailed logs per superstep |
cabal testEvery graph file must declare the node count and list edges:
NODES 5
EDGES
0 1
0 2
1 3
2 3
3 4
For weighted graphs, add the WEIGHTED directive and a weight per edge:
NODES 4
WEIGHTED
EDGES
0 1 4
0 2 1
Add UNDIRECTED when the input is an undirected graph. The parser keeps each listed edge and adds the reverse arc (unless it is a self-loop).
NODES 4
UNDIRECTED
EDGES
0 1
1 2
2 3
This is equivalent to listing both directions explicitly.