From 4feb8f3fab93342fb7e014a042f755a95665264e Mon Sep 17 00:00:00 2001
From: Antoine Castillon <antoine.castillon@ens-lyon.fr>
Date: Sun, 13 Mar 2022 15:00:22 +0000
Subject: [PATCH] Upload New File

---
 summarization.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 summarization.py

diff --git a/summarization.py b/summarization.py
new file mode 100644
index 0000000..1e0d708
--- /dev/null
+++ b/summarization.py
@@ -0,0 +1,47 @@
+
+import networkx as nx
+
+def DSS_summarization(G,QuasiCliques):
+    "compress G into H using the DSS method"
+    
+    copy_G = G.copy()
+    
+    def loss_edges(C):
+        "return the non edges inside C"
+        loss_edges_list = []
+        
+        for i in range(1,len(C)):
+            for j in range(i):
+                u = C[i]
+                v = C[j]
+                
+                if not (u in list(G[v])):
+                    loss_edges_list.append((u,v))
+        
+        return loss_edges_list
+        
+    
+    H = nx.Graph()
+    H.add_nodes_from(range(len(QuasiCliques)))
+    
+    for i in range(len(QuasiCliques)):
+        H.nodes[i]['super_node_set'] = QuasiCliques[i]
+        H.nodes[i]['loss_edges'] = loss_edges(QuasiCliques[i])
+        
+        for j in range(1,len(QuasiCliques[i])):
+            u = QuasiCliques[i][j]
+            copy_G.remove_edges_from([(u,QuasiCliques[i][k]) for k in range(j)])
+    
+    return H, copy_G        # copy_G are the remaining edges
+
+
+
+def summary_size(H,remaining_edges):
+    "compute the size of the summary"
+    
+    size = len(remaining_edges.edges)
+    for i_Su in H.nodes:
+        Su = H.nodes[i_Su]
+        size += len(Su['super_node_set'])+len(Su['loss_edges'])
+    
+    return size
\ No newline at end of file
-- 
GitLab