Search code examples
prologvisualizationgraphvizcode-analysis

Visualizing prolog rule dependencies


I have a prolog program that has some rather complicated recursive logic. I'd like to visualize the dependency of the rules to better understand the program. Is there some utility that can convert a prolog program to say, a GraphViz file, for visualization?

All of my predicates are contained in one XSB prolog file.


Solution

  • Logtalk (which supports 12 Prolog systems) provides a diagrams tool that can generate several kinds of diagrams, including cross-referencing diagrams. It can also be used with some limitations, depending on the Prolog system, to create diagrams for Prolog code. For example:

    http://logtalk.org/diagrams/swi_prolog_library_entity_diagram.svg

    An example of a cross-referencing diagram (generated using an old version of tool) is:

    http://logtalk.org/diagrams/pengines_module_xref_diagram.pdf

    This tool may be a viable option (it's default output is GraphViz .dot files) in your case depending on the Prolog system that you're using and how you organize your code. Maybe you can update your post with some more details?