Data structure-6.6 figure

Preface-Data Structure

The data structure needs to be chewed repeatedly, and the answers to the problems encountered in the development can be obtained at any time.

Topological sort

  • Engineering drawing for student courses
    Insert picture description here

    • Select a vertex with an in-degree of 0 in the AOV network and output
    • Remove the vertex and all arcs from the vertex from the AOV network
    • Repeat steps 1 and 2 until all vertices have in degrees 0
    • In (b), we use a directed graph to represent the opening of courses. In this directed graph
      • The vertices represent activities,
      • Use arcs to indicate the priority of activities,
      • The directed graph is called Active On Vertices (AOV) network for short.
  • In the AOV network, the directed edge of <i,j> means that the activity should start with activity j first, that is, activity i must be completed before activity j can start, and i is the direct predecessor of j, and j is the direct successor of i This relationship between predecessor and successor is transitive. In addition, any activity i cannot use itself as its predecessor and successor. This is called anti-reflexivity. From the perspective of the transitivity and anti-reflexivity of the predecessor and successor, a directed loop (or called a directed loop) cannot appear in the AOV network. If a directed loop appears in the AOV network, it means that an activity should be As a prerequisite for yourself, this is wrong, the project will not be able to proceed, and for the program flow, there will be an endless loop.

  • Summary AOV

  • Vertex i has a predecessor and successor, and cannot be itself

  • There can be no loops in the network. To determine whether there are loops, it is to sort the topology of the network.

  • Example
    Insert picture description here
    Insert picture description here

Critical path (if weighted directed graph)

  • Description

  • The vertices represent events or project progress status,

  • An arc is used to represent the activity, and the weight on the arc represents the time required to complete the activity.
    Such a weighted directed graph is called AOE (Active On Edge Network) AOE, as shown below.
    Insert picture description here

  • Source point V1 in degree is 0

  • Meeting point V9 out of 0 is 0

  • The path is composed of directed edges that the source point passes through a series of vertices to reach the sink point

  • Key activities that are not completed on schedule are activities that the entire project cannot be completed on schedule

  • The critical path refers to the path formed by the edges connected by the key activities as the critical path. In
    books: the longest path from the source to the sink is called the critical path, and the activities on the critical path are called critical activities

  • specific description

  • AOE-Net. There are 9 events, v1, v2, v3,...v9. Each event indicates that the activity before it has been completed, and the activity after it can start. For example, v1 indicates the start of the entire project, v9 indicates the end of the entire project, v5 indicates that a4 and a5 have been completed, and a7 and a8 can start. The number associated with each activity is the time required to perform that activity. For example, activity a1 takes 6 days, a2 takes 4 days, etc. Since the entire project has only one starting point and one completion point, under normal conditions (without loops), there is only one point with zero manpower (called the source point) and one point with zero output (called sink). point).

The earliest occurrence time of the i-th event Ve[i]

  • And [j]
  • j = 0, Ve[j] = 0, is the source point
  • <i,j> Max{Ve[j] + dur(i,j)}, why is Max because of the earliest time when the event occurred? If the previous activity is not completed, then the event will not occur, so max is required
    such as I want Install the lamp and brush the wall for 5 days, install the lamp holder for 2 days, then I must wait for 5 days
    Insert picture description here
  • ve[j] represents the earliest time when the event vj can occur, and is the length of the longest path from the source point to the vertex vi. Obviously, the earliest occurrence time of event vj is also the earliest event represented by the arc starting from vj.
  • Example ps The entire project is at least 18 days
    Insert picture description here

The latest occurrence time of the i-th event Vl[i]

  • Vl (j)
  • Ve[n-1], if j = n-1 Vj is the meeting point, and no delay is allowed at this time
  • Min{Vl[k]-dur(j,k)} <vj,vk> is the arc in the network (seeking the latest occurrence time of j, then k is his successor, except for the meeting point, j has k, k (successor vertex) latest occurrence time minus dur(j,k))
    Insert picture description here
  • Example: (Why Min, because it is calculated by time point, that is, time. For example, if the successor of an event is to start on the 2nd day and the 10th day, then choose to start on the next day. In order to leave enough time for later events)
    Insert picture description here

The earliest start time e[k] of the i-th event ak

  • e[k] = Ve[i] ak is the activity on <i,j>, which is the earliest start time of the activity ak<i,j> = the earliest occurrence time of event i (precursor, earliest)
  • Example: Below a1<0,1> e[1] = Ve[0], pay attention to 0 and 0 (predecessor)
    Insert picture description here

The latest start time of the i-th event ak l[k]

  • l[k] = Vl[j]-dur(<i,j>) ak is the activity <i,j> which is the latest occurrence time of the successor Vl[j]-the time of the activity ak (successor, latest), If the previous event
  • Example: the following a1<0,1> l[1] = Vl[1]-dur(<0,1>), pay attention to a1<0,1> 1 and Vl[1] 1 (successor)
    Insert picture description here
  • Vl [8] = 18, Vl [7] = 14, Vl [6] = 16, Vl [5] = 10, Vl [4] = 7, Vl [3] = 8, Vl [3] = 6, Vl [1] = 6, Vl [0] = 0

Relaxation time

  • l[k]-e[k]> 0 If there is no slack time (l[k]-e[k] = 0), then activity k is the key activity, and the path connected by the key activity is called the critical path
  • If key activities are not completed on time, the entire construction period will be delayed
    Insert picture description here

Critical path

Insert picture description here

  • Summarize the critical path algorithm steps
  • Use topological sort to see if there are loops
  • Calculate the Ve[j] of each vertex
  • Calculate the Vl[j] of each vertex
  • Then calculate e[k] = Ve[j] l[k] = Vl[j]-dur(<i,j>), if e[k] = l[k], then it is the key activity, and the composition is the key path

Guess you like

Origin blog.csdn.net/weixin_41732253/article/details/109632805