Skip to content

Commit b7bab91

Browse files
committed
Community mutate
1 parent a131610 commit b7bab91

File tree

5 files changed

+74
-60
lines changed

5 files changed

+74
-60
lines changed

graphdatascience/procedure_surface/api/community/k1coloring_endpoints.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

1212

1313
class K1ColoringEndpoints(ABC):
14-
"""
15-
Abstract base class defining the API for the K-1 Coloring algorithm.
16-
"""
1714

1815
@abstractmethod
1916
def mutate(
@@ -31,32 +28,35 @@ def mutate(
3128
job_id: Optional[Any] = None,
3229
) -> K1ColoringMutateResult:
3330
"""
34-
Executes the K-1 Coloring algorithm and writes the results to the in-memory graph as node properties.
31+
Runs the K-1 Coloring algorithm and stores the results in the graph catalog as a new node property.
32+
33+
The K-1 Coloring algorithm assigns a color to every node in the graph, trying to optimize for two objectives:
34+
to make sure that every neighbor of a given node has a different color than the node itself, and to use as few colors as possible.
3535
3636
Parameters
3737
----------
3838
G : GraphV2
3939
The graph to run the algorithm on
4040
mutate_property : str
41-
The property name to store the color for each node
41+
Name of the node property to store the results in.
4242
batch_size : Optional[int], default=None
4343
The batch size for processing
4444
max_iterations : Optional[int], default=None
45-
The maximum number of iterations of K-1 Coloring to run
45+
Maximum number of iterations to run.
4646
relationship_types : Optional[List[str]], default=None
47-
The relationships types used to select relationships for this algorithm run
47+
Filter the graph using the given relationship types. Relationships with any of the given types will be included.
4848
node_labels : Optional[List[str]], default=None
49-
The node labels used to select nodes for this algorithm run
49+
Filter the graph using the given node labels. Nodes with any of the given labels will be included.
5050
sudo : Optional[bool], default=None
51-
Override memory estimation limits
51+
Disable the memory guard.
5252
log_progress : Optional[bool], default=None
53-
Whether to log progress
53+
Display progress logging.
5454
username : Optional[str], default=None
55-
The username to attribute the procedure run to
55+
As an administrator, run the algorithm as a different user, to access also their graphs.
5656
concurrency : Optional[Any], default=None
57-
The number of concurrent threads
57+
Number of CPU threads to use.
5858
job_id : Optional[Any], default=None
59-
An identifier for the job
59+
Identifier for the computation.
6060
6161
Returns
6262
-------

graphdatascience/procedure_surface/api/community/kcore_endpoints.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,32 @@ def mutate(
2929
job_id: Optional[Any] = None,
3030
) -> KCoreMutateResult:
3131
"""
32-
Executes the K-Core algorithm and writes the results to the in-memory graph as node properties.
32+
Runs the K-Core Decomposition algorithm and stores the results in the graph catalog as a new node property.
33+
34+
The K-core decomposition constitutes a process that separates the nodes in a graph into groups based on the degree sequence and topology of the graph.
35+
The term `i-core` refers to a maximal subgraph of the original graph such that each node in this subgraph has degree at least `i`.
36+
Each node is associated with a core value which denotes the largest value `i` such that the node belongs to the `i-core`.
3337
3438
Parameters
3539
----------
3640
G : GraphV2
3741
The graph to run the algorithm on
3842
mutate_property : str
39-
The property name to store the core value for each node
43+
Name of the node property to store the results in.
4044
relationship_types : Optional[List[str]], default=None
41-
The relationships types used to select relationships for this algorithm run
45+
Filter the graph using the given relationship types. Relationships with any of the given types will be included.
4246
node_labels : Optional[List[str]], default=None
43-
The node labels used to select nodes for this algorithm run
47+
Filter the graph using the given node labels. Nodes with any of the given labels will be included.
4448
sudo : Optional[bool], default=None
45-
Override memory estimation limits
49+
Disable the memory guard.
4650
log_progress : Optional[bool], default=None
47-
Whether to log progress
51+
Display progress logging.
4852
username : Optional[str], default=None
49-
The username to attribute the procedure run to
53+
As an administrator, run the algorithm as a different user, to access also their graphs.
5054
concurrency : Optional[Any], default=None
51-
The number of concurrent threads
52-
job_id : Optional[Any], default=None
53-
An identifier for the job
55+
Number of CPU threads to use.
56+
job_id : Optional[Any] = None
57+
Identifier for the computation.
5458
5559
Returns
5660
-------

graphdatascience/procedure_surface/api/community/louvain_endpoints.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,46 @@ def mutate(
3636
relationship_weight_property: Optional[str] = None,
3737
) -> LouvainMutateResult:
3838
"""
39-
Executes the Louvain algorithm and writes the results to the in-memory graph as node properties.
39+
Runs the Louvain algorithm and stores the results in the graph catalog as a new node property.
40+
41+
The Louvain method is an algorithm to detect communities in large networks.
42+
It maximizes a modularity score for each community, where the modularity quantifies the quality of an assignment of nodes to communities by evaluating how much more densely connected the nodes within a community are, compared to how connected they would be in a random network.
43+
The Louvain algorithm is a hierarchical clustering algorithm that recursively merges communities into a single node and runs the modularity clustering on the condensed graphs.
4044
4145
Parameters
4246
----------
4347
G : GraphV2
4448
The graph to run the algorithm on
4549
mutate_property : str
46-
The property name to store the community ID for each node
50+
Name of the node property to store the results in.
4751
tolerance : Optional[float], default=None
48-
The tolerance value for the algorithm convergence
52+
Minimum change in scores between iterations.
4953
max_levels : Optional[int], default=None
5054
The maximum number of levels in the hierarchy
5155
include_intermediate_communities : Optional[bool], default=None
52-
Whether to include intermediate community assignments
56+
Whether to include intermediate communities
5357
max_iterations : Optional[int], default=None
54-
The maximum number of iterations per level
58+
Maximum number of iterations to run.
5559
relationship_types : Optional[List[str]], default=None
56-
The relationships types used to select relationships for this algorithm run
60+
Filter the graph using the given relationship types. Relationships with any of the given types will be included.
5761
node_labels : Optional[List[str]], default=None
58-
The node labels used to select nodes for this algorithm run
62+
Filter the graph using the given node labels. Nodes with any of the given labels will be included.
5963
sudo : Optional[bool], default=None
60-
Override memory estimation limits
64+
Disable the memory guard.
6165
log_progress : Optional[bool], default=None
62-
Whether to log progress
66+
Display progress logging.
6367
username : Optional[str], default=None
64-
The username to attribute the procedure run to
68+
As an administrator, run the algorithm as a different user, to access also their graphs.
6569
concurrency : Optional[Any], default=None
66-
The number of concurrent threads
70+
Number of CPU threads to use.
6771
job_id : Optional[Any], default=None
68-
An identifier for the job
72+
Identifier for the computation.
6973
seed_property : Optional[str], default=None
70-
Defines node properties that are used as initial community identifiers
74+
The property name that contains seed values
7175
consecutive_ids : Optional[bool], default=None
72-
Flag to decide whether community identifiers are mapped into a consecutive id space
76+
Whether to use consecutive IDs
7377
relationship_weight_property : Optional[str], default=None
74-
The property name that contains weight
78+
Name of the property to be used as weights.
7579
7680
Returns
7781
-------

graphdatascience/procedure_surface/api/community/scc_endpoints.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,33 @@ def mutate(
3030
consecutive_ids: Optional[bool] = None,
3131
) -> SccMutateResult:
3232
"""
33-
Executes the SCC algorithm and writes the results to the in-memory graph as node properties.
33+
Runs the Strongly Connected Components algorithm and stores the results in the graph catalog as a new node property.
34+
35+
The Strongly Connected Components (SCC) algorithm finds maximal sets of connected nodes in a directed graph.
36+
A set is considered a strongly connected component if there is a directed path between each pair of nodes within the set.
3437
3538
Parameters
3639
----------
3740
G : GraphV2
3841
The graph to run the algorithm on
3942
mutate_property : str
40-
The property name to store the component ID for each node
43+
Name of the node property to store the results in.
4144
relationship_types : Optional[List[str]], default=None
42-
The relationships types used to select relationships for this algorithm run
45+
Filter the graph using the given relationship types. Relationships with any of the given types will be included.
4346
node_labels : Optional[List[str]], default=None
44-
The node labels used to select nodes for this algorithm run
47+
Filter the graph using the given node labels. Nodes with any of the given labels will be included.
4548
sudo : Optional[bool], default=None
46-
Override memory estimation limits
49+
Disable the memory guard.
4750
log_progress : Optional[bool], default=None
48-
Whether to log progress
51+
Display progress logging.
4952
username : Optional[str], default=None
50-
The username to attribute the procedure run to
53+
As an administrator, run the algorithm as a different user, to access also their graphs.
5154
concurrency : Optional[Any], default=None
52-
The number of concurrent threads
55+
Number of CPU threads to use.
5356
job_id : Optional[Any], default=None
54-
An identifier for the job
57+
Identifier for the computation.
5558
consecutive_ids : Optional[bool], default=None
56-
Flag to decide whether component identifiers are mapped into a consecutive id space
59+
Whether to use consecutive IDs for components
5760
5861
Returns
5962
-------

graphdatascience/procedure_surface/api/community/wcc_endpoints.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,39 @@ def mutate(
3333
relationship_weight_property: Optional[str] = None,
3434
) -> WccMutateResult:
3535
"""
36-
Executes the WCC algorithm and writes the results to the in-memory graph as node properties.
36+
Runs the Weakly Connected Components algorithm and stores the results in the graph catalog as a new node property.
37+
38+
The Weakly Connected Components (WCC) algorithm finds sets of connected nodes in directed and undirected graphs where two nodes are connected if there exists a path between them.
39+
In contrast to Strongly Connected Components (SCC), the direction of relationships on the path between two nodes is not considered.
3740
3841
Parameters
3942
----------
4043
G : GraphV2
4144
The graph to run the algorithm on
4245
mutate_property : str
43-
The property name to store the component ID for each node
46+
Name of the node property to store the results in.
4447
threshold : Optional[float], default=None
4548
The minimum required weight to consider a relationship during traversal
4649
relationship_types : Optional[List[str]], default=None
47-
The relationships types used to select relationships for this algorithm run
50+
Filter the graph using the given relationship types. Relationships with any of the given types will be included.
4851
node_labels : Optional[List[str]], default=None
49-
The node labels used to select nodes for this algorithm run
52+
Filter the graph using the given node labels. Nodes with any of the given labels will be included.
5053
sudo : Optional[bool], default=None
51-
Override memory estimation limits
54+
Disable the memory guard.
5255
log_progress : Optional[bool], default=None
53-
Whether to log progress
56+
Display progress logging.
5457
username : Optional[str], default=None
55-
The username to attribute the procedure run to
58+
As an administrator, run the algorithm as a different user, to access also their graphs.
5659
concurrency : Optional[Any], default=None
57-
The number of concurrent threads
60+
Number of CPU threads to use.
5861
job_id : Optional[Any], default=None
59-
An identifier for the job
62+
Identifier for the computation.
6063
seed_property : Optional[str], default=None
61-
Defines node properties that are used as initial component identifiers
64+
The property name that contains seed values
6265
consecutive_ids : Optional[bool], default=None
63-
Flag to decide whether component identifiers are mapped into a consecutive id space
66+
Whether to use consecutive IDs for components
6467
relationship_weight_property : Optional[str], default=None
65-
The property name that contains weight
68+
Name of the property to be used as weights.
6669
6770
Returns
6871
-------

0 commit comments

Comments
 (0)