Strange question about transit schematics (title tbd)
graphical-output popularity-contest
In this challenge, your goal is to produce a schematic diagram of a transit network, given a list of lines and a list of stations as input. This is a popularity-contest -- the program's goal is to maximize the readability of the diagram by carefully choosing where to draw the stations and lines.
Each line in the transit network is formatted as a list of strings. For instance:
"Peel Line", "Douglas", "Port Erin", "Braddan Halt", "Union Mill", "Crosby"
The first string on the list is the name of the line. The remaining strings are the stations that that particular line stops at. In this example the Peel Line stops at Douglas, Port Erin, Braddan Halt, Union Mill, and terminates at Crosby. The lines are bidirectional so the Peel Line would also go back the other way.
Of course, most transit networks will have more than one line. Each line of the transit network will have its own line in the input. For instance:
"Peel Line", "Douglas", "Port Erin", "Braddan Halt", "Union Mill", "Crosby"
"Foxdale Line", "Ramsey", "St. John's", "Union Mill", "Bishop", "Foxdale"
Notice how both lines stop at Union Mill. This means that Union Mill is an interchange station for those two lines. A station is an interchange station if more than one line stops at it. Here is an attempt at what the network might look like:
This map does some things well but fails at other things. The lines are coloured different colours which helps differentiate the lines. In addition, the interchange station is emphasised with the white dot to show it is an interchange station. However, it fails at other things, the most prominent being that the text "Union Mill" is overlapping the line, and there is a lack of a key showing which line is which. When we fix these elements the map looks like this:
Much better! (Another way I could have resolved the Union Mill overlapping issue was to change the paths of the lines.) In addition, we can also have lines being a loop. This is indicated by the first and last train stations being the same. For instance:
"Island Line", "Port Erin", "Kitterland", "Kalfr", "Ardglass", "Kearney", "Port Erin"
The Island Line in this case is a loop that goes from Port Erin to Kitterland to Kalfr, then to Ardglass and Kearney, before finally returning to Port Erin, completing the loop.
With more complicated train networks, it becomes more difficult to arrange the stations and lines in a readable manner. Here are some inputs of varying complexity and density to try your program on. Some of them are based of actual networks, while others are made up for this challenge.
Challenge Input 1: Oslo, Norway:
"1", "Frognerseteren", "Voksenkollen", "Lillevann", "Skogen", "Voksenlia", "Holmenkollen", "Besserud", "Midtstuen", "Skådalen", "Vettakollen", "Gulleråsen", "Gråkammen", "Slemdal", "Ris", "Gaustad", "Vinderen", "Steinerud", "Frøen", "Majorstuen", "Nationaltheatret", "Stortinget", "Jernbanetorget (Oslo S)", "Grønland", "Tøyen", "Ensjø", "Helsfyr", "Brynseng", "Hellerud", "Tveita", "Haugerud", "Trosterud", "Lindeberg", "Furuset", "Ellingsrudåsen"
"2", "Østerås", "Lijordet", "Eiksmarka", "Ekravein", "Røa", "Hovseter", "Holmen", "Makrellbekken", "Smestad", "Borgen", "Majorstuen", "Nationaltheatret", "Stortinget", "Jernbanetorget (Oslo S)", "Grønland", "Tøyen", "Ensjø", "Helsfyr", "Brynseng", "Hellerud", "Tveita", "Haugerud", "Trosterud", "Lindeberg", "Furuset", "Ellingsrudåsen"
"3", "Mortensrud", "Skullerud", "Bogerud", "Bøler", "Ulsrud", "Oppsal", "Skøyenåsen", "Godlia", "Hellerud", "Brynseng", "Helsfyr", "Ensjø", "Tøyen", "Grønland", "Jernbanetorget (Oslo S)", "Stortinget", "Nationaltheatret", "Majorstuen", "Blindern", "Forskningsparken", "Ullevål stadion", "Berg", "Tåsen", "Østhorn", "Holstein", "Kringsjå", "Sognsvann"
"4", "Storo", "Nydalen", "Ullevål stadion", "Forskningsparken", "Blindern", "Majorstuen", "Nationaltheatret", "Stortinget", "Jernbanetorget (Oslo S)", "Grønland", "Tøyen", "Ensjø", "Helsfyr", "Brynseng", "Høyenhall", "Manglerud", "Ryen", "Brattlikollen", "Karlsrud", "Lambertseter", "Munkelia", "Bergkrystallen"
"5", "Storo", "Nydalen", "Ullevål stadion", "Forskningsparken", "Blindern", "Majorstuen", "Nationaltheatret", "Stortinget", "Jernbanetorget (Oslo S)", "Grønland", "Tøyen", "Carl Berners plass", "Hasle", "Økern", "Risløkka", "Vollebekk", "Linderud", "Veitvet", "Rødtvet", "Kalbakken", "Ammerud", "Grorud", "Romsås", "Rommen", "Stovner", "Vestli"
"6", "Bekkestua", "Ringstabekk", "Jar", "Bjørnsletta", "Åsjordet", "Ullernåsen", "Montebello", "Smestad", "Borgen", "Majorstuen", "Nationaltheatret", "Stortinget", "Jernbanetorget (Oslo S)", "Grønland", "Tøyen", "Carl Berners plass", "Sinsen", "Storo"
Here's what the official map looks like for some inspiration (click to enlarge):
TODO: more challenge inputs coming!
Sandbox Notes
- I've had this one sitting around for a while. I've wanted to try and make a popularity-contest graphical-output that wasn't just about making the prettiest image. So instead it's about making the most functional image, which I'm not sure is any better than the art challenges...
- Another thing I've been considering is changing it to a code-golf. I'd have minimum requirements for the final output (a key, coloured lines, distinguished interchange stations, etc.) and the shortest code that implemented all the requirements would win. I'd like your thoughts on whether this challenge would work better as code golf or popularity contest.