NovoNordisk.CriticalPath 2.1.4

dotnet add package NovoNordisk.CriticalPath --version 2.1.4
NuGet\Install-Package NovoNordisk.CriticalPath -Version 2.1.4
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="NovoNordisk.CriticalPath" Version="2.1.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NovoNordisk.CriticalPath --version 2.1.4
#r "nuget: NovoNordisk.CriticalPath, 2.1.4"
#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 NovoNordisk.CriticalPath as a Cake Addin
#addin nuget:?package=NovoNordisk.CriticalPath&version=2.1.4

// Install NovoNordisk.CriticalPath as a Cake Tool
#tool nuget:?package=NovoNordisk.CriticalPath&version=2.1.4

CI CD CodeQL License: MIT semver NuGet Downloads NuGet Version

Critical Path Method

This is an implementation of the Critical Path Method. The activities are treated as a graph, and is stored as a adjencency list graph. When determining the order of activities (and checking for cyclic dependencies), the activities are being topological sorted (using Kahn's algorithm).

Usage

Examples

See the NovoNordisk.CriticalPath.Console and the NovoNordisk.CriticalPath.Tests projects for working examples.

In general, create a HashSet of activities and use it as an argument to the Execute(...) function in the CriticalPathMethod.

Here is a simple example:

Diagram

// Create activities
var activityEnd = new Activity(name: "Finish", cost: 0);
var activityC = new Activity(name: "C", cost: 90, dependencies: activityEnd);
var activityG = new Activity(name: "G", cost: 40, dependencies: activityEnd);
var activityF = new Activity(name: "F", cost: 20, dependencies: activityEnd);
var activityB = new Activity(name: "B", cost: 90, dependencies: activityC);
var activityE = new Activity(name: "E", cost: 20, dependencies: [activityG, activityF]);
var activityA = new Activity(name: "A", cost: 50, dependencies: activityB);
var activityD = new Activity(name: "D", cost: 100, dependencies: [activityB, activityE]);
var activityStart = new Activity(name: "Start", cost: 0, dependencies: [activityA, activityD]);

// Add activities to HashSet
var activities = new HashSet<Activity>
{
    activityEnd, activityC, activityG, activityF, activityB,
    activityE, activityA, activityD, activityStart,
};

// Calculate critical path
var criticalPathMethod = new CriticalPathMethod();
var criticalPath = criticalPathMethod.Execute(activities);

// Print critical path and its total cost
Console.WriteLine("Critical Path: " + criticalPath.Select(_ => _.Name).Aggregate((a, b) => $"{a} -> {b}"));
Console.WriteLine("Critical Path Cost: " + criticalPath.Sum(_ => _.Cost));

// Output:
// Critical Path: Start -> D -> B -> C -> Finish                                       
// Critical Path Cost: 280    

Notes

Equal Critical Paths

If the graph contains two equal critical paths, and therefore both have a total float of 0, then the algorithm will return the first path in the given graph. It will not return both.

Two Paths That Does Not Intersect

If the graph contains two paths that does not intersect, then they'll both have a total float of 0. In that case the algorithm will return the first path in the given graph. It will not return both.

One could argue that it should return the one with the highest total cost, but this is not implemented. If this is the desired functionality then we should modify CriticalActivities() where the initial activity is found: initialActivities.First(_ => _.TotalFloat == 0);.

Free Float for the Final Task

We define this as 0. You could argue that it is infinite.

Map your own domain objects to activities

You can use the activity id property to keep a reference between your own domain objects and critical path activities.

var drinkCoffeeActivity = new Activity("Drink Coffee", myDrinkCoffeeObject.durationMs, cleanMugActivity);
{
    Id = myDrinkCoffeeObject.Id,
};

Another option could be to let your domain objects inherit the Activity class.

How to Contribute

Branching Strategy

Trunk based branching strategy is used. New features are added by creating feature branches that are then merged to main with a pull request. Pull requests requires the build pipeline to pass.

Versioning

The nuget package follows semver.org.

Release Procedure

These are the steps needed to create a new release:

  1. Make sure the CHANGELOG.mdis up to date in tha main branch.
  2. In GitHub, create a new release.
    1. The tag version should be the same as the version in the CHANGELOG.md file, prefixed with a 'v'. For example v1.2.3.
    2. The release title should be the version number. Fx 1.2.3. The release title is used as the version number in the nuget package.
  3. The release pipeline will now create a new nuget package and publish it to nuget.org.

To build and publish the nuget package manually, do the following:

  1. Build and test the solution dotnet build and dotnet test
  2. Package the nuget package with the right version: dotnet pack NovoNordisk.CriticalPath -c Release /p:PackageVersion=[SEMVER. Fx 1.2.3]

References

Based on:

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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. 
.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 is compatible. 
.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.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

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
2.1.4 640 2/7/2024
2.1.3 145 1/23/2024
2.1.2 78 1/19/2024
2.1.1 93 1/12/2024
2.1.0 84 1/12/2024
2.0.0 294 12/20/2023
0.0.1-beta.5 64 12/18/2023