Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to assign each vertex a random number with the minimum bound equal to the smallest vertex and the maximum equal to the value of the largest without repeats.

For example, in a 20x20 grid, the vertices would be randomly labeled from 1 to 400 ,without repeats.

share|improve this question
It would be best if you post some code that you have tried so that readers can get a better idea of where your Mathematica problem is. – Jens Apr 9 '13 at 4:43

Here's one way to get random integers

Partition[RandomSample[Range[16]], 4]

This gets the first 16 integers in random order and formats them in a 4 by 4 block.

enter image description here

You can change the "16" to 400 and the "4" to 20 and get a larger matrix of such values.

share|improve this answer
Might be better to just use RandomSample[Range[16]] for the scrambling. – J. M. Apr 9 '13 at 4:59
JM - thanks for the improvement... – bill s Apr 9 '13 at 5:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.