Created
December 20, 2012 16:20
-
-
Save FabienArcellier/4346348 to your computer and use it in GitHub Desktop.
Resolve graph path using prolog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arc(b, a, 1). | |
arc(b, c, 3). | |
arc(a, d, 4). | |
arc(c, d, 5). | |
arc(d, e, 7). | |
arc(d, f, 6). | |
ch1(O, D, Longueur) :- arc(O, D, Longueur). | |
ch1(O, D, Longueur) :- arc(O, N, L0), ch1(N, D, L1), Longueur is L1 + L0. | |
ch2(O, D, Longueur, [O,D]) :- arc(O, D, Longueur). | |
ch2(O, D, Longueur, [O|R]) :- arc(O, N, L0), ch2(N, D, L1, R), Longueur is L1 + L0. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment