Skip to content

Commit 84f76d3

Browse files
committed
Merge branch 'documentation'
2 parents a3fb826 + 6ac786c commit 84f76d3

File tree

1 file changed

+64
-3
lines changed

1 file changed

+64
-3
lines changed

Diff for: squashy/squash.py

+64-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,70 @@
55

66

77
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+
847
def __init__(self, node_label: str, relation_label: str, weight_label: str = None, db_address: str = 'localhost',
948
db_port: int = 7687, decomposer: KCoreIdentifier = None,
1049
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+
1172
self.db = Memgraph(address=db_address, port=db_port)
1273

1374
self.decomposer = decomposer
@@ -18,11 +79,11 @@ def __init__(self, node_label: str, relation_label: str, weight_label: str = Non
1879
self.decomposer = KCoreIdentifier(self.db, node_label, relation_label)
1980
if self.agglomerator is None:
2081
self.agglomerator = GraphAgglomerator(self.db, node_label,
21-
relation_label,
22-
weight=weight_label)
82+
relation_label,
83+
weight=weight_label)
2384
if self.meta_relator is None:
2485
self.meta_relator = MetaRelate(self.db, node_label, relation_label,
25-
weight=weight_label)
86+
weight=weight_label)
2687

2788
def reset(self):
2889
self.meta_relator.reset()

0 commit comments

Comments
 (0)