Graphs in PROLOG Adam Volk
PROLOG Introduction • Programmer tells the system what to find, not how to find it • 2 parts to using PROLOG • Declaration of facts and rules • Asking questions dependent on those facts and rules • Pattern matching key! • Example
Problem Considered • PROLOG implementation of graphs • G = (Vertices, Edges) • G = ( {x,y,z} , {(x,y), (y,z), (x,z)} ) • graph( [ [x,y,z], [ [x,y],[y,z],[x,z] ] ] ).
Methods Studied • chain(G,Start,End,Chain) • graph(G) • tree (G) • vertex(G,V) • outdegree(G,V) • edge(G,E) • complete(G) • has_cycle(G,V) Complete graph K5
Methods Studied • chain(G,Start,End,Chain) • graph(G) • tree (G) • vertex(G,V) • outdegree(G,V) • edge(G,E) • complete(G) • has_cycle(G,V) Complete graph K5
Demo
Thank you
References • Bratko, I., Programming in Prolog for Artificial Intelligence, 4 th Edition. Addison-Wesley, 2011, chapters 1-5. • Matuszek, D., A Concise Introduction to Prolog . • Pereira, F., A Brief Introduction to Prolog . ACM Digital Library.
Recommend
More recommend