next up previous
Next: Hughes's efficient sequence type Up: Accompanying material for: A Previous: Some simple benchmarks

Graphs

A simple implementation of graphs using adjacency lists.

>  module Graph(

>      VertexEdgeGraph, adjacent, vertices)
>  where
>  import Array


>  type Vertex                   =  Int

>  type Edge                     =  (VertexVertex)
>  type Graph                    =  Array Vertex [Vertex]

>  adjacent                      :: Graph -> Vertex -> [Vertex]
>  adjacent g v                  =  g ! v

>  vertices                      :: Graph -> [Vertex]
>  vertices g                    =  indices g


next up previous
Next: Hughes's efficient sequence type Up: Accompanying material for: A Previous: Some simple benchmarks
Ralf Hinze 2001-03-20