Visualizing CityRail with Cytoscape

Visualizing or visualising?  Doesn’t really matter.

The idea here is to render the Sydney Rail Network (aka CityRail) using Cytoscape, an open source application typically used by researchers to visualizing bioinformation.  My original idea was actually to visualize something plain like Facebook friend networks but decided on the CityRail niche because it partly relates to my work.

Behold the CityRail Galactic Empire...(Larger image after the break)
Behold the CityRail Galactic Empire...(Larger image after the break)

Depressing as it may sound, I’ve been itching to do something related to work outside of work.  An original idea was to make papercraft model trains, but I’m too lazy to go around taking photos of trains (I actually hate trains…).

So lets start!

Requirements :-

  1. Information must be publicly available.  i.e. I can’t use confidential information and get fired for it…
  2. The end result has to be both ‘useful’ and ‘pretty’.   i.e. I can’t fail this one since they’re both subjective…
  3. This can’t take too long or I’ll view this as too nerdy an exercise and give up…

Method :-

  1. Get the CityRail timetable.
  2. Parse it.
  3. Generate a fancy visualization based on the data.

Definitions (This is/was written down for my own benefit…I haven’t started yet…) :-

  1. A node is a train station on the Sydney metropolitan network (CityRail)
  2. A node is categorized by how many trains start/stop/end at this station.
  3. A link(edge) between two nodes is created when a train leaves one station/node and stops at another without any intermediate stops.
  4. A link(edge) is categorized by the distance between the two nodes, the average time for all trains to transverse the link, and the average speed of trains on this link.

Result :-

The CityRail Interstellar Network...(Can't get over how it looks like a space network map)...Click to Enlarge
The CityRail Interstellar Network...(Can't get over how it looks like a space network map)...Click to Enlarge

Some explanations and a bit of review…

The layout is based on link weighted springs, basically the length of the link is representative of the distance between the stations.

The link colour represents the average speed of trains on that link.  Light blue is fast/good, purple is slow/bad.

The node/station size represents the number of trains that stop at that station.  Central is huge!  Redfern, Town Hall, Sydenham and Strathfield are also obviously key hubs as well.

This took way longer than expected…I made heaps of typos in the parser script and debugging it was hell because the typos all looked ‘legitimate’ (e.g. I typed ‘stations’ instead of ‘nodes’ as the table name…).

But hey the exercise was fruitful.   Its pretty!   It shows some interesting pieces of information (which I won’t spell out)…

Post a comment if you are interested in the cytoscape source file or a SVG vector graphics file of the image 🙂

Author’s Note : I’m an avid ‘avoider’ of train travel.

Leave a Reply

Your email address will not be published. Required fields are marked *