文章
149
粉丝
195
获赞
0
访问
19.0k
1)
顶点表节点结构
int vertex:顶点编号(V0~V7)
EdgeNode *firstEdge:指向第一条依附于该顶点的边(出边)
边表节点结构
int adjvex:该边指向的顶点编号
int taskId:任务编号
int duration:任务持续时间(天)
EdgeNode *next:指向下一条依附于同一顶点的边
V0 -> [V1, task1, 3] -> [V2, task2, 2] -> NULL
V1 -> [V3, task3, 4] -> [V4, task4, 1] -> NULL
V2 -> [V4, task5, 1] -> [V5, task6, 5] -> NULL
V3 -> [V6, task7, 2] -> NULL
V4 -> [V6, task8, 2] -> [V7, task9, 3] -> NULL
V5 -> [V7, task10, 3] -> NULL
V6 -> [V7, task11, 1] -> NULL
V7 -> NULL
2)
步骤 1:拓扑序列
这里顶点编号已经是拓扑序(V0→V1→V2→V3→V4→V5→V6→V7),因为 AOE 网是无环的且题中给出的依赖关系自然形成这个顺序。
步骤 2:计算最早发生时间 ve[j]
ve[0] = 0
ve[1] = ve[0] + 3 = 3
ve[2] = ve[0] + 2 = 2
ve[3] = ve[1] + 4 = 7
ve[4] = max(ve[1] + 1 = 4, ve[2] + 1 = 3) = 4
ve[5] = ve[2] + 5 = 7
ve[6] = max(ve[3] + 2 = 9, ve[4] + 2 = 6) = 9
ve[7] = max(ve[4] + 3 = 7, ve[5] + 3 = 10, ve[6] + 1 = 10...
登录后发布评论
暂无评论,来抢沙发