rusty-graph 0.3.3__cp38-cp38-manylinux_2_34_x86_64.whl → 0.3.4__cp38-cp38-manylinux_2_34_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of rusty-graph might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rusty_graph
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -25,6 +25,10 @@ A high-performance graph database library with Python bindings written in Rust.
25
25
  - [Working with Nodes](#working-with-nodes)
26
26
  - [Creating Connections](#creating-connections)
27
27
  - [Filtering and Querying](#filtering-and-querying)
28
+ - [Basic Filtering](#basic-filtering)
29
+ - [Filtering Orphan Nodes](#filtering-orphan-nodes)
30
+ - [Sorting Results](#sorting-results)
31
+ - [Limiting Results](#limiting-results)
28
32
  - [Traversing the Graph](#traversing-the-graph)
29
33
  - [Statistics and Calculations](#statistics-and-calculations)
30
34
  - [Saving and Loading](#saving-and-loading)
@@ -34,6 +38,8 @@ A high-performance graph database library with Python bindings written in Rust.
34
38
 
35
39
  ```bash
36
40
  pip install rusty-graph
41
+ # upgrade
42
+ pip install rusty-graph --upgrade
37
43
  ```
38
44
 
39
45
  ## Introduction
@@ -197,18 +203,83 @@ product_orphans = graph.type_filter('Product').filter_orphans(include_orphans=Tr
197
203
 
198
204
  ### Sorting Results
199
205
 
206
+ Rusty Graph offers flexible options for sorting nodes based on their properties. The `sort_spec` parameter can be used in various methods including `type_filter()`, `filter()`, `filter_orphans()`, `traverse()`, and the standalone `sort()` method.
207
+
208
+ #### Sort Specification Format Options
209
+
210
+ 1. **Single field string**: Sorts by the specified field in ascending order.
211
+ ```python
212
+ # Sort products by price (lowest to highest)
213
+ sorted_products = graph.type_filter('Product').sort('price')
214
+
215
+ # Can also be used in other methods
216
+ cheap_products = graph.type_filter('Product').filter(
217
+ {'stock': {'>': 10}},
218
+ sort_spec='price'
219
+ )
220
+ ```
221
+
222
+ 2. **Field with direction**: Explicitly specify ascending or descending order.
223
+ ```python
224
+ # Sort products by price (highest to lowest)
225
+ expensive_first = graph.type_filter('Product').sort('price', ascending=False)
226
+ ```
227
+
228
+ 3. **List of tuples**: For multi-field sorting with different directions.
229
+ ```python
230
+ # First sort by stock (descending), then by price (ascending)
231
+ # This prioritizes high-stock items, and for items with equal stock,
232
+ # shows the cheapest ones first
233
+ complex_sort = graph.type_filter('Product').sort([
234
+ ('stock', False), # False = descending order
235
+ ('price', True) # True = ascending order
236
+ ])
237
+ ```
238
+
239
+ 4. **Dictionary with field and direction**: Alternative format for single field sorting.
240
+ ```python
241
+ # Sort by rating in descending order
242
+ top_rated = graph.type_filter('Product').filter(
243
+ {},
244
+ sort_spec={'field': 'rating', 'ascending': False}
245
+ )
246
+ ```
247
+
248
+ #### Using Sort Specifications in Different Methods
249
+
250
+ Sort specifications work consistently across methods:
251
+
200
252
  ```python
201
- # Sort by a single field (ascending by default)
202
- sorted_products = graph.type_filter('Product').sort('price')
253
+ # In type_filter
254
+ latest_users = graph.type_filter('User', sort_spec='creation_date', max_nodes=10)
255
+
256
+ # In filter
257
+ new_expensive = graph.type_filter('Product').filter(
258
+ {'price': {'>': 500.0}},
259
+ sort_spec=[('creation_date', False), ('price', True)]
260
+ )
203
261
 
204
- # Sort explicitly by direction
205
- expensive_first = graph.type_filter('Product').sort('price', ascending=False)
262
+ # In traversal
263
+ alice_recent_purchases = graph.type_filter('User').filter({'name': 'Alice'}).traverse(
264
+ connection_type='PURCHASED',
265
+ sort_target='date',
266
+ max_nodes=5
267
+ )
206
268
 
207
- # Sort by multiple fields
208
- sorted_complex = graph.type_filter('Product').sort([
209
- ('stock', False), # Highest stock first
210
- ('price', True) # Then by price, lowest first
211
- ])
269
+ # In filter_orphans
270
+ recent_orphans = graph.filter_orphans(
271
+ include_orphans=True,
272
+ sort_spec='last_modified',
273
+ max_nodes=20
274
+ )
275
+
276
+ # In children_properties_to_list
277
+ expensive_products = graph.type_filter('User').traverse('PURCHASED').children_properties_to_list(
278
+ property='title',
279
+ sort_spec='price', # Sort children by price before creating the list
280
+ max_nodes=3,
281
+ store_as='top_expensive_purchases'
282
+ )
212
283
  ```
213
284
 
214
285
  ### Limiting Results
@@ -261,6 +332,7 @@ unique_categories = graph.type_filter('Product').unique_values(
261
332
  )
262
333
 
263
334
  # Convert children properties to a comma-separated list in parent nodes
335
+ # Option 1: Store results in parent nodes
264
336
  users_with_products = graph.type_filter('User').traverse('PURCHASED').children_properties_to_list(
265
337
  property='title', # Default is 'title' if not specified
266
338
  filter={'price': {'<': 500.0}}, # Optional filtering of children
@@ -270,6 +342,14 @@ users_with_products = graph.type_filter('User').traverse('PURCHASED').children_p
270
342
  max_length=100, # Optional maximum string length (adds "..." if truncated)
271
343
  keep_selection=False # Whether to keep the current selection
272
344
  )
345
+
346
+ # Option 2: Get results as a dictionary without storing them
347
+ product_names = graph.type_filter('User').traverse('PURCHASED').children_properties_to_list(
348
+ property='title',
349
+ sort_spec='price',
350
+ max_nodes=5
351
+ )
352
+ print(product_names) # Returns {'User1': 'Product1, Product2', 'User2': 'Product3, Product4, Product5'}
273
353
  ```
274
354
 
275
355
  ### Custom Calculations
@@ -0,0 +1,6 @@
1
+ rusty_graph-0.3.4.dist-info/METADATA,sha256=SjInsQ8P1QmylegHI2DtG2oNnU1JJWIOp1IPjCeBS84,12480
2
+ rusty_graph-0.3.4.dist-info/WHEEL,sha256=5jZZUTTSm-pSgQrllvuSF9QlGNhb3Pd0Yt1t5tnFNC0,106
3
+ rusty_graph-0.3.4.dist-info/licenses/LICENSE,sha256=rpMbqF0kOM1XAviOJRrR8UYQsNx0QPAzbf5b4RE358g,932
4
+ rusty_graph/__init__.py,sha256=_Fds04T5qV95XgyZm7qIPfLghgoCZi-_hDbw-e_18oA,127
5
+ rusty_graph/rusty_graph.cpython-38-x86_64-linux-gnu.so,sha256=jIcFQ8_p76QOlgou8OM9mBOEv5ruiW1Fs8c-p8OQnF0,1456528
6
+ rusty_graph-0.3.4.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- rusty_graph-0.3.3.dist-info/METADATA,sha256=Mw0MbC1NTH3MeR59NM8OfIQdfRngmfsngmcusuxTlm4,9739
2
- rusty_graph-0.3.3.dist-info/WHEEL,sha256=5jZZUTTSm-pSgQrllvuSF9QlGNhb3Pd0Yt1t5tnFNC0,106
3
- rusty_graph-0.3.3.dist-info/licenses/LICENSE,sha256=rpMbqF0kOM1XAviOJRrR8UYQsNx0QPAzbf5b4RE358g,932
4
- rusty_graph/__init__.py,sha256=_Fds04T5qV95XgyZm7qIPfLghgoCZi-_hDbw-e_18oA,127
5
- rusty_graph/rusty_graph.cpython-38-x86_64-linux-gnu.so,sha256=lphTnVCTGL0jY946g3Co8WIGMHYpoC3LWQ3AhCn0pLE,1447768
6
- rusty_graph-0.3.3.dist-info/RECORD,,