Algebra.Graph.Labelled.Example.Network

algebraic-graphs-0.7: A library for algebraic graph construction and transformation

Copyright | (c) Andrey Mokhov 2016-2022
License | MIT (see the file LICENSE)
Maintainer | andrey.mokhov@gmail.com
Stability | experimental
Safe Haskell | None
Language | Haskell2010

Algebra.Graph.Labelled.Example.Network

Description

Alga is a library for algebraic construction and manipulation of graphs in Haskell. See this paper for the motivation behind the library, the underlying theory, and implementation details.

This module contains a simple example of using edge-labelled graphs defined in the module Algebra.Graph.Labelled for working with networks, i.e. graphs whose edges are labelled with distances.

Synopsis

- data City
  - = Aberdeen
  - | Edinburgh
  - | Glasgow
  - | London
  - | Newcastle
- type JourneyTime = Int
- eastCoast :: Network JourneyTime City
- scotRail :: Network JourneyTime City
- network :: Network JourneyTime City

# Documentation

data City #

Our example networks have cities as vertices.

Constructors

Aberdeen |
Edinburgh |
Glasgow |
London |
Newcastle |

#### Instances

Instances details

Bounded City # |
Instance details Defined in Algebra.Graph.Labelled.Example.Network Methods minBound :: City # maxBound :: City #
Enum City # |
Instance details Defined in Algebra.Graph.Labelled.Example.Network Methods succ :: City -> City # pred :: City -> City # toEnum :: Int -> City # fromEnum :: City -> Int # enumFrom :: City -> [City] # enumFromThen :: City -> City -> [City] # enumFromTo :: City -> City -> [City] # enumFromThenTo :: City -> City -> City -> [City] #
Show City # |
Instance details Defined in Algebra.Graph.Labelled.Example.Network Methods showsPrec :: Int -> City -> ShowS # show :: City -> String # showList :: [City] -> ShowS #
Eq City # |
Instance details Defined in Algebra.Graph.Labelled.Example.Network Methods (==) :: City -> City -> Bool # (/=) :: City -> City -> Bool #
Ord City # |
Instance details Defined in Algebra.Graph.Labelled.Example.Network Methods compare :: City -> City -> Ordering # (<) :: City -> City -> Bool # (<=) :: City -> City -> Bool # (>) :: City -> City -> Bool # (>=) :: City -> City -> Bool # max :: City -> City -> City # min :: City -> City -> City #

type JourneyTime = Int #

For simplicity we measure journey times in integer number of minutes.

eastCoast :: Network JourneyTime City #

A part of the EastCoast train network between `Aberdeen` and `London`.

    eastCoast = overlays [ Aberdeen  -<150>- Edinburgh
                         , Edinburgh -< 90>- Newcastle
                         , Newcastle -<170>- London ]

scotRail :: Network JourneyTime City #

A part of the ScotRail train network between `Aberdeen` and `Glasgow`.

    scotRail = overlays [ Aberdeen  -<140>- Edinburgh
                        , Edinburgh -< 50>- Glasgow
                        , Edinburgh -< 70>- Glasgow ]

network :: Network JourneyTime City #

An example train network.

    network = overlay scotRail eastCoast