diprism / fggs

Factor Graph Grammars in Python
MIT License
13 stars 3 forks source link

Let HRG and Graph share labeling (review me 1st) #158

Open davidweichiang opened 2 years ago

davidweichiang commented 2 years ago

This lets all the rules of an HRG share a single edge_labels registry (as suggested in #140), which makes it possible to catch errors like adding an edge to a rule rhs whose label clashes with one from another rule.

davidweichiang commented 2 years ago

As mentioned in #140, this will eventually also make it possible to use FGG.new_rule to create and add an empty rule to the grammar and then add nodes and edges to the rule.

davidweichiang commented 2 years ago

Possible objections:

  1. edge_labels is going to be much bigger than before, which could be slower. Indeed factorize_hrg became much slower so I had to fix it.

  2. There is no mechanism for removing an entry from edge_labels if all the edges that use a label are removed. This has always been an issue, but now it could be worse: imagine adding an edge labeled el1 to rule1, removing it, then adding an edge labeled el2 to rule2 in the same grammar, and el1 and el2 are conflicting.

davidweichiang commented 2 years ago

OK to merge this one?

davidweichiang commented 2 years ago

@darcey Can we discuss this one?