Graph

public class Graph : Equatable

Author

Tebin Raouf

The class to represent a graph

  • All the tasks in the graph

    Declaration

    Swift

    public var tasks: [TaskNode]
  • Initialize an empty graph

    tasks is empty

    Declaration

    Swift

    public init()
  • Add a task to the graph

    Declaration

    Swift

    public func addTask(_ task: TaskNode)

    Parameters

    task

    the task to be added

    Return Value

    void

  • Add a successor task to the current (source) task. This method adds an Edge between the two tasks.

    Declaration

    Swift

    public func addSuccessorEdge(_ source: TaskNode, neighbor: TaskNode)

    Parameters

    source

    the task in which a successor is added

    neighbor

    the successor task for the source task

    Return Value

    void

  • Add a predecessor task to the current (source) task. This method adds an Edge between the two tasks.

    Declaration

    Swift

    public func addPredecessorEdge(_ source: TaskNode?, neighbor: TaskNode?)

    Parameters

    source

    the task in which a predecessor is added

    neighbor

    the predecessor task for the source task

    Return Value

    void

  • Get a task object by its name

    Declaration

    Swift

    public func getTask(by name: String) -> TaskNode?

    Parameters

    name

    the name of the task

    Return Value

    a TaskNode object (if any)