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
Check if a node is the root of the graph (i.e., has no parent) and return `true` or `false`.
77
+
Intended to be used within a rule or query.
78
+
79
+
## Arguments
80
+
- `c::Context`: The context associated to a node in a dynamic graph.
81
+
82
+
## Returns
83
+
`true` if the node is the root of the graph, otherwise `false`.
84
+
"""
42
85
isroot(c::Context) =!has_parent(c)
43
86
44
87
"""
@@ -311,6 +354,27 @@ function children(c::Context)
311
354
return out
312
355
end
313
356
357
+
358
+
359
+
"""
360
+
getdescendant(c::Context; condition = x -> true, max_level::Int = typemax(Int))
361
+
362
+
Returns the first descendant of a node that matches the `condition`. Intended to be used
363
+
within a rule or query.
364
+
365
+
## Arguments
366
+
- `c::Context`: Context associated to a node in a dynamic graph.
367
+
368
+
## Keywords
369
+
- `condition`: An user-defined function that takes a `Context` object as input and returns `true` or `false`.
370
+
- `max_level::Int`: Maximum number of steps that the algorithm may take when traversing the graph.
371
+
372
+
## Details
373
+
This function traverses the graph from the node associated to `c` towards the leaves of the graph until a node is found for which `condition` returns `true`. If no node meets the condition, then it will return `missing`.
374
+
375
+
## Returns
376
+
Return a `Context` object or `missing`.
377
+
"""
314
378
functiongetdescendant(c::Context; condition = x ->true, max_level::Int=typemax(Int))
0 commit comments