You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/configuration.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ The `transforms` extra installs `networkx`, `rustworkx`, and `pandas`.
16
16
17
17
## Requirements
18
18
19
-
-**PostgreSQL**— required. django-postgresql-dag uses recursive CTEs (`WITH RECURSIVE`), which are PostgreSQL-specific. It is not compatible with SQLite, MySQL, or other databases.
19
+
-**PostgreSQL**- required. django-postgresql-dag uses recursive CTEs (`WITH RECURSIVE`), which are PostgreSQL-specific. It is not compatible with SQLite, MySQL, or other databases.
20
20
-**Supported primary key types**: `integer`, `bigint`, `uuid`. The query builders handle type casting automatically.
21
21
22
22
## Django settings
@@ -41,12 +41,12 @@ Creates an abstract base class for your Edge model.
41
41
| Parameter | Type | Default | Description |
42
42
|---|---|---|---|
43
43
|`node_model`|`str` or model class |*(required)*| The Node model this edge connects. Use a string name (e.g. `"MyNode"`) when the Node class hasn't been defined yet. |
44
-
|`concrete`|`bool`|`True`| If `True`, the factory returns a concrete model. If `False`, returns an abstract model — your subclass provides the database table. Almost always set to `False`. |
44
+
|`concrete`|`bool`|`True`| If `True`, the factory returns a concrete model. If `False`, returns an abstract model - your subclass provides the database table. Almost always set to `False`. |
45
45
|`base_model`| model class |`models.Model`| Base class for the generated model. Use this to inject a custom base (e.g. a TimeStampedModel). |
46
46
47
47
The generated model provides:
48
-
-`parent`— ForeignKey to the node model (the "from" side)
49
-
-`child`— ForeignKey to the node model (the "to" side)
48
+
-`parent`- ForeignKey to the node model (the "from" side)
49
+
-`child`- ForeignKey to the node model (the "to" side)
50
50
- Circular reference checking on save (unless disabled)
51
51
- Duplicate edge checking on save (unless disabled)
52
52
@@ -61,7 +61,7 @@ Creates an abstract base class for your Node model.
61
61
|`base_model`| model class |`models.Model`| Base class for the generated model. |
62
62
63
63
The generated model provides:
64
-
-`children`— ManyToManyField through the edge model
64
+
-`children`- ManyToManyField through the edge model
65
65
- All traversal, path, predicate, and mutation methods (see [Node API Reference](node-reference.md))
66
66
- Custom manager with `roots()`, `leaves()`, `topological_sort()`, and other graph-wide methods
Copy file name to clipboardExpand all lines: docs/edge-reference.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ These are called on `MyEdge.objects`.
22
22
: Returns a QuerySet of edges forming the shortest path from `start_node` to `end_node`. Accepts `directional` (default `True`).
23
23
24
24
**redundant_edges(self)**
25
-
: Returns a QuerySet of redundant edges — those removable by transitive reduction. An edge A→C is redundant if C is reachable from A via a path of length >= 2.
25
+
: Returns a QuerySet of redundant edges - those removable by transitive reduction. An edge A→C is redundant if C is reachable from A via a path of length >= 2.
26
26
27
27
**transitive_reduction(self, delete=False)**
28
28
: Identifies redundant edges. With `delete=True`, removes them and returns the count. See also `NodeManager.transitive_reduction()`.
Copy file name to clipboardExpand all lines: docs/filtering.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Filtering Graph Traversals
2
2
3
-
All traversal methods (`ancestors()`, `descendants()`, `clan()`, `path()`, `connected_graph()`, and their variants) accept filtering parameters that control which parts of the graph are explored. These filters operate at the CTE level — excluded edges are never traversed, not just hidden from results.
3
+
All traversal methods (`ancestors()`, `descendants()`, `clan()`, `path()`, `connected_graph()`, and their variants) accept filtering parameters that control which parts of the graph are explored. These filters operate at the CTE level - excluded edges are never traversed, not just hidden from results.
4
4
5
5
## Limiting depth with `max_depth`
6
6
@@ -70,7 +70,7 @@ Pass a queryset of edge instances to exclude from traversal. The CTE will skip t
Copy file name to clipboardExpand all lines: docs/node-reference.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ These are called on `MyNode.objects`.
16
16
: Returns a list of QuerySets, one per disconnected subgraph. Each QuerySet can be further filtered.
17
17
18
18
**graph_stats(self)**
19
-
: Returns a dict with aggregate metrics: `node_count`, `edge_count`, `root_count`, `leaf_count`, `island_count`, `max_depth`, `avg_depth`, `density`, `component_count`. Runs O(N) queries — suitable for analytics, not hot paths.
19
+
: Returns a dict with aggregate metrics: `node_count`, `edge_count`, `root_count`, `leaf_count`, `island_count`, `max_depth`, `avg_depth`, `density`, `component_count`. Runs O(N) queries - suitable for analytics, not hot paths.
20
20
21
21
**topological_sort(self, max_depth=None)**
22
22
: Returns a QuerySet of all nodes in topological order (parents before children). Island nodes are included at the front.
@@ -102,7 +102,7 @@ All traversal methods accept optional keyword arguments for [filtering](filterin
102
102
## Path Methods
103
103
104
104
**path(self, ending_node, \*\*kwargs)**
105
-
: Returns a QuerySet of the shortest path from self to `ending_node`. Sorted root-side toward leaf-side regardless of direction. Raises `NodeNotReachableException` if no path exists. Accepts `directional` (default `True`) — set to `False` to search in both directions.
105
+
: Returns a QuerySet of the shortest path from self to `ending_node`. Sorted root-side toward leaf-side regardless of direction. Raises `NodeNotReachableException` if no path exists. Accepts `directional` (default `True`) - set to `False` to search in both directions.
106
106
107
107
**path_exists(self, ending_node, \*\*kwargs)**
108
108
: Returns `True` if a path exists from self to `ending_node`. Accepts `directional`.
@@ -114,7 +114,7 @@ All traversal methods accept optional keyword arguments for [filtering](filterin
114
114
: Returns a list of QuerySets, each representing one path. Unlike `path()`, returns all paths, not just the shortest.
: Returns a `(QuerySet, total_weight)` tuple for the minimum-weight path. The edge model must have the specified weight field. Raises `NodeNotReachableException` or `WeightFieldDoesNotExistException`.
Copy file name to clipboardExpand all lines: docs/paths-and-algorithms.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Working with Paths and Algorithms
2
2
3
-
Beyond basic ancestor/descendant traversal, django-postgresql-dag provides several graph algorithms — all implemented as PostgreSQL recursive CTEs or using the NetworkX library.
3
+
Beyond basic ancestor/descendant traversal, django-postgresql-dag provides several graph algorithms - all implemented as PostgreSQL recursive CTEs or using the NetworkX library.
4
4
5
5
The examples on this page use the graph from the [Quickstart](quickstart.md):
6
6
@@ -62,7 +62,7 @@ For lightweight processing, `all_paths_as_pk_lists()` returns lists of primary k
62
62
[[1, 4, 7, 9], [1, 4, 8, 9]]
63
63
```
64
64
65
-
Use `max_results` to cap the number of paths returned — useful in dense graphs:
65
+
Use `max_results` to cap the number of paths returned - useful in dense graphs:
66
66
67
67
```python
68
68
>>> root.all_paths(c1, max_results=1)
@@ -120,7 +120,7 @@ At the instance level, get a node and its descendants in topological order:
120
120
121
121
## Critical path
122
122
123
-
The critical path is the longest weighted path from any root to any leaf in the DAG. This is useful for project scheduling — the critical path determines the minimum total duration.
123
+
The critical path is the longest weighted path from any root to any leaf in the DAG. This is useful for project scheduling - the critical path determines the minimum total duration.
Copy file name to clipboardExpand all lines: docs/transformations.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,14 +14,14 @@ This installs `networkx`, `rustworkx`, and `pandas`.
14
14
15
15
## Common parameters
16
16
17
-
All export functions accept a queryset of either nodes or edges. The queryset type is detected automatically — pass a nodes queryset and the corresponding edges are looked up, or vice versa.
17
+
All export functions accept a queryset of either nodes or edges. The queryset type is detected automatically - pass a nodes queryset and the corresponding edges are looked up, or vice versa.
18
18
19
19
These parameters are shared across `nx_from_queryset`, `rx_from_queryset`, and `json_from_queryset`:
20
20
21
-
-`node_attribute_fields_list`— field names to include as attributes on each node
22
-
-`edge_attribute_fields_list`— field names to include as attributes on each edge
23
-
-`date_strf`— strftime format string for date-like fields (e.g. `"%Y-%m-%d"`)
24
-
-`digraph`—`True` for a directed graph, `False` (default) for undirected
21
+
-`node_attribute_fields_list`- field names to include as attributes on each node
22
+
-`edge_attribute_fields_list`- field names to include as attributes on each edge
23
+
-`date_strf`- strftime format string for date-like fields (e.g. `"%Y-%m-%d"`)
24
+
-`digraph`-`True` for a directed graph, `False` (default) for undirected
25
25
26
26
## NetworkX export
27
27
@@ -158,11 +158,11 @@ True
158
158
159
159
The output follows the node-link JSON format with these top-level keys:
160
160
161
-
-`directed`— whether the graph is directed
162
-
-`multigraph`— whether the graph allows multiple edges
163
-
-`attrs`— graph-level attributes
164
-
-`nodes`— list of node objects, each with `id` (index) and `data` dict
165
-
-`links`— list of edge objects, each with `source`, `target`, `id`, and `data` dict
161
+
-`directed`- whether the graph is directed
162
+
-`multigraph`- whether the graph allows multiple edges
163
+
-`attrs`- graph-level attributes
164
+
-`nodes`- list of node objects, each with `id` (index) and `data` dict
165
+
-`links`- list of edge objects, each with `source`, `target`, `id`, and `data` dict
166
166
167
167
By default, `digraph=False` produces undirected output:
168
168
@@ -202,7 +202,7 @@ These functions use NetworkX's Weisfeiler-Lehman algorithm to compute structural
202
202
True
203
203
```
204
204
205
-
WL hashing is not collision-free — hash equality is necessary but not sufficient for true isomorphism.
205
+
WL hashing is not collision-free - hash equality is necessary but not sufficient for true isomorphism.
206
206
207
207
These functions also have node-level convenience methods that use lazy imports (so NetworkX isn't required at import time):
These functions are used internally by the export functions, but can be useful when working with querysets directly.
219
219
220
-
**`edges_from_nodes_queryset(nodes_queryset)`**— Given a queryset of nodes, returns a queryset of all edges where both parent and child are in the provided nodes.
220
+
**`edges_from_nodes_queryset(nodes_queryset)`**- Given a queryset of nodes, returns a queryset of all edges where both parent and child are in the provided nodes.
221
221
222
-
**`nodes_from_edges_queryset(edges_queryset)`**— Given a queryset of edges, returns a queryset of all nodes that appear as a parent or child in the provided edges.
222
+
**`nodes_from_edges_queryset(edges_queryset)`**- Given a queryset of edges, returns a queryset of all nodes that appear as a parent or child in the provided edges.
223
223
224
-
**`model_to_dict(instance, fields=None, date_strf=None)`**— Converts a model instance to a dictionary for the specified fields. Handles ForeignKeys, ManyToMany fields (with `__` subfield lookup), dates, UUIDs, file fields, and callable methods.
224
+
**`model_to_dict(instance, fields=None, date_strf=None)`**- Converts a model instance to a dictionary for the specified fields. Handles ForeignKeys, ManyToMany fields (with `__` subfield lookup), dates, UUIDs, file fields, and callable methods.
0 commit comments