Table of Contents

Class MemoryGraph

Namespace
CStructSharp.Memory
Assembly
CStructSharp.dll

Streaming breadth- or depth-first exploration with explicit identity and independently bounded work.

public static class MemoryGraph
Inheritance
MemoryGraph
Inherited Members

Methods

Run<TNode, TKey>(IEnumerable<TNode>, Func<TNode, TKey>, Func<TNode, int, MemoryAccessContext, MemoryGraphVisit>, Func<TNode, MemoryAccessContext, IEnumerable<TNode>>, MemoryAccessContext, bool, int, int, int, int)

Visits graph nodes in deterministic BFS or preorder DFS, preserving supplied root and edge order.

public static MemoryGraphResult Run<TNode, TKey>(IEnumerable<TNode> roots, Func<TNode, TKey> identity, Func<TNode, int, MemoryAccessContext, MemoryGraphVisit> visit, Func<TNode, MemoryAccessContext, IEnumerable<TNode>> edges, MemoryAccessContext context, bool breadthFirst = true, int maxNodes = 100000, int maxEdges = 1000000, int maxDepth = 64, int maxPending = 100000) where TKey : notnull

Parameters

roots IEnumerable<TNode>

Ordered initial nodes.

identity Func<TNode, TKey>

Canonical identity, preserving source/process/generation distinctions.

visit Func<TNode, int, MemoryAccessContext, MemoryGraphVisit>

Streams each distinct node and its zero-based depth. Stop preserves the caller's chosen first result.

edges Func<TNode, MemoryAccessContext, IEnumerable<TNode>>

Ordered outgoing nodes; the iterator is disposed on every stop.

context MemoryAccessContext

Shared CPU, callback, translation and read budget.

breadthFirst bool

True for BFS; false for preorder DFS.

maxNodes int

Maximum distinct visited identities.

maxEdges int

Maximum enumerated outgoing edges, counting duplicates and rejected-depth edges.

maxDepth int

Maximum included depth; roots have depth zero.

maxPending int

Maximum retained frontier, including supplied roots.

Returns

MemoryGraphResult

Explicit completion and work counts; partial findings remain owned by the caller.

Type Parameters

TNode

Application node and coordinate representation.

TKey

Explicit canonical identity.

Remarks

Canonical identity must include the source/process and generation when they matter. Duplicate edges still charge work. No results, sources or caches survive the operation. The visitor decides whether an unavailable branch is skipped; exceptions, cancellation and budget exhaustion always propagate. Depth-limited branches do not prevent visits to other branches.

Exceptions

ArgumentOutOfRangeException

A limit is invalid.

MemoryAccessException

The shared operation budget is exhausted.

OperationCanceledException

Cancellation was requested.