Content deleted Content added
Fixed link |
Correction of the Step 3, also switched to a better example |
||
Line 129:
:{|class="wikitable" style="text-align:center"
|-
| 0
|-
|b1'||
|-
|
|-
|
|}
In the above case, no assignment can be made. Note that task 1 is done efficiently by both
To overcome this, we repeat the above procedure for all columns (i.e. '''the minimum element in each column is subtracted from all the elements in that column''') and then check if an assignment is possible.
Line 147:
'''All zeros in the matrix must be covered by marking as few rows and/or columns as possible.''' The following procedure is ''one way'' to accomplish this:
*First, assign as many tasks as possible. The assigned tasks are represented by starring a zero.
** We assign the first zero of Row 1. The second zero of Row 1 can't be assigned, because it is on the same line as the first zero.
** We assign the first zero of Row 2. The second zero of Row 2 can't be assigned.
** Zeros on Row 3 and Row 4 can't be assigned, because they are on the same line as the zero assigned on Row 1
We could end with another assignment if we choose another ordering of the rows and columns.
:{|class="wikitable" style="text-align:center"
|-
| 0
|-
|b1'||
|-
| 0 ||c2'||c3'||c4'
|-
|
|}
* Cover all columns having an assignment (columns 1 and 2).
:{|class="wikitable" style="text-align:center"
|- style="background: white"
|×
|-
|style="background:lightgrey"| 0*||style="background:lightgrey"|a2'|| 0 ||a4'
|style="background: white"|
|-
|style="background:lightgrey"|b1'||style="background:lightgrey"| 0*||b3'|| 0
|style="background: white"|
|-
|style="background:lightgrey"| 0 ||style="background:lightgrey"|c2'||c3'||c4'
|style="background: white"|
|-
|style="background:lightgrey"| 0 ||style="background:lightgrey"|d2'||d3'||d4'
|style="background: white"|
|}
* Find a non-covered zero and prime it. If the zero is on the same line as a starred zero, cover the corresponding line, and uncover the column of the starred zero.
**Here, the second zero of Row 1 is uncovered. Because there is another zero starred on Row 1, we cover Row 1 and uncover Column 1.
**Then, the second zero of Row 2 is uncovered. We cover Row 2 and uncover Column 2.
:{|class="wikitable" style="text-align:center"
|- style="background: white"
|
|- style="background:lightgrey"
| 0*||a2'|| 0'||a4'
|style="background: white"|×
|-
|b1'||style="background:lightgrey"| 0
|style="background: white"|
|-
|| 0 ||style="background:lightgrey"|c2'||c3'||c4'
|style="background: white"|
|-
|| 0 ||style="background:lightgrey"|d2'||d3'||d4'
|style="background: white"|
|}
:{|class="wikitable" style="text-align:center"
|- style="background: white"
|| || || || ||
|- style="background:lightgrey"
| 0*||a2'|| 0'||a4'
|style="background: white"|×
|- style="background:lightgrey"
|b1'||
|style="background: white"|×
|-
|
|style="background: white"|
|-
|| 0 ||d2'||d3'||d4'
|style="background: white"|
|}
* If a non-covered zero has no assigned zero on its row, perform the following steps :
** Step 1: Find a starred zero on the corresponding column. If there is one, go to Step 2, else, stop.
** Step 2: Find a primed zero on the corresponding row (there should always be one). Go to Step 1.
The zero on Row 3 is uncovered. We find on the path the first zero of Row 1, then the second zero of Row 1, then we are done.
:{|class="wikitable" style="text-align:center"
|- style="background: white"
|| || || || ||
|- style="background:lightgrey"
| <span style="color:red">0*</span> ||a2'|| <span style="color:red">0'</span> ||a4'
|style="background: white"|×
|- style="background:lightgrey"
|
|style="background: white"|×
|-
|| <span style="color:red">0'</span> ||c2'||c3'||c4'
|style="background: white"|
|-
|| 0 ||d2'||d3'||d4'
|style="background: white"|
|}
* For all zeros encountered during the path, star primed zeros and unstar starred zeros, remove all covered lines and primed zeros.
**As the path begins and ends by a primed zero when swapping starred zeros, we have assigned one more zero.
:{|class="wikitable" style="text-align:center"
|-
| 0 ||a2'|| 0*||a4'
|-
|b1'|| 0*||b3'|| 0
|-
|| 0*||c2'||c3'||c4'
|-
|| 0 ||d2'||d3'||d4'
|}
* Repeat the previous steps
** we cover columns 1, 2 and 3. The second zero on Row 2 is uncovered, so we cover Row 2 and uncover Column 2
:{|class="wikitable" style="text-align:center"
|- style="background: white"
||× || ||× || ||
|-
|style="background:lightgrey"| 0 ||a2'||style="background:lightgrey"| 0*||a4'
|style="background: white"|
|- style="background:lightgrey"
|b1'|| 0*||b3'|| 0'
|style="background: white"|×
|-
|style="background:lightgrey"| 0*||c2'||style="background:lightgrey"|c3'||c4'
|style="background: white"|
|-
|style="background:lightgrey"| 0 ||d2'||style="background:lightgrey"|d3'||d4'
|style="background: white"|
|}
All zeros are now covered with a minimal number of rows and columns.
The aforementioned detailed description is ''just one way'' to draw the minimum number of lines to cover all the 0s. Other methods work as well.
|