Optimizing Paths and Weighted Paths
So far, we’ve spent a good amount of time working on solutions that return accurate solutions. That’s interesting, but much better is getting the best solution! Be careful, though. With large datasets, it’s easy to chew up plenty of memory and time if your algorithm isn’t efficient.
In this section, we’re going to look at some built-in Prolog features that let us roll up many potential results and choose the best one. As we plan a minimal solution, we’ll unlock the secret to dealing with weighted graphs, which are graphs having edges with a cost or benefit. Using these techniques, we can count the solutions to a problem, build a collection of solutions, or work out the combined cost or value of all possible ...
Get Programmer Passport: Prolog now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.