@@ -213,6 +213,7 @@ def __init__(self, graph_db: List[nx.DiGraph], subgraphs: List[nx.DiGraph], labe
213213 self .occurrences_transaction = {}
214214 self .occurrences_embeddings = {}
215215 self .occurrences_references = {}
216+ self .compressions = {}
216217 self .lattice = lattice
217218
218219 def _set_label_name (self ):
@@ -259,7 +260,8 @@ def compute_occurrences_lattice_based(self):
259260 self .occurrences_transaction [lattice_node .graph .name ] = len (lattice_node .occurrences )
260261 # the occurrences of the nodes is just the id in the graph database, we want to get the names of the graphs instead
261262 self .occurrences_references [lattice_node .graph .name ] = [self .graph_db [graph_id ].name for graph_id in lattice_node .occurrences ]
262-
263+ # absolute compresion (heuristic)
264+ self .compressions [lattice_node .graph .name ] = (len (lattice_node .occurrences )- 1 ) * (len (lattice_node .graph .nodes ()) + len (lattice_node .graph .edges ()))
263265
264266 def write_as_csv (self , save_path , additional_tag ):
265267 '''
@@ -277,8 +279,8 @@ def write_as_csv(self, save_path, additional_tag):
277279 occurrences_embeddings = self .occurrences_embeddings [subgraph .name ] if subgraph .name in self .occurrences_embeddings .keys () else 0
278280 occurrences_transaction = self .occurrences_transaction [subgraph .name ] if subgraph .name in self .occurrences_transaction .keys () else 0
279281 occurrences_references = self .occurrences_references [subgraph .name ] if subgraph .name in self .occurrences_references .keys () else []
280- csvwriter . writerow ( [subgraph .name , additional_tag , occurrences_embeddings , occurrences_transaction , occurrences_references ])
281-
282+ compression = self . compressions [subgraph .name ] if subgraph . name in self . compressions . keys () else 0
283+ csvwriter . writerow ([ subgraph . name , additional_tag , occurrences_embeddings , occurrences_transaction , compression , occurrences_references ])
282284
283285 def write_as_md (self , save_path , project_name ):
284286 os .makedirs (os .path .dirname (save_path ), exist_ok = True )
@@ -291,7 +293,7 @@ def write_as_md(self, save_path, project_name):
291293 occurrences_references = self .occurrences_references [subgraph .name ] if subgraph .name in self .occurrences_references .keys () else []
292294 mdfile .write (f"Frequency: { occurrences_transaction } \n \n " )
293295 mdfile .write ("Put your notes here\n \n " )
294- mdfile .write ("<details><summary>Matches</summar ><p>\n " )
296+ mdfile .write ("<details><summary>Matches</summary ><p>\n " )
295297 for occurrence in occurrences_references :
296298 tokens = occurrence .split ('$$$' )
297299 if not len (tokens ) >= 2 :
0 commit comments