Critical Path Method
An application to find the Critical Path of a project
Assumptions
- First line is the header.
- The input is comma separated.
- The input should be in the following format order:
TaskName,Duration,Predecessor
. - If there are more than one predecessor, separate them with a comma such as
B,2,C,D,E
. - If a task doesn't have any predecessors, it should be labeled NA.
Examples
Program Structure
There are 5 main classes to generate all the critical and none critical paths of a project. The classes are:
FileObject
class to parse a text file intoTaskNode
objects and generate aGraph
object.TaskNode
class represents a task.Edge
class represents connections betweenTaskNode
objects.Graph
class represents tasks and their relationships in a graph structure using a modified depth-first algorithm.Path
class generatesTaskNode
's properties such asearlyStart
,earlyFinish
,lateStart
,lateFinish
,slack
,isOnCriticalPath
.
To parse a text file follow these steps:
///1. `FileObject` to parse the input into `TaskNode` objects
let fileObject = FileObject("/Users/Tebin/Desktop/CPM/inputs/veryComplex.txt")
///2. `Graph` generated from `getGraph` method of `FileObject`
let graph = fileObject.getGraph()
///3. `Path` to generate all paths in a `Graph`
let path = Path(graph)
path.generate()
///4. View CPM for critical paths
view(path, for: .Critical)
///5. View CPM for none critical paths
view(path, for: .None)
///6. View the project summary
summary(path)