Tuesday, 1 July 2014

QuickGraph: Modelling the London Underground in C#

quickgraph.banner.png

In this example we model the London Underground, well more specifically the Victoria, Bakerloo and Circle lines.

We ask the question: what is the shortest path between Marylebone and Victoria?

This requires a change at Oxford Circus from the Bakerloo to Victoria line.  Thanks to QuickGraph we can easily model the London underground as a graph.

image

The way this works is that we have our TrainLine and Station classes each populated with the relevant names.  Each TrainLine has an ordered list of it’s Stations.  We then loop through each of the TrainLines and their Stations to create a graph, adding “edges” between each of the stations.  This map is then used by the library to calculate the shortest path. Source:  https://github.com/stevenh77/QuickGraphExample/

Simple Many to Many design

A linked list would be a more logical representation of stations for a train line but for this example we’re using a list.

Material Design: Google’s new design language

image

image

image

image

image

image

image

image

image

 

image

image 

image

image

image

image

image

image

image

image

image

image

For more info check out:  http://google.com/design

You can check out some examples on the Polymer website, here’s one to get you started:  http://www.polymer-project.org/apps/topeka/

12345678910111213