5
5
6
6
7
7
class Squash :
8
+ """
9
+ A class for handling the full process of graph compression using primarily default values.
10
+ If the Memgraph Database already contains a compressed graph this class allows access
11
+ to the core graph as well as associated metrics via the individual stages of compression (see attributes).
12
+
13
+ ...
14
+
15
+ Attributes
16
+ ----------
17
+ decomposer : KCoreIdentifier
18
+ The KCoreIdentifier used in the compression process. Use to access metrics and associated attributes.
19
+ aggolmerator : GraphAgglomerator
20
+ The GraphAgglomerator used in the compression process. Use to access metrics and associated attributes.
21
+ meta_relator : MetaRelate
22
+ The MetaRelate class used in the compression process. Use to access metrics and associated attributes.
23
+
24
+ Methods
25
+ ----------
26
+ squash_graph(max_cores=500, k=2, min_hops=None, max_hops=None)
27
+ Generates the compressed core graph. Steps through each stage of core identification,
28
+ assignment of representatives and the generation of meta-relations.
29
+
30
+ get_core_edge_list()
31
+ Returns a list of dictionary edges of format {source, target, **weight values}.
32
+ Equivalent to MetaRelate.get_core_edge_list()
33
+
34
+ get_core_node_list()
35
+ Returns a list of dictionary node records of format {id, n_subnodes}
36
+ where n_subnodes is the number of node_label nodes represented by each core node.
37
+ Equivalent to MetaRelate.get_core_node_list()
38
+ reset()
39
+ Wipes all core graph metrics and assignments from the database ready to re-run compression.
40
+
41
+ """
42
+
43
+ decomposer : KCoreIdentifier
44
+ agglomerator : GraphAgglomerator
45
+ meta_relator : MetaRelate
46
+
8
47
def __init__ (self , node_label : str , relation_label : str , weight_label : str = None , db_address : str = 'localhost' ,
9
48
db_port : int = 7687 , decomposer : KCoreIdentifier = None ,
10
49
agglomerator : GraphAgglomerator = None , meta_relator : MetaRelate = None ):
50
+ """
51
+
52
+ Parameters
53
+ ----------
54
+ node_label : str
55
+ The label of the nodes to be compressed.
56
+ relation_label : str
57
+ The label of the relations to be compressed.
58
+ weight_label: str, optional
59
+ The label of the attribute containing a weight value. Use this if your raw graph is weighted.
60
+ db_address: str, optional
61
+ Address of the Memgraph database (default is 'localhost')
62
+ db_port: int, optional
63
+ Port number of the Memgraph database.
64
+ decomposer: KCoreIdentifier, optional
65
+ To use non-default settings pass in a custom instance of KCoreIdentifier.
66
+ agglomerator: GraphAgglomerator, optional
67
+ To use non-default settings pass in a custom instance of GraphAgglomerator.
68
+ meta_relator: MetaRelate, optional
69
+ To use non-default settings pass in a custom instance of MetaRelate.
70
+ """
71
+
11
72
self .db = Memgraph (address = db_address , port = db_port )
12
73
13
74
self .decomposer = decomposer
@@ -18,11 +79,11 @@ def __init__(self, node_label: str, relation_label: str, weight_label: str = Non
18
79
self .decomposer = KCoreIdentifier (self .db , node_label , relation_label )
19
80
if self .agglomerator is None :
20
81
self .agglomerator = GraphAgglomerator (self .db , node_label ,
21
- relation_label ,
22
- weight = weight_label )
82
+ relation_label ,
83
+ weight = weight_label )
23
84
if self .meta_relator is None :
24
85
self .meta_relator = MetaRelate (self .db , node_label , relation_label ,
25
- weight = weight_label )
86
+ weight = weight_label )
26
87
27
88
def reset (self ):
28
89
self .meta_relator .reset ()
0 commit comments