Path
public class Path
This class generates paths and task attributes from a Graph object
-
A holder for all paths
Declaration
Swift
private var _allPaths: [[TaskNode]] -
A holder for all tasks in a path
Declaration
Swift
private var _paths: [TaskNode] -
A graph representing all tasks
Declaration
Swift
private var graph: Graph -
All generated paths. Task attributes (such as ES, EF, LS, LF, Slack, isOnCriticalPath) are not calculated
Declaration
Swift
public var paths: [[TaskNode]] { get } -
All critical paths. Task attributes are calculated
Declaration
Swift
public var criticalPaths: [Int : [[TaskNode]]] -
Number of paths in a graph
Declaration
Swift
public var count: Int { get } -
Initialize the Path with a graph
Declaration
Swift
public init(_ graph: Graph)Parameters
graphthe graph from which pathes are generated
-
Generate all paths and calculate all attributes
Declaration
Swift
public func generate()Return Value
Void
-
Generate paths from a graph.
_allPathsis updatedDeclaration
Swift
private func initialPathsGenerator()Return Value
Void
-
Remove a task in a collection of paths of tasks
Parameters
taskThe task to be removed
allPathsthe collection from which the task is removed
Return Value
the new collection without the task which is an array of paths of tasks.
-
Search the graph by using Depth-First Search Algorithm to find all paths
This method adds each path to
_allPathsarrayParameters
graphthe graph to be searched for paths
sourcethe starting point (TaskNode) of the search
Return Value
void
-
Calculate Early Start (ES), Early Finish (EF), Late Start (LS), Late Finish (LF), and Slack for tasks on critical paths
Declaration
Swift
private func calculateCPAttributes()Return Value
Void
-
This function calculates the total duration of each path
Declaration
Swift
private func getPathsWithDuration() -> Dictionary<Int, [[TaskNode]]>Return Value
A key-value pair. The key is the total duration and the value is any number of paths.
-
Calculate Early Start (ES), Early Finish (EF), Late Start (LS), Late Finish (LF), and Slack for tasks on none critical paths
Declaration
Swift
private func calculateNoneCPAttributes()Return Value
Void
-
A utility function to loop through all none critical paths.
labeledPathsproperty is updated.Declaration
Swift
private func calculateEarlyStartFinish(_ callback: (TaskNode) -> ())Parameters
callbacka callback function to handle how tasks’ ES and EF are calculated. It differs for tasks with one predecessor and tasks with more than one predecessor
Return Value
Void
-
A utility function to loop though all none critical paths in reverse order.
labeledPathsproperty is updated.Declaration
Swift
private func calculateLateStartFinish(_ callback: (TaskNode) -> ())Parameters
callbacka callback function to handle how tasks’ LS and LF are calculated. It differs for tasks with no successors and tasks with successors.
Return Value
void
View on GitHub
Path Class Reference