Saving SVGtree

Possibly.

If SWISH is a requirement then I can not be of any practical help. If using SWI-Prolog from the top level is allowed then I might be of assistance.

For generating graphics depicting graphs (node/edge) which includes trees, SVG is nice but the image is static. A better solution I have found is to use Cytoscape.js, which should not to be confused with Cystoscape, that allows one to interact with the image and data. Granted it is a much greater level of complexity but for certain needs worth the effort.

See: Wiki Discussion: Generating Cytoscape.js graphs with SWI-Prolog. It gives a working example but the example is still far from any I would use in a production setting.

Can you give more clarity to

  1. The goal, e.g. display a tree based on Prolog facts and the facts are simply edge(From,To).
  2. The constraints (these are just examples, please create a new set from scratch)
    a. Can only use SWISH
    b. Must be able to display with an internet browser
    c. The image only needs to be static.
    d. Prefer to avoid transformation applications like GraphViz and Cytoscape.js
    e. Generate output format using only SWI-Prolog
    f. Can make use of html//1
    g. Can make use of SWI-Prolog packs

GraphViz can generate SVG. I have done this often in the past but have moved away from GraphViz a few years ago as I prefer dynamic interaction to static displays.

See this post for an example of an SVG generated using GraphViz which was based on Prolog facts.

1 Like