GraphAhoi 0.0.3

dotnet add package GraphAhoi --version 0.0.3                
NuGet\Install-Package GraphAhoi -Version 0.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GraphAhoi" Version="0.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add GraphAhoi --version 0.0.3                
#r "nuget: GraphAhoi, 0.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install GraphAhoi as a Cake Addin
#addin nuget:?package=GraphAhoi&version=0.0.3

// Install GraphAhoi as a Cake Tool
#tool nuget:?package=GraphAhoi&version=0.0.3                

GraphAhoi

Graph library for tracing forward, backward, completely etc. using DFS or BFS. Optional delegates to control tracing of edges and nodes. Can adapt to existing graphs without changes.

Examples:

using GraphAhoi.Extensions;

namespace GraphAhoi.Example;

class SomeEdge
{
    public SomeNode From;
    public SomeNode To;
    public int EdgeData;
}

class SomeNode
{
    public List<SomeEdge> Inlinks;
    public List<SomeEdge> Outlinks;
    public int NodeData;
}

/// <summary>
/// Adapt to some node and edge that we don't have control over. 
/// If we had control, we could implement INode and IEdge, and then use GraphTracer directly.
/// But here we override 4 methods to adapt.
/// </summary>
class GraphTracerAdapter : GraphTracerBase<SomeNode, SomeEdge>
{
    public GraphTracerAdapter(GraphTracerAlgo algo) : base(algo)
    { }
    protected override SomeNode GetSourceNode(SomeEdge e) => e.From;
    protected override SomeNode GetTargetNode(SomeEdge e) => e.To;
    protected override IEnumerable<SomeEdge> GetInEdges(SomeNode n) => n.Inlinks;
    protected override IEnumerable<SomeEdge> GetOutEdges(SomeNode n) => n.Outlinks;
}

internal class RetrofitExample
{
    public void Example()
    {
        // All nodes in graph
        var graphNodes = GetGraphNodes();
        // Selection: one or more nodes from the graph
        var selection = new List<SomeNode>() { graphNodes[42], graphNodes[666] };

        // Create tracer-adapter and select algo
        var tracer = new GraphTracerAdapter(GraphTracerAlgo.BFS);

        // Trace the selection
        var trace1 = tracer.TraceCompletely(selection);
        var trace2 = tracer.TraceBackward(selection);
        var trace3 = tracer.TraceForward(selection);
        var trace4 = tracer.TraceBackwardAndForward(selection);

        // Control tracing with delegates
        var trace5 = tracer.TraceCompletely(selection, 
			shouldTraceEdge: (edg, _) => edg.EdgeData == 42,
			shouldTraceNode: (node, _) => node.NodeData == 42);
        var trac65 = tracer.TraceCompletely(selection,
			shouldTraceEdge: (edg, direction) => direction == Direction.Forward && edg.EdgeData == 42, 
			shouldTraceNode: (node, direction) => node.NodeData == 42 && direction == Direction.Backward);

        // Extension method
        var ordered = selection.TopologicalOrder(n => n.Inlinks.Select(f => f.From));
    }

    private List<SomeNode> GetGraphNodes()
    {
        throw new NotImplementedException();
    }

    public async Task ExampleAsync()
    {
        var nodes = new List<SomeNode>();
        // Extension method async
        var ordered = nodes.TopologicalOrderAsync(GetDepsAsync);
        await foreach (var o in ordered)
        {
            Console.WriteLine(o);
        }
    }

    private async IAsyncEnumerable<SomeNode> GetDepsAsync(SomeNode node)
    {
        foreach (var x in node.Inlinks.Select(f => f.From))
            yield return x;
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.3 172 3/3/2025
0.0.2 80 3/2/2025
0.0.1 80 3/2/2025