https://github.com/fancellu/graphx-citymap
CityMap coding test plus 3 solutions, 1 with Spark/GraphX
https://github.com/fancellu/graphx-citymap
graphx scalatest spark
Last synced: about 1 month ago
JSON representation
CityMap coding test plus 3 solutions, 1 with Spark/GraphX
- Host: GitHub
- URL: https://github.com/fancellu/graphx-citymap
- Owner: fancellu
- License: mit
- Created: 2015-10-06T09:57:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-11T14:53:08.000Z (over 9 years ago)
- Last Synced: 2025-04-03T16:52:13.247Z (2 months ago)
- Topics: graphx, scalatest, spark
- Language: Scala
- Homepage:
- Size: 0 Bytes
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CityMap coding test plus 3 solutions #
[](https://travis-ci.org/fancellu/graphx-citymap)
The problem is to provide an algorithm to calculate if a journey is possible for a series of locations in a city, connected by roads. You need to write an implementation for a class as follows:
/**
* @param routesAndLocations A String specification of the
* routes between locations. A comma-separated list
* of roads and paths between locations defined as
* [startLocation][type][endLocation] e.g.
*
* "a-b" represents two locations, where travel is only possible
* from a to b on foot
* "a-b,b-a" represents two locations, where travel
* is possible in both directions on foot
* "a=b,b=c,c=a" represents a triangular one-way road travelling
* from a, through b and c, and finally back to a.
*
* Routes can be of two types:
* - Paths (accessible on foot only)
* = Roads (accessible on foot & by car)
*/
class CityMap(routesAndLocations: String) {
/**
* Determine whether a journey from the startLocation to the
* destinationLocation can be made, based on the available routes
* and whether on foot (onFoot=true), or by car (onFoot=false)
*/
def isJourneyPossible(startLocation: String, destinationLocation: String, onFoot: Boolean): Boolean = ???
}## Solutions ##
3 solutions are supplied, first 2 in pure Scala, the 3rd using Spark+GraphX
[CityMapA](../../tree/master/src/main/scala/com/felstar/citymap/CityMapA.scala)
[CityMapB](../../tree/master/src/main/scala/com/felstar/citymap/CityMapB.scala)
[CityMapGraphX](../../tree/master/src/main/scala/com/felstar/citymap/CityMapGraphX.scala)
along with ScalaTest to test them all
[CityMapTest](../../tree/master/src/test/scala/com/felstar/citymap/CityMapTest.scala)