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
rootsIEnumerable<TNode>Ordered initial nodes.
identityFunc<TNode, TKey>Canonical identity, preserving source/process/generation distinctions.
visitFunc<TNode, int, MemoryAccessContext, MemoryGraphVisit>Streams each distinct node and its zero-based depth. Stop preserves the caller's chosen first result.
edgesFunc<TNode, MemoryAccessContext, IEnumerable<TNode>>Ordered outgoing nodes; the iterator is disposed on every stop.
contextMemoryAccessContextShared CPU, callback, translation and read budget.
breadthFirstboolTrue for BFS; false for preorder DFS.
maxNodesintMaximum distinct visited identities.
maxEdgesintMaximum enumerated outgoing edges, counting duplicates and rejected-depth edges.
maxDepthintMaximum included depth; roots have depth zero.
maxPendingintMaximum retained frontier, including supplied roots.
Returns
- MemoryGraphResult
Explicit completion and work counts; partial findings remain owned by the caller.
Type Parameters
TNodeApplication node and coordinate representation.
TKeyExplicit 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.