Live Module
Live graph builder for incremental graph construction.
The Live builder queues changes (additions and removals) that can be applied
to a graph in batches via sync. This is useful for:
- Building graphs incrementally from streaming data
- Delaying expensive graph operations until necessary
- Tracking pending changes before commit
Comparison with LabeledBuilder
Aspect |
LiveBuilder |
LabeledBuilder |
|---|---|---|
Changes |
Queued/batched |
Immediate |
Sync required |
Yes |
No |
Remove operations |
Yes |
No |
Use case |
Streaming/mutable |
Static construction |
Example
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: |
|
Transition Types
AddNode: Create a new node with given ID and labelAddEdge: Create an edge between node IDsRemoveEdge: Remove an edge between node IDsRemoveNode: Remove a node and all its edges
<summary> Live graph builder for incremental graph construction. The Live builder queues changes (additions and removals) that can be applied to a graph in batches via `sync`. This is useful for: - Building graphs incrementally from streaming data - Delaying expensive graph operations until necessary - Tracking pending changes before commit ## Comparison with LabeledBuilder | Aspect | LiveBuilder | LabeledBuilder | |--------|-------------|----------------| | Changes | Queued/batched | Immediate | | Sync required | Yes | No | | Remove operations | Yes | No | | Use case | Streaming/mutable | Static construction | ## Example ```fsharp open Yog.Builder // Queue multiple changes let builder, graph = Live.create<string, int>() |> Live.addEdge "Alice" "Bob" 5 |> Live.addEdge "Bob" "Charlie" 3 |> Live.removeEdge "Alice" "Bob" |> Live.sync (Yog.Model.empty Directed) // graph now contains only Bob -> Charlie ``` ## Transition Types - `AddNode`: Create a new node with given ID and label - `AddEdge`: Create an edge between node IDs - `RemoveEdge`: Remove an edge between node IDs - `RemoveNode`: Remove a node and all its edges </summary>
<summary> Creates a new empty live builder. ## Example ```fsharp let builder = Live.create<string, int>() ``` </summary>
val string: value: 'T -> string
--------------------
type string = System.String
val int: value: 'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> = int
<summary> Queues an edge addition between two labels. Creates nodes automatically if they don't exist. ## Example ```fsharp let builder = Live.create<string, int>() |> Live.addEdge "A" "B" 10 ``` </summary>
<summary> Queues an edge removal. Silently ignored if either label doesn't exist. </summary>
<summary> Synchronizes pending changes to the provided graph. Returns the updated builder (with cleared queue) and the updated graph. ## Parameters - `builder`: The LiveBuilder with pending changes - `graph`: The target graph to apply changes to ## Returns Tuple of (builder with cleared pending, updated graph) ## Example ```fsharp let builder, updatedGraph = myBuilder |> Live.sync existingGraph ``` </summary>
<summary> Core graph data structures and basic operations for the yog library. This module defines the fundamental `Graph` type and provides all basic operations for creating and manipulating graphs. The graph uses an adjacency list representation with dual indexing (both outgoing and incoming edges) for efficient traversal in both directions. </summary>
<summary> Creates a new empty graph of the specified type. ## Example ```fsharp let graph = Model.empty Directed ``` </summary>
Functions and values
| Function or value |
Description
|
||
Full Usage:
addEdge fromLabel toLabel weight builder
Parameters:
'a
toLabel : 'a
weight : 'b
builder : LiveBuilder<'a, 'b>
Returns: LiveBuilder<'a, 'b>
|
Queues an edge addition between two labels. Creates nodes automatically if they don't exist.
Example
val builder: obj
Multiple items
val string: value: 'T -> string -------------------- type string = System.String Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int
|
||
Full Usage:
addSimpleEdge fromLabel toLabel builder
Parameters:
'a
toLabel : 'a
builder : LiveBuilder<'a, int>
Returns: LiveBuilder<'a, int>
|
Queues a simple edge with weight 1.
|
||
|
|||
|
Creates a new empty live builder.
Example
val builder: obj
Multiple items
val string: value: 'T -> string -------------------- type string = System.String Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int
|
||
Full Usage:
fromLabeled labeled
Parameters:
LabeledBuilder<'n, 'e>
Returns: LiveBuilder<'n, 'e>
|
Migrate from a static LabeledBuilder to a LiveBuilder. Preserves all labels and IDs but starts with an empty pending queue.
Example
val labeled: obj
Multiple items
val string: value: 'T -> string -------------------- type string = System.String Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int val live: obj
|
||
Full Usage:
getId label builder
Parameters:
'a
builder : LiveBuilder<'a, 'b>
Returns: NodeId option
|
Looks up the NodeId for a label.
|
||
|
|||
Full Usage:
purgePending builder
Parameters:
LiveBuilder<'a, 'b>
Returns: LiveBuilder<'a, 'b>
|
Discards all pending changes without applying them.
Example
val cleanBuilder: obj
|
||
Full Usage:
removeEdge fromLabel toLabel builder
Parameters:
'a
toLabel : 'a
builder : LiveBuilder<'a, 'b>
Returns: LiveBuilder<'a, 'b>
|
Queues an edge removal. Silently ignored if either label doesn't exist.
|
||
Full Usage:
removeNode label builder
Parameters:
'a
builder : LiveBuilder<'a, 'b>
Returns: LiveBuilder<'a, 'b>
|
Queues a node removal and removes it from the label registry. Silently ignored if the label doesn't exist.
|
||
Full Usage:
sync builder graph
Parameters:
LiveBuilder<'n, 'e>
graph : Graph<'n, 'e>
Returns: LiveBuilder<'n, 'e> * Graph<'n, 'e>
Tuple of (builder with cleared pending, updated graph) |
Synchronizes pending changes to the provided graph. Returns the updated builder (with cleared queue) and the updated graph.
Parameters
Example
val builder: obj
val updatedGraph: obj
|