进程多级调度算法图片
多阶段图问题 (Multistage graph problem)
The multistage graph problem is to find a minimum cost from a source to a sink.
多级图问题是找到从源到接收器的最低成本。
A multistage graph is a directed graph having a number of multiple stages, where stages element should be connected consecutively.
多级图是具有多个多级的有向图,其中级元素应连续连接。
In this multiple stage graph, there is a vertex whose in degree is 0 that is known as the source. And the vertex with only one out degree is 0 is known as the destination vertex.
在此多阶段图中,存在一个度为0的顶点(称为源)。 只有一个度数为0的顶点称为目标顶点。
The one end of the multiple stage graphs is at i thus the other reaching end is on i+1 stage.
多级图的一端在i上,因此另一端在i + 1级上。
If we denote a graph G = (V, E) in which the vertices are partitioned into K >= 2 disjoints sets, Vi, 1 <= I <=K. So that, if there is an edge < u, v > from u to v in E, the u £Vi and v € v (i+1), for some I, 1 <= i <= K. And sets V1 and Vk are such that |V1| = |Vk| = 1.
如果我们表示一个图G =(V,E) ,其中顶点被划分为K> = 2个不交集, Vi , 1 <= I <= K。 因此,如果在E中存在从u到v的边<u,v> ,则对于某些I , u£Vi和v€v(i + 1) , 1 <= i <= K。 集合V1和Vk使得| V1 | = | Vk | = 1 。
前向进近算法 (Algorithm for Forward Approach)
1. F graph (graph G, int K, int n, int p[])
2. {
3. Float cost [max size], int d [max size], r;
4. Cost [n] = 0.0
5. For (int j = n-1; j>= 1; j--)
6. {
7. Let r be a vertex such that
is an edge of G and C[j][r] + cost[r] is minimum;
8. Cost [j] = C[j][r] + Cost[r]
9. D [j] = r
10. }
11. P [1] = 1 , P[k] = n
12. For (j = 2 ; j <= K-1; j++)
13. P[j] = d[P(j-1)];
14. }
Input = input is a K stage graph G = (V, E) with n vertices indexed in order of stages.
输入=输入是K个阶段图G =(V,E),其中n个顶点按阶段顺序索引。
E is a set of an edge.
E是边的集合。
C [i][j] is the cost or weight of the edge [i][j]
C [i] [j]是边缘[i] [j]的成本或权重
后退算法 (Algorithm for Backward Approach)
1. Algorithm BGraph (G, K, n, p)
2. // some function as FGraph
3. {
4. B cost [1] = 0.0;
5. For j = 2 to n do
6. {
7. // compute b cost [j].
8. Let r be such that
is an edge of
9. G and b cost [r] + c [r, j];
10. D [j] = r;
11. }
12. // find a minimum cost path
13. P [1] = 1; p [k] = n;
14. For j = k-1 to 2 do p[j] = d [p (j+1)];
15. }
If we consider s as the vertex in V1 and t as the vertex in Vk. The vertex s is supposed as the source and vertex t as the sink. The cost of a path from s to t is the sum of the costs of the edges on the path.
如果我们将s视为V1中的顶点,将t视为Vk中的顶点。 假定顶点s为源,顶点t为宿。 从s到t的路径成本是路径上边缘成本的总和。
Here, each set Vi defines a stage in the graph. Each path starts from stage 1 goes to stage 2 then to stage 3 and so on, because of constraints on E.
在此,每个集合Vi定义图中的一个阶段。 由于对E的限制,每个路径都从阶段1开始进入阶段2,然后到达阶段3,依此类推。
![Multi stage graph](https://www.includehelp.com/algorithms/images/multi-stage-graph.jpg)
The minimum cost of s to t path is indicated by a dashed line. This method can be used for solving many problems such as allocating some resources to given number of projects with the intent to find the maximum profit.
s到t路径的最小成本用虚线表示。 此方法可用于解决许多问题,例如为找到最大的利润而将资源分配给给定数量的项目。
进程多级调度算法图片