Advertisement
Guest User

Untitled

a guest
Jun 7th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 1.34 KB | None | 0 0
  1. % *****************************************************************************
  2. % **  Succesor                                                                *
  3. % *****************************************************************************
  4. % succ(+UG, -PL, -SL)                                                         *
  5. % First, find normalized version of UG graph G.                               *
  6. % Then find all predecessor and successors pairs.                             *
  7. % SL is a successor of PL if:                                                 *
  8. % i) SL is f path: [v_1, v_2, .., v_n] and PL is f path: [u_1, u_2, .., u_m], *
  9. % ii) m <= n,                                                                 *
  10. % iii) for i = 1..m, there is e(u_i, v_i) in G.                               *
  11. % *****************************************************************************
  12. succ(UG, PL, SL) :- normalize(UG, G), nPermuting(G), lsucc(G, PL, SL).
  13.  
  14. lsucc(G, [], SL) :- fPath(SL, G).
  15. lsucc(G, [V], [U]) :- graphVtx(V, G), graphVtx(U, G), e(V, U, G).
  16. lsucc(G, [V], [U1|[U2|SL]]) :- graphVtx(V, G), graphVtx(U1, G), graphVtx(U2, G), e(V, U1, G), f(U1, U2, G), lsucc(G, [], [U2|SL]).
  17. lsucc(G, [V1|[V2|PL]], [U1|[U2|SL]]) :- graphVtx(V1, G), graphVtx(U1, G), graphVtx(V2, G), graphVtx(U2, G), f(V1, V2, G), f(U1, U2, G), e(V1, U1, G), lsucc(G, [V2|PL], [U2|SL])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement