I would like to introduce a volatile graph in Prolog in an efficient way. I will look for subsets in the graph and replace them with other subsets.
I managed to get something using the database as my graph repository. For example, I have:
:- dynamic step/2. % step(Type, Name). :- dynamic sequence/2. % sequence(Step, NextStep).
Then I use a few rules for the retract subsets that I have mapped, and replace them with new steps with assert . I really like this method ... it is easy to read and process, and I let Prolog do a lot of hard work on pattern matching.
Another way I know to represent graphs is by using lists of nodes and adjacencies. I have seen many sites using this method, but I doubt a little because it is more overhead.
Lead time is important to me, as is simplicity for myself.
What are the pros and cons for any approach?
source share