|
| 1 | +from abc import abstractmethod |
| 2 | +from typing import Any, Dict, List, Optional |
| 3 | + |
| 4 | +import pandas as pd |
| 5 | + |
| 6 | +from graphdatascience.procedure_surface.api.base_result import BaseResult |
| 7 | +from graphdatascience.procedure_surface.api.catalog.graph_api import GraphV2 |
| 8 | +from graphdatascience.procedure_surface.api.estimation_result import EstimationResult |
| 9 | + |
| 10 | + |
| 11 | +class LocalClusteringCoefficientEndpoints: |
| 12 | + """ |
| 13 | + Interface for LocalClusteringCoefficient algorithm endpoints. |
| 14 | + """ |
| 15 | + |
| 16 | + @abstractmethod |
| 17 | + def mutate( |
| 18 | + self, |
| 19 | + G: GraphV2, |
| 20 | + *, |
| 21 | + mutate_property: str, |
| 22 | + concurrency: Optional[int] = None, |
| 23 | + job_id: Optional[str] = None, |
| 24 | + log_progress: bool = True, |
| 25 | + node_labels: Optional[List[str]] = None, |
| 26 | + relationship_types: Optional[List[str]] = None, |
| 27 | + sudo: Optional[bool] = False, |
| 28 | + triangle_count_property: Optional[str] = None, |
| 29 | + username: Optional[str] = None, |
| 30 | + ) -> "LocalClusteringCoefficientMutateResult": |
| 31 | + """ |
| 32 | + Executes the LocalClusteringCoefficient algorithm and writes results back to the graph. |
| 33 | +
|
| 34 | + Parameters |
| 35 | + ---------- |
| 36 | + G : GraphV2 |
| 37 | + The graph on which to run the algorithm |
| 38 | + mutate_property : str |
| 39 | + Property name to store the result |
| 40 | + concurrency : Optional[int], default=None |
| 41 | + Number of concurrent threads |
| 42 | + job_id : Optional[str], default=None |
| 43 | + Job identifier for tracking |
| 44 | + log_progress : bool, default=True |
| 45 | + Whether to log progress |
| 46 | + node_labels : Optional[List[str]], default=None |
| 47 | + Node labels to include in the computation |
| 48 | + relationship_types : Optional[List[str]], default=None |
| 49 | + Relationship types to include in the computation |
| 50 | + sudo : Optional[bool], default=False |
| 51 | + Run with elevated privileges |
| 52 | + triangle_count_property : Optional[str], default=None |
| 53 | + Property name for pre-computed triangle counts |
| 54 | + username : Optional[str], default=None |
| 55 | + Username for authentication |
| 56 | +
|
| 57 | + Returns |
| 58 | + ------- |
| 59 | + LocalClusteringCoefficientMutateResult |
| 60 | + Result containing clustering coefficient statistics and timing information |
| 61 | + """ |
| 62 | + pass |
| 63 | + |
| 64 | + @abstractmethod |
| 65 | + def stats( |
| 66 | + self, |
| 67 | + G: GraphV2, |
| 68 | + *, |
| 69 | + concurrency: Optional[int] = None, |
| 70 | + job_id: Optional[str] = None, |
| 71 | + log_progress: bool = True, |
| 72 | + node_labels: Optional[List[str]] = None, |
| 73 | + relationship_types: Optional[List[str]] = None, |
| 74 | + sudo: Optional[bool] = False, |
| 75 | + triangle_count_property: Optional[str] = None, |
| 76 | + username: Optional[str] = None, |
| 77 | + ) -> "LocalClusteringCoefficientStatsResult": |
| 78 | + """ |
| 79 | + Executes the LocalClusteringCoefficient algorithm and returns statistics. |
| 80 | +
|
| 81 | + Parameters |
| 82 | + ---------- |
| 83 | + G : GraphV2 |
| 84 | + The graph on which to run the algorithm |
| 85 | + concurrency : Optional[int], default=None |
| 86 | + Number of concurrent threads |
| 87 | + job_id : Optional[str], default=None |
| 88 | + Job identifier for tracking |
| 89 | + log_progress : bool, default=True |
| 90 | + Whether to log progress |
| 91 | + node_labels : Optional[List[str]], default=None |
| 92 | + Node labels to include in the computation |
| 93 | + relationship_types : Optional[List[str]], default=None |
| 94 | + Relationship types to include in the computation |
| 95 | + sudo : Optional[bool], default=False |
| 96 | + Run with elevated privileges |
| 97 | + triangle_count_property : Optional[str], default=None |
| 98 | + Property name for pre-computed triangle counts |
| 99 | + username : Optional[str], default=None |
| 100 | + Username for authentication |
| 101 | +
|
| 102 | + Returns |
| 103 | + ------- |
| 104 | + LocalClusteringCoefficientStatsResult |
| 105 | + Result containing clustering coefficient statistics and timing information |
| 106 | + """ |
| 107 | + pass |
| 108 | + |
| 109 | + @abstractmethod |
| 110 | + def stream( |
| 111 | + self, |
| 112 | + G: GraphV2, |
| 113 | + *, |
| 114 | + concurrency: Optional[int] = None, |
| 115 | + job_id: Optional[str] = None, |
| 116 | + log_progress: bool = True, |
| 117 | + node_labels: Optional[List[str]] = None, |
| 118 | + relationship_types: Optional[List[str]] = None, |
| 119 | + sudo: Optional[bool] = False, |
| 120 | + triangle_count_property: Optional[str] = None, |
| 121 | + username: Optional[str] = None, |
| 122 | + ) -> pd.DataFrame: |
| 123 | + """ |
| 124 | + Executes the LocalClusteringCoefficient algorithm and streams results. |
| 125 | +
|
| 126 | + Parameters |
| 127 | + ---------- |
| 128 | + G : GraphV2 |
| 129 | + The graph on which to run the algorithm |
| 130 | + concurrency : Optional[int], default=None |
| 131 | + Number of concurrent threads |
| 132 | + job_id : Optional[str], default=None |
| 133 | + Job identifier for tracking |
| 134 | + log_progress : bool, default=True |
| 135 | + Whether to log progress |
| 136 | + node_labels : Optional[List[str]], default=None |
| 137 | + Node labels to include in the computation |
| 138 | + relationship_types : Optional[List[str]], default=None |
| 139 | + Relationship types to include in the computation |
| 140 | + sudo : Optional[bool], default=False |
| 141 | + Run with elevated privileges |
| 142 | + triangle_count_property : Optional[str], default=None |
| 143 | + Property name for pre-computed triangle counts |
| 144 | + username : Optional[str], default=None |
| 145 | + Username for authentication |
| 146 | +
|
| 147 | + Returns |
| 148 | + ------- |
| 149 | + pandas.DataFrame |
| 150 | + DataFrame containing nodeId and localClusteringCoefficient columns |
| 151 | + """ |
| 152 | + pass |
| 153 | + |
| 154 | + @abstractmethod |
| 155 | + def write( |
| 156 | + self, |
| 157 | + G: GraphV2, |
| 158 | + *, |
| 159 | + write_property: str, |
| 160 | + concurrency: Optional[int] = None, |
| 161 | + job_id: Optional[str] = None, |
| 162 | + log_progress: bool = True, |
| 163 | + node_labels: Optional[List[str]] = None, |
| 164 | + relationship_types: Optional[List[str]] = None, |
| 165 | + sudo: Optional[bool] = False, |
| 166 | + triangle_count_property: Optional[str] = None, |
| 167 | + username: Optional[str] = None, |
| 168 | + write_concurrency: Optional[int] = None, |
| 169 | + write_to_result_store: Optional[bool] = None, |
| 170 | + ) -> "LocalClusteringCoefficientWriteResult": |
| 171 | + """ |
| 172 | + Executes the LocalClusteringCoefficient algorithm and writes results to the database. |
| 173 | +
|
| 174 | + Parameters |
| 175 | + ---------- |
| 176 | + G : GraphV2 |
| 177 | + The graph on which to run the algorithm |
| 178 | + write_property : str |
| 179 | + Property name to store results in the database |
| 180 | + concurrency : Optional[int], default=None |
| 181 | + Number of concurrent threads |
| 182 | + job_id : Optional[str], default=None |
| 183 | + Job identifier for tracking |
| 184 | + log_progress : bool, default=True |
| 185 | + Whether to log progress |
| 186 | + node_labels : Optional[List[str]], default=None |
| 187 | + Node labels to include in the computation |
| 188 | + relationship_types : Optional[List[str]], default=None |
| 189 | + Relationship types to include in the computation |
| 190 | + sudo : Optional[bool], default=False |
| 191 | + Run with elevated privileges |
| 192 | + triangle_count_property : Optional[str], default=None |
| 193 | + Property name for pre-computed triangle counts |
| 194 | + username : Optional[str], default=None |
| 195 | + Username for authentication |
| 196 | + write_concurrency : Optional[int], default=None |
| 197 | + Concurrency for writing back to the database |
| 198 | + write_to_result_store : Optional[bool], default=None |
| 199 | + Whether to write to the result store |
| 200 | +
|
| 201 | + Returns |
| 202 | + ------- |
| 203 | + LocalClusteringCoefficientWriteResult |
| 204 | + Result containing clustering coefficient statistics and timing information |
| 205 | + """ |
| 206 | + pass |
| 207 | + |
| 208 | + @abstractmethod |
| 209 | + def estimate( |
| 210 | + self, |
| 211 | + G: GraphV2, |
| 212 | + *, |
| 213 | + concurrency: Optional[int] = None, |
| 214 | + job_id: Optional[str] = None, |
| 215 | + log_progress: bool = True, |
| 216 | + node_labels: Optional[List[str]] = None, |
| 217 | + relationship_types: Optional[List[str]] = None, |
| 218 | + sudo: Optional[bool] = False, |
| 219 | + triangle_count_property: Optional[str] = None, |
| 220 | + username: Optional[str] = None, |
| 221 | + ) -> EstimationResult: |
| 222 | + """ |
| 223 | + Estimates the LocalClusteringCoefficient algorithm memory requirements. |
| 224 | +
|
| 225 | + Parameters |
| 226 | + ---------- |
| 227 | + G : GraphV2 |
| 228 | + The graph on which to run the algorithm |
| 229 | + concurrency : Optional[int], default=None |
| 230 | + Number of concurrent threads |
| 231 | + job_id : Optional[str], default=None |
| 232 | + Job identifier for tracking |
| 233 | + log_progress : bool, default=True |
| 234 | + Whether to log progress |
| 235 | + node_labels : Optional[List[str]], default=None |
| 236 | + Node labels to include in the computation |
| 237 | + relationship_types : Optional[List[str]], default=None |
| 238 | + Relationship types to include in the computation |
| 239 | + sudo : Optional[bool], default=False |
| 240 | + Run with elevated privileges |
| 241 | + triangle_count_property : Optional[str], default=None |
| 242 | + Property name for pre-computed triangle counts |
| 243 | + username : Optional[str], default=None |
| 244 | + Username for authentication |
| 245 | +
|
| 246 | + Returns |
| 247 | + ------- |
| 248 | + EstimationResult |
| 249 | + Memory estimation details |
| 250 | + """ |
| 251 | + pass |
| 252 | + |
| 253 | + |
| 254 | +class LocalClusteringCoefficientMutateResult(BaseResult): |
| 255 | + pre_processing_millis: int |
| 256 | + compute_millis: int |
| 257 | + post_processing_millis: int |
| 258 | + mutate_millis: int |
| 259 | + node_count: int |
| 260 | + node_properties_written: int |
| 261 | + average_clustering_coefficient: float |
| 262 | + configuration: Dict[str, Any] |
| 263 | + |
| 264 | + |
| 265 | +class LocalClusteringCoefficientStatsResult(BaseResult): |
| 266 | + pre_processing_millis: int |
| 267 | + compute_millis: int |
| 268 | + post_processing_millis: int |
| 269 | + node_count: int |
| 270 | + average_clustering_coefficient: float |
| 271 | + configuration: Dict[str, Any] |
| 272 | + |
| 273 | + |
| 274 | +class LocalClusteringCoefficientWriteResult(BaseResult): |
| 275 | + pre_processing_millis: int |
| 276 | + compute_millis: int |
| 277 | + post_processing_millis: int |
| 278 | + write_millis: int |
| 279 | + node_count: int |
| 280 | + node_properties_written: int |
| 281 | + average_clustering_coefficient: float |
| 282 | + configuration: Dict[str, Any] |
0 commit comments