Cannot solve Hungarian Algorithm - algorithm
I'm trying to implementing a function to solve the hungarian algorithm and i think that there is something i have misunderstood about the algorithm.
For testing purposes i'm using this c++ code from google that is supposed to work.
But when i test this 14x11 matrix, it says that it is not possible to solve:
[ 0 0 0 0 0 0 0 0 0 0 0 ]
[ 53 207 256 207 231 348 348 348 231 244 244 ]
[ 240 33 67 33 56 133 133 133 56 33 33 ]
[ 460 107 200 107 122 324 324 324 122 33 33 ]
[ 167 340 396 340 422 567 567 567 422 442 442 ]
[ 167 367 307 367 433 336 336 336 433 158 158 ]
[ 160 20 37 20 31 70 70 70 31 22 22 ]
[ 200 307 393 307 222 364 364 364 222 286 286 ]
[ 33 153 152 153 228 252 252 252 228 78 78 ]
[ 93 140 185 140 58 118 118 118 58 44 44 ]
[ 0 7 22 7 19 58 58 58 19 0 0 ]
[ 67 153 241 153 128 297 297 297 128 39 39 ]
[ 73 253 389 253 253 539 539 539 253 36 36 ]
[ 173 267 270 267 322 352 352 352 322 231 231 ]
C++ code for creating the array: (in case someone wants to test it by using the C++ example i provided)
int r[14*11] ={0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 207, 256, 207, 231, 348, 348, 348, 231, 244, 244, 240, 33, 67, 33, 56, 133, 133, 133, 56, 33, 33, 460, 107, 200, 107, 122, 324, 324, 324, 122, 33, 33, 167, 340, 396, 340, 422, 567, 567, 567, 422, 442, 442, 167, 367, 307, 367, 433, 336, 336, 336, 433, 158, 158, 160, 20, 37, 20, 31, 70, 70, 70, 31, 22, 22, 200, 307, 393, 307, 222, 364, 364, 364, 222, 286, 286, 33, 153, 152, 153, 228, 252, 252, 252, 228, 78, 78, 93, 140, 185, 140, 58, 118, 118, 118, 58, 44, 44, 0, 7, 22, 7, 19, 58, 58, 58, 19, 0, 0, 67, 153, 241, 153, 128, 297, 297, 297, 128, 39, 39, 73, 253, 389, 253, 253, 539, 539, 539, 253, 36, 36, 173, 267, 270, 267, 322, 352, 352, 352, 322, 231, 231};
If I run my implementation to reduce the number of zeros (so they can get covered by the minimum number of lines- step 9 in wikihow's link provided at the top -) I get the following matrix where i have to find the 0 combination unique for row and column.
The problem is that it is impossible to solve since the columns 10 and 11 (the ones bold) only have one 0 each one and it is in the same row.
Row 1 : [ 240 140 225 140 206 339 339 339 206 215 215 0 0 0 ]
Row 2 : [ 254 0 37 0 43 58 58 58 43 38 38 67 67 67 ]
Row 3 : [ 0 107 158 107 151 206 206 206 151 182 182 0 0 0 ]
Row 4 : [ 0 253 245 253 304 235 235 235 304 402 402 220 220 220 ]
Row 5 : [ 300 27 56 27 11 0 0 0 11 0 0 227 227 227 ]
Row 6 : [ 300 0 145 0 0 230 230 230 0 284 284 227 227 227 ]
Row 7 : [ 80 120 188 120 176 269 269 269 176 193 193 0 0 0 ]
Row 8 : [ 207 0 0 0 151 143 143 143 151 96 96 167 167 167 ]
Row 9 : [ 229 9 95 9 0 110 110 110 0 159 159 22 22 22 ]
Row 10 : [ 147 0 40 0 148 221 221 221 148 171 171 0 0 0 ]
Row 11 : [ 240 133 203 133 187 282 282 282 187 215 215 0 0 0 ]
Row 12 : [ 189 3 0 3 94 58 58 58 94 192 192 16 16 16 ]
Row 13 : [ 367 87 36 87 153 0 0 0 153 379 379 200 200 200 ]
Row 14 : [ 194 0 82 0 11 115 115 115 11 112 112 127 127 127 ]
Is there any kind of limitation with this method? Or is just me, making a bad implementation of the algorithm? In this case, why "is the supposed to work" example not working either?
Any suggestion would be appreciate, or if you know any trick or suggestion to help finding the minimum number of lines to cover zeros, please let me know.
Thanks in advance,
Is there any kind of limitation with this method?
Yes. That line drawing method will only properly work if you have made the maximum number of assignments at each step. I don't particularly feel like working this out by hand to prove it, but I assume that the code you are using does not accomplish that for this particular matrix. I decided to work it out (aka procrastinate) as best as I can figure from the lack of documentation, and it doesn't actually have a problem with covering all zeroes with the minimum number of lines. It's just bad at making assignments.
Every implementation of the Hungarian Algorithm I have found online will not work. They unfortunately all copy each other without actually learning the math behind it, and thus they all get it wrong. I have implemented something similar to what Munkres describes in his article "Algorithms for the Assignment and Transportation Problems", published in 1957. My code gives the results: (0,1), (1,3), (2,8), (3,2), (9,12), (10,11), (4,9), (8,7), (5,10), (6,6), (7,0) for a minimum cost of 828.
You can view my code here: http://www.mediafire.com/view/1yss74lxb7kro2p/APS.h
ps: Thanks for providing that C++ array. I wasn't looking forward to typing it myself.
pps: Here's your matrix, properly spaced:
0 0 0 0 0 0 0 0 0 0 0
53 207 256 207 231 348 348 348 231 244 244
240 33 67 33 56 133 133 133 56 33 33
460 107 200 107 122 324 324 324 122 33 33
167 340 396 340 422 567 567 567 422 442 442
167 367 307 367 433 336 336 336 433 158 158
160 20 37 20 31 70 70 70 31 22 22
200 307 393 307 222 364 364 364 222 286 286
33 153 152 153 228 252 252 252 228 78 78
93 140 185 140 58 118 118 118 58 44 44
0 7 22 7 19 58 58 58 19 0 0
67 153 241 153 128 297 297 297 128 39 39
73 253 389 253 253 539 539 539 253 36 36
173 267 270 267 322 352 352 352 322 231 231
Note in the link you provide section (2) that you add dummy rows or columns to make sure the matrix is square.
Now that you have a square matrix, there are a large number of different matchings which link together each row with its own column and vice versa. The solution, or solutions, is simply one of these matchings that has the lowest possible cost, so there should always be a solution.
Related
Create a file according to sort contend
I have a list of more than 100000 records. per example the values from 21 to 84 are continuous, then it will be 21-84 but if it is not continuous as the case 84 87, then it need to be 84,87 separated by , at beginning of each line will be the value 11111. The values from the list will be in the column range of 21 to 80 with, at last. The length of each row need to be maximum 80. here is the input file. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 87 85 86 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 108 111 109 112 110 113 115 114 117 116 118 124 125 120 122 123 126 132 127 133 128 130 131 135 136 137 138 139 140 141 142 143 144 145 146 148 147 149 150 151 152 153 154 155 156 158 157 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 184 183 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 214 here in the output file desired. 111111 21-84,87,85-86,88-106,108,111,109,112,110,113,115,114,117, 111111 116,118,124-125,120,122-123,126,132,127,133,128,130-131, 111111 135-146,148,147,149-156,158,157,159-182,184,183,185-212,214, thanks in advance
Presented without explanation: check the man pages for the commands used and come back with questions: awk ' function printrange() { print start (start == last ? "" : "-" last) } NR == 1 {start=last=$1; next} $1 == last+1 {last=$1; next} {printrange(); start=last=$1} END {printrange()} ' file | paste -sd" " | fold -sw 60 | tr ' ' ',' | sed 's/^/111111 /' 111111 21-84,87,85-86,88-106,108,111,109,112,110,113,115,114,117, 111111 116,118,124-125,120,122-123,126,132,127,133,128,130-131, 111111 135-146,148,147,149-156,158,157,159-182,184,183,185-212,214
Keep lines based on ratio between lines
I have a sort -g k9 command on a file that gives me this in the bash standard output: 55.19 645 156 15 9 520 58 702 0.0 661 55.50 636 159 16 9 520 58 693 0.0 654 55.19 645 156 15 9 520 58 702 0.0 658 56.52 644 147 16 9 520 59 701 0.0 669 55.97 645 151 15 9 520 65 709 0.0 672 55.97 645 151 15 9 520 65 709 4e-124 674 28.32 671 301 32 1 507 48 702 3e-49 183 28.32 671 301 32 1 507 47 701 3e-49 183 31.40 516 247 24 86 507 196 698 1e-46 176 31.41 519 243 25 86 507 196 698 5e-46 175 27.72 588 290 26 19 481 98 675 2e-39 154 30.56 337 170 17 101 413 302 598 5e-20 96.3 30.56 337 170 17 101 413 302 598 8e-20 95.5 I would like to cut my data based on the 9th column. The idea would be to compare the value of the 9th column on line i, divide it by the value of the 9th column on line i+1, and if the ratio is 0 OR 0/0 OR > 1e-50, line i and i+1 are kept. As soon as one of these conditions is not filled, stop reading. The desired output would be: 55.19 645 156 15 9 520 58 702 0.0 661 55.50 636 159 16 9 520 58 693 0.0 654 55.19 645 156 15 9 520 58 702 0.0 658 56.52 644 147 16 9 520 59 701 0.0 669 55.97 645 151 15 9 520 65 709 0.0 672 55.97 645 151 15 9 520 65 709 4e-124 674 I can obtain this output with head -n 6 but this is obviously not based on the condition on values in the 9th column. Please note that the values are in 'scientific' format. I know how to do this in Python (write the standard output to a file, calculate ratios, etc.) but for commodity reasons I'd prefer a shell-based solution (with awk or sort for instance) although I don't know if that's possible. Thanks for your help!
Just exit the script when the condition is not accomplished; otherwise, print the previous line and store the 9th field to compare on the next loop: $ awk '($9 && prev/$9>1e-50) {exit} {print stored; prev=$9; stored=$0}' file 55.19 645 156 15 9 520 58 702 0.0 661 55.50 636 159 16 9 520 58 693 0.0 654 55.19 645 156 15 9 520 58 702 0.0 658 56.52 644 147 16 9 520 59 701 0.0 669 55.97 645 151 15 9 520 65 709 0.0 672 55.97 645 151 15 9 520 65 709 4e-124 674
How to extract Photoshop curve points to RGB number array?
Hi I made some filter effects using Photoshop curves and they look like this: Is there a way I can extract each one of the 256 numbers from each color so it is a number array like this? var r = [0, 0, 0, 1, 1, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 17, 18, 19, 19, 20, 21, 22, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 44, 45, 47, 48, 49, 52, 54, 55, 57, 59, 60, 62, 65, 67, 69, 70, 72, 74, 77, 79, 81, 83, 86, 88, 90, 92, 94, 97, 99, 101, 103, 107, 109, 111, 112, 116, 118, 120, 124, 126, 127, 129, 133, 135, 136, 140, 142, 143, 145, 149, 150, 152, 155, 157, 159, 162, 163, 165, 167, 170, 171, 173, 176, 177, 178, 180, 183, 184, 185, 188, 189, 190, 192, 194, 195, 196, 198, 200, 201, 202, 203, 204, 206, 207, 208, 209, 211, 212, 213, 214, 215, 216, 218, 219, 219, 220, 221, 222, 223, 224, 225, 226, 227, 227, 228, 229, 229, 230, 231, 232, 232, 233, 234, 234, 235, 236, 236, 237, 238, 238, 239, 239, 240, 241, 241, 242, 242, 243, 244, 244, 245, 245, 245, 246, 247, 247, 248, 248, 249, 249, 249, 250, 251, 251, 252, 252, 252, 253, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] Sorry for the question if it's stupid, i'm not even sure what i'm asking, it's late. UPDATE: following Mark Setchell's answer, i was able to create a saved.ppm file with these values inside it. The last step was to extract the RGB values from this long string of numbers, Red is the 0th, 3nd, 6th number, Green is the 1st, 4th, 7th number etc. For anyone else's interest, I was trying to create a filter on Photoshop curves, then extract its RGB values and apply it using pixel cross processing on HTML Canvas, similar to a demo shown here.
Here is a totally different, and simpler way of doing it. Save the data below in a file called ramp.ppm - it is a Portable Pixmap format from the NetPBM suite see Wikipedia here. It is a black-to-white greyscale ramp 256 pixels wide and 1 pixel tall. Load that into Photoshop and apply your curve to it then save as a PNG file. P3 256 1 255 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 7 7 7 8 8 8 9 9 9 10 10 10 11 11 11 12 12 12 13 13 13 14 14 14 15 15 15 16 16 16 17 17 17 18 18 18 19 19 19 20 20 20 21 21 21 22 22 22 23 23 23 24 24 24 25 25 25 26 26 26 27 27 27 28 28 28 29 29 29 30 30 30 31 31 31 32 32 32 33 33 33 34 34 34 35 35 35 36 36 36 37 37 37 38 38 38 39 39 39 40 40 40 41 41 41 42 42 42 43 43 43 44 44 44 45 45 45 46 46 46 47 47 47 48 48 48 49 49 49 50 50 50 51 51 51 52 52 52 53 53 53 54 54 54 55 55 55 56 56 56 57 57 57 58 58 58 59 59 59 60 60 60 61 61 61 62 62 62 63 63 63 64 64 64 65 65 65 66 66 66 67 67 67 68 68 68 69 69 69 70 70 70 71 71 71 72 72 72 73 73 73 74 74 74 75 75 75 76 76 76 77 77 77 78 78 78 79 79 79 80 80 80 81 81 81 82 82 82 83 83 83 84 84 84 85 85 85 86 86 86 87 87 87 88 88 88 89 89 89 90 90 90 91 91 91 92 92 92 93 93 93 94 94 94 95 95 95 96 96 96 97 97 97 98 98 98 99 99 99 100 100 100 101 101 101 102 102 102 103 103 103 104 104 104 105 105 105 106 106 106 107 107 107 108 108 108 109 109 109 110 110 110 111 111 111 112 112 112 113 113 113 114 114 114 115 115 115 116 116 116 117 117 117 118 118 118 119 119 119 120 120 120 121 121 121 122 122 122 123 123 123 124 124 124 125 125 125 126 126 126 127 127 127 128 128 128 129 129 129 130 130 130 131 131 131 132 132 132 133 133 133 134 134 134 135 135 135 136 136 136 137 137 137 138 138 138 139 139 139 140 140 140 141 141 141 142 142 142 143 143 143 144 144 144 145 145 145 146 146 146 147 147 147 148 148 148 149 149 149 150 150 150 151 151 151 152 152 152 153 153 153 154 154 154 155 155 155 156 156 156 157 157 157 158 158 158 159 159 159 160 160 160 161 161 161 162 162 162 163 163 163 164 164 164 165 165 165 166 166 166 167 167 167 168 168 168 169 169 169 170 170 170 171 171 171 172 172 172 173 173 173 174 174 174 175 175 175 176 176 176 177 177 177 178 178 178 179 179 179 180 180 180 181 181 181 182 182 182 183 183 183 184 184 184 185 185 185 186 186 186 187 187 187 188 188 188 189 189 189 190 190 190 191 191 191 192 192 192 193 193 193 194 194 194 195 195 195 196 196 196 197 197 197 198 198 198 199 199 199 200 200 200 201 201 201 202 202 202 203 203 203 204 204 204 205 205 205 206 206 206 207 207 207 208 208 208 209 209 209 210 210 210 211 211 211 212 212 212 213 213 213 214 214 214 215 215 215 216 216 216 217 217 217 218 218 218 219 219 219 220 220 220 221 221 221 222 222 222 223 223 223 224 224 224 225 225 225 226 226 226 227 227 227 228 228 228 229 229 229 230 230 230 231 231 231 232 232 232 233 233 233 234 234 234 235 235 235 236 236 236 237 237 237 238 238 238 239 239 239 240 240 240 241 241 241 242 242 242 243 243 243 244 244 244 245 245 245 246 246 246 247 247 247 248 248 248 249 249 249 250 250 250 251 251 251 252 252 252 253 253 253 254 254 254 255 255 255 If you have Linux, and you have ImageMagick, you can then convert the saved PNG file back into a PPM file with convert saved.png -compress none saved.ppm The file saved.ppm will then show you the output of your curve for each input value in the greyscale ramp - in effect it will be the 256 values you are looking for. If you don't have ImageMagick, just give me the PNG file and I'll convert it for you.
I don't feel like writing the code today, least of all when you are not too sure what you are up to! However, what you are asking is perfectly achievable. If you save the curve you have created (the Save option is in the top right menu), you will get a .ACV file. The format of this file is given here if you scroll down to the section entitled Curves. It is a pretty simple format with just an identifier and a version number then a count of the number of points that you have defined for your curve, i.e. 6 in your case. Then, for each point, the 4 coordinates. These can be pretty easily extracted with Perl or similar. You could then fit a curve to those points, probably using GNUplot, and interpolate to find the points you are looking for. Excerpt from referenced document: Here is an extract from some code I wrote in Perl that actually writes a .ACV file. I know you will actually want to read one, bit you'll get the idea of the byte packing technique... #!/usr/bin/perl use strict; use warnings; use Image::Magick; use Data::Dumper; my $Debug=1; # 1=print debug messages, 0=don't my $NPOINTS=5; # Number of points in curve we create .... .... other stuff .... # Work out name of the curve file = image basename + acv my $curvefile=substr($imagename,0,rindex($imagename,'.')) . ".acv"; open(my $out,'>:raw',$curvefile) or die "Unable to open: $!"; print $out pack("s>",4); # Version=4 print $out pack("s>",4); # Number of curves in file = Master NULL curve + R + G + B print $out pack("s>",2); # Master NULL curve with 2 points for all channels print $out pack("s>",0 ),pack("s>",0 ); # 0 out, 0 in print $out pack("s>",255),pack("s>",255); # 255 out, 255 in print $out pack("s>",2+$NPOINTS); # Red curve print $out pack("s>",0 ),pack("s>",0 ); # 0 out, 0 in for($p=0;$p<$NPOINTS;$p++){ print $out pack("s>",$Rpoint[$p]),pack("s>",$greypoint[$p]); } print $out pack("s>",255),pack("s>",255); # 255 out, 255 in print $out pack("s>",2+$NPOINTS); # Green curve print $out pack("s>",0 ),pack("s>",0 ); # 0 out, 0 in for($p=0;$p<$NPOINTS;$p++){ print $out pack("s>",$Gpoint[$p]),pack("s>",$greypoint[$p]); } print $out pack("s>",255),pack("s>",255); # 255 out, 255 in print $out pack("s>",2+$NPOINTS); # Blue curve print $out pack("s>",0 ),pack("s>",0 ); # 0 out, 0 in for($p=0;$p<$NPOINTS;$p++){ print $out pack("s>",$Bpoint[$p]),pack("s>",$greypoint[$p]); } print $out pack("s>",255),pack("s>",255); # 255 out, 255 in close($out);
Parsing the wbxml get from Exchange2013 server
Below is a full section of bytes stream I got from Exchange2013 server after sending activesync command 'itemoperations' from iPhone. 31 139 8 0 0 0 0 0 4 0 237 189 7 96 28 73 150 37 38 47 109 202 123 127 74 245 74 215 224 116 161 8 128 96 19 36 216 144 64 16 236 193 136 205 230 146 236 29 105 71 35 41 171 42 129 202 101 86 101 93 102 22 64 204 237 157 188 247 222 123 239 189 247 222 123 239 189 247 186 59 157 78 39 247 223 255 63 92 102 100 1 108 246 206 74 218 201 158 33 128 170 200 31 63 126 124 31 63 34 126 237 95 243 167 127 141 95 227 183 58 253 226 215 222 253 53 126 205 23 207 248 199 175 241 155 255 196 175 125 255 119 191 151 61 220 167 127 240 247 111 245 123 253 26 191 249 119 127 237 54 127 215 222 93 149 89 177 196 71 207 127 237 215 95 61 124 253 229 79 31 191 251 226 233 233 15 126 234 167 143 175 190 248 233 183 87 95 60 61 198 255 119 190 124 243 19 59 47 62 255 226 7 191 207 155 159 250 233 23 139 223 231 222 139 167 211 221 23 63 248 226 250 167 126 250 247 217 161 191 247 126 234 233 239 115 255 197 226 171 189 159 250 233 239 44 94 252 244 23 244 115 122 253 226 167 207 246 190 120 67 127 63 125 187 67 237 174 95 44 78 247 94 188 249 125 126 240 226 7 63 177 75 144 232 253 179 123 47 126 154 127 18 220 47 222 125 177 248 234 7 218 159 254 255 212 251 221 252 127 26 126 255 6 248 30 95 253 212 27 243 25 193 249 193 219 31 124 241 211 223 41 191 248 193 233 15 8 151 125 134 251 70 254 254 242 233 23 215 95 60 125 50 255 125 246 126 159 61 250 219 194 122 241 148 218 253 128 218 253 244 23 192 237 7 47 8 159 23 63 125 122 77 227 218 37 24 10 231 39 8 206 23 87 244 61 189 251 157 183 47 126 250 43 140 135 218 31 83 59 124 126 76 99 195 223 103 123 47 208 15 141 235 139 31 224 221 51 130 71 125 124 206 116 217 121 241 131 175 238 125 241 131 87 229 139 207 127 31 162 171 224 255 133 197 95 255 14 199 255 238 133 163 129 155 31 249 158 254 254 170 67 163 83 31 30 254 255 217 175 241 107 226 249 127 0 225 220 243 27 28 2 0 0 I don't know why it is not normal and expect it sholud start like this: 3 1 106 0 0 20 69 77 3 49 0 1 78 70 77 3 49 0 1 0 17 81 3 82 103 65 65 65 65 65 117 50 72 120 85 112 65 .......... I think the response must have been encrypted, but what's the encryption algorithm? Will be very appreciated for any ideas.
I have got the answer, the stream 31 139 8 0 0 0 0 0 4 0 237 189 7 96 28 73 150 37 ...... has been compressed by Gzip
R compare all list elements for duplicates
I am looking at all possible paths through a graph. I have written a DFS algorithm that finds all these paths. I want to make sure that my algorithm works correctly and that no two paths are identical. My algorithm returns a list that looks as follows: .... [[2770]] [1] 1 2 3 52 53 54 55 56 57 58 59 60 12 11 10 9 8 78 79 80 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 [38] 130 131 132 133 134 137 138 139 140 141 142 143 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 [[2771]] [1] 1 2 3 52 53 54 55 56 57 58 59 60 12 11 10 9 8 78 79 80 113 114 115 143 144 145 146 147 148 149 150 151 152 153 154 155 156 [38] 157 158 159 160 161 162 163 164 165 166 [[2772]] [1] 1 2 3 52 53 54 55 56 57 58 59 60 12 11 10 9 8 78 79 80 113 114 115 143 150 151 152 153 154 155 156 157 158 159 160 161 162 [38] 163 164 165 166 As you can see, the list is 2772 elements long. This means there are 2,772 paths through this graph. How can I easily compare all the list elements to make sure there are no duplicates. Just to be clear, the same set of numbers but in a different ordering represents a different path and is not a duplicate! Thank you for your help!
maybe something like test<-list(1:2,3:4,5:7,1:10,3:4,4:3) dups<-duplicated(test) idups<-seq_along(test)[dups]