Computer science students are typically introduced to graph traversal early in their coursework. It’s also a topic often used as a talking point or whiteboard exercise during many engineering interviews. Outside of those contexts, it might be hard to find a non-contrived reason to brush up on graph traversal algorithms. I recently reacquainted myself while working on a game I’ve been building in my spare time. The game contains a galaxy map with interconnected star systems, and the player uses the map to calculate a flight path between those systems. This post discusses a depth-first search algorithm with path tracing used to build this feature.
A traditional Rails application uses a single database. Programmers interact with it by writing models that inherit from
ActiveRecord::Base. As the application grows, it may be useful to connect to different databases for a variety of reasons. One database might be dedicated to reports. Another may be the result of an entirely different process, and now the Rails application wants to read from it. Using multiple databases helps a Rails application scale, and may be a more manageable first step toward an architecture based on microservices.