NovoNordisk.CriticalPath
2.1.2
See the version list below for details.
dotnet add package NovoNordisk.CriticalPath --version 2.1.2
NuGet\Install-Package NovoNordisk.CriticalPath -Version 2.1.2
<PackageReference Include="NovoNordisk.CriticalPath" Version="2.1.2" />
paket add NovoNordisk.CriticalPath --version 2.1.2
#r "nuget: NovoNordisk.CriticalPath, 2.1.2"
// Install NovoNordisk.CriticalPath as a Cake Addin #addin nuget:?package=NovoNordisk.CriticalPath&version=2.1.2 // Install NovoNordisk.CriticalPath as a Cake Tool #tool nuget:?package=NovoNordisk.CriticalPath&version=2.1.2
Critical Path Method
This is an implementation of the Critical Path Method.
Usage
Examples
See the 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:
// Create activities
var activityEnd = new Activity("Finish", 0);
var activityC = new Activity("C", 90, activityEnd);
var activityG = new Activity("G", 40, activityEnd);
var activityF = new Activity("F", 20, activityEnd);
var activityB = new Activity("B", 90, activityC);
var activityE = new Activity("E", 20, activityG, activityF);
var activityA = new Activity("A", 50, activityB);
var activityD = new Activity("D", 100, activityB, activityE);
var activityStart = new Activity("Start", 0, 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:
- Make sure the
CHANGELOG.md
is up to date in tha main branch. - In GitHub, create a new release.
- The tag version should be the same as the version in the
CHANGELOG.md
file, prefixed with a 'v'. For examplev1.2.3
. - 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.
- The tag version should be the same as the version in the
- 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:
- Build and test the solution
dotnet build
anddotnet test
- Package the nuget package with the right version:
dotnet pack NovoNordisk.CriticalPath -c Release /p:PackageVersion=x.y.z
References
Based on:
- https://www.workamajig.com/blog/critical-path-method
- https://stackoverflow.com/a/9774655/2787333
- https://stackoverflow.com/questions/2985317/critical-path-method-algorithm
- https://www.codeproject.com/Articles/25312/Critical-Path-Method-Implementation-in-C
- https://github.com/elerch/Critical-Path-Extension-Method-for-.NET
Product | Versions 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. 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 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. |
-
.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.