[Question]
  [
**The Task**
This is quite a simple coding task, all your program has to do is place a point on a canvas (or your alternative in another coding language) and connect it to all the dots already placed. Your program must take in one input, the number of dots that should be placed, and output some sort of display with the dots connected. [Example](https://www.dropbox.com/s/bdgyrxsrri2g6u1/CodeGolf.png)
**Requirements**
* I have to be able to run it, which means that it has to have a
compiler/tool to run it either online, or publicly available to
download.
* You are allowed to use any library created before this challenge was set, as long as it wasn't designed for the sole purpose of solving this.
* This is a shortest code task, which means characters. Comments, code that changes colour (for prettiness) and libraries will be ignored.
* Your answer must be unique, don't steal other peoples code, shorten it a few characters and repost it.
* It must be able to run in less than 5 minutes, for the values of 5 and 100. It must also use a resolution of at least 200\*200 and put each dot in a random location on the canvas using a non-trivial distribution.
**Current Leaderboard**
```
Flawr        - Matlab        - 22  - Confirmed
Falko        - Python 2      - 41  - Confirmed
Wyldstallyns - NetLogo       - 51  - Confirmed 
Ssdecontrol  - R             - 66  - Confirmed
9214         - Red           - 81  - Confirmed
David        - Mathematica   - 95  - Confirmed
Razetime     - Red           - 118 - Confirmed
ILoveQBasic  - QBasic        - 130 - Confirmed
Adriweb      - TI-Nspire Lua - 145 - Confirmed
Manatwork    - Bash          - 148 - Confirmed
Doorknob     - Python 2      - 158 - Confirmed
Kevin        - TCL           - 161 - Confirmed
M L          - HPPPL         - 231 - Confirmed
Manatwork    - HTML/JS       - 261 - Confirmed - Improved code of Scrblnrd3
Makando      - C#            - 278 - Confirmed
Scrblnrd3    - HTML/JS       - 281 - Confirmed
Geobits      - Java          - 282 - Confirmed
```
If I've missed you out, I'm very sorry, just add a comment to your work saying so and I'll add it as soon as I see it =)
**TL;DR**
* Input - Number of dots (int, can be hard coded)
* Output - Image of randomly placed dots, all connected to each other (graphic)
* Winner - Shortest code
  
[Answer]
# Java : ~~318 282~~ 265
Because, ya know, Java:
```
class M{public static void main(String[]a){new Frame(){public void paint(Graphics g){int i=0,j,d=640,n=25,x[]=new int[n],y[]=x.clone();for(setSize(d,d);i<n;i++)for(j=0,x[i]=(int)(random()*d),y[i]=(int)(random()*d);j<i;g.drawLine(x[i],y[i],x[j],y[j++]));}}.show();}}
```
Its just a simple loop that makes random dots and draws lines between the current dot and all previous ones.
Example with 25 dots:
![enter image description here](https://i.stack.imgur.com/3gcZv.png)
With line breaks and imports:
```
import java.awt.*;
import static java.lang.Math.*;
class M{
    public static void main(String[]a){
        new Frame(){
            public void paint(Graphics g){
                int i=0,j,d=640,n=25,x[]=new int[n],y[]=x.clone();
                for(setSize(d,d);i<n;i++)
                    for(j=0,x[i]=(int)(random()*d),y[i]=(int)(random()*d);
                        j<i;
                        g.drawLine(x[i],y[i],x[j],y[j++]));
            }
        }.show();
    }
}
```
Edit: Since we're not counting imports, I imported a couple more things to save some characters later.
Edit 2: OP added an allowance for hardcoding number of dots. -17 chars :)
[Answer]
# Matlab (22)
```
gplot(ones(n),rand(n))
```
It is assumend that n is the number of points, and it looks like this for n=10:
![random graph](https://i.stack.imgur.com/MC8yt.png)
`n=6`:
![random](https://i.stack.imgur.com/QKeoA.png)
### Explaination
`gplot` is a command for plotting graphs. The first argument is a `n x n` incidence matrix (full of ones, obviously). The second argument should be a `n x 2` matrix with the coordinates of the points, but it does not matter if the second dimension is bigger that 2, so I just generate an `n x n` matrix of random values (which is 2 characters shorter than generating an `n x 2` matrix).
## Links to documentation
* [gplot](http://www.mathworks.ch/ch/help/matlab/ref/gplot.html)
* [ones](http://www.mathworks.ch/ch/help/matlab/ref/ones.html)
* [rand](http://www.mathworks.ch/ch/help/matlab/ref/rand.html)
[Answer]
# Python 2 - ~~41~~ 35
After importing some libraries as allowed for this challenge
```
from pylab import rand as r
from pylab import plot as p
from itertools import product as x
from itertools import chain as c
```
we can plot some number of connected points with just one line of code:
```
X=r(5,2);p(*zip(*c(*list(x(X,X)))))
```
![](https://i.stack.imgur.com/FlJj1.png)
(The screenshot was generated with 10 points.)
[Answer]
# Mathematica ~~95~~ 87
With some help from belisarius.
```
CompleteGraph[n, VertexSize -> {2, 2},
VertexCoordinates -> Table[RandomInteger[{0, 199}, 2], {n}]]
```
**n=5**
![5](https://i.stack.imgur.com/92QAu.png)
---
**n=100**
Timing: 2.082654 sec
![100](https://i.stack.imgur.com/cVFjG.png)
[Answer]
# Python 2, 158
Import statements not included in character count, as noted in question ("libraries will be ignored").
```
from PIL import Image,ImageDraw
from random import randint
s=[(randint(0,200),randint(0,200))for _ in range(int(input()))]
i=Image.new('RGB',(200,200))
[ImageDraw.Draw(i).line((p,q),255)for p in s for q in s]
i.show()
```
Sample outputs:
n=2 (...):
![n=2](https://i.stack.imgur.com/QOIbk.png)
n=10 (looks like fancy 3d thing or something):
![n=10](https://i.stack.imgur.com/udYat.png)
n=100 (looks like someone went BLELEEEAARARGHHH with a red pen):
![n=100](https://i.stack.imgur.com/sI96I.png)
n=500, 1000, 10000 (runs in about 1.5 seconds, 5-6 seconds, and 3.5 minutes respectively):
![](https://i.stack.imgur.com/tSZWi.png)![](https://i.stack.imgur.com/hjDkV.png)![](https://i.stack.imgur.com/UPlf0.png)
Note: the 10000 points one was run with a slightly optimized version that changed line 3 (not including imports) to this:
```
d=ImageDraw.Draw
for p in s:
  for q in s:d.line((p,q),255)
```
Otherwise it would have taken forever. :P
Ungolfed:
```
from PIL import Image, ImageDraw
from random import randint
point_count = int(input())
image_size = 200
points = [(randint(0, image_size), randint(0, image_size)) for _ in range(point_count)]
image = Image.new('RGB', (200, 200))
draw = ImageDraw.Draw(image)
for start_point in points:
    for end_point in points:
        draw.line((start_point, end_point), 255)
image.show()
```
[Answer]
## R, 66
This one is borderline cheating but I still think it's within the rules. Set up by loading the `igraph` package with `library(igraph)`, which can be downloaded from CRAN with `install.packages("igraph")`. Then assign the input to variable `N`. As per the rules, these are not counted in the total.
```
G=graph.adjacency(matrix(1,N,N),"un")
plot(G,layout=layout.random)
```
### N = 50
![enter image description here](https://i.stack.imgur.com/sNyRb.png)
Note that this code also draws self-connections. Eliminating them (although there's no rule against them) adds 6 characters:
```
G=graph.adjacency(matrix(1,N,N),"un",diag=F)
plot(G,layout=layout.random)
```
## R, 141
This is an honest-to-goodness solution in base R:
```
p=replicate(2,runif(N))
g=as.matrix(expand.grid(1:N,1:N))
plot.new()
apply(g,1,function(i) segments(p[i[1],1],p[i[1],2],p[i[2],1],p[i[2],2]))
```
although you still have to enter `N` by hand.
### N = 50
![enter image description here](https://i.stack.imgur.com/GOFLU.png)
I'm wondering if a `for` loop would be fewer characters than `apply` but I'm happy with what I've got.
[Answer]
# QBasic or QuickBasic, 130 characters
```
SCREEN 1:RANDOMIZE:N=10:DIM X(100),Y(100):FOR I=1 TO N:X(I)=RND*320:Y(I)=RND*200:FOR J=1 TO I:LINE(X(I),Y(I))-(X(J),Y(J)):NEXT J,I
```
### Code variations
* If you do not want to be prompted for a seed, replace `RANDOMIZE` with `RANDOMIZE TIMER`.
* If you want to be prompted for N, replace `N=10` with `INPUT N` or `INPUT "N";N`.
### Sample runs
For `N=5`, tested with QBasic 1.1 running on DOSBox 0.74:
![](https://i.stack.imgur.com/jIeQC.png)
For `N=100`, tested with QBasic 1.1 running on DOSBox 0.74:
![](https://i.stack.imgur.com/7iUlz.png)
[Answer]
# Bash + ImageMagick: 148 characters
```
c=()
while((i++<$1)); do
p=$[RANDOM%200],$[RANDOM%200]
c+=($p)
for e in ${c[@]};do
d+="line $p $e"
done
done
convert -size 200x200 xc: -draw "$d" x:
```
Sample run:
```
bash-4.3$ time ./line.sh 5
real    0m5.256s
user    0m0.137s
sys     0m0.017s
```
Sample output:
![5 connected points](https://i.stack.imgur.com/AxQ82.png)
Sample run:
```
bash-4.3$ time ./line.sh 25
real    0m3.043s
user    0m0.574s
sys     0m0.023s
```
Sample output:
![25 connected points](https://i.stack.imgur.com/z8pwv.png)
Sample run:
```
bash-4.3$ time ./line.sh 100
real    0m5.662s
user    0m11.156s
sys     0m0.076s
```
Sample output:
![100 connected points](https://i.stack.imgur.com/KWhxA.png)
[Answer]
# TCL 161 chars
Clearly not going to win, but beats several others presented here, and I think it makes good use of a highly undervalued language.
```
for {set i 0} {$i<10} {incr i} {lappend l [expr rand()*291] [expr rand()*204]}
pack [canvas .c]
foreach {x y} $l {foreach {w z} $l {.c create line $x $y $w $z}}
```
![Example](https://i.stack.imgur.com/mNgI7.png)
The default canvas size on my system appears to be 291x204. Not sure why, but using it saves 13 characters.
Fairly fast, 400 points in < 5 seconds, 500 in ~10 s. Size and points can be scaled arbitrarily and colors and line styles can be altered, at the cost of characters of course. Un-golfed and using variables to make it clearer and easier to scale and color:
```
set n 20
set width 500
set height 500
set bg_color black
set line_color white
for {set i 0} {$i < $n} {incr i} {
        lappend points [expr rand() * $width] [expr rand() * $height]
}
canvas .c -width $width -height $height -background $bg_color 
pack .c
foreach {x1 y1} $points {
        foreach {x2 y2} $points {
                .c create line $x1 $y1 $x2 $y2 -fill $line_color
        }
}       
```
[Answer]
## [TI-Nspire] Lua - ~~145~~ ~~135~~ 130
(Updated fixed version)
![Screenshot with n=10](https://i.stack.imgur.com/QoVLS.png)
"Importing" math.random as "r", first, as allowed : `r=math.random`
Actual code :
```
function on.paint(g)t={}for b=1,2*n-1,2 do t[b]=r(318)t[b+1]=r(212)for c=1,b-1,2 do g:drawLine(t[b],t[b+1],t[c],t[c+1])end end end
```
Note : This code works on the TI-Nspire calculators *(TI added Lua scripting to recent OSes of this platform, with an even-based API allowing users to graph stuff etc. for example.)*
  
It can also be [tried online here](http://bwns.be/jim/WEBspire/editor.html) (just erase the demo script and prepend mine with `n=10` for example)
[Answer]
# [Red](http://www.red-lang.org), 118 bytes
```
a: collect[loop n[keep random d: 200x200]]
view[base d draw collect[foreach p a[foreach q a[keep reduce['line p q]]]]]
```
This was fun to figure out. Thanks to [Toomas Vooglaid](https://github.com/toomasv) on Gitter and 9214 for helping with this. `n` is hardcoded.
-1 byte from Bubbler.
-2 bytes from Galen Ivanov.
## Screenshots
[![enter image description here](https://i.stack.imgur.com/l3xdP.png)](https://i.stack.imgur.com/l3xdP.png)
[![enter image description here](https://i.stack.imgur.com/5crde.png)](https://i.stack.imgur.com/5crde.png)
[Answer]
# C# Windows forms, 268
```
static void k(int n,int s){var f=new Form{Height=s+50,Width=s+25};f.Paint+=(u,v)=>{var r=new Random();var p=new Point[n];while(n>0)p[--n]=new Point(r.Next(s),r.Next(s));foreach(var a in p)foreach(var b in p)f.CreateGraphics().DrawLine(Pens.Tan,a,b);};f.ShowDialog();}
```
**N=5**
![Plot using 5 points](https://i.stack.imgur.com/a6VxU.png)
**N=50**
![Plot using N=50](https://i.stack.imgur.com/GyMRo.png)
# Full code is given below
```
using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
    static class Program
    {
        static void Main()
        {
            k(50, 200);
        }
        static void k(int n, int s)
        {
            var f = new Form {Height = s + 50, Width = s + 25};
            f.Paint += (u, v) =>
            {
                var r = new Random();
                var p = new Point[n];
                while (n > 0)
                    p[--n] = new Point(r.Next(s), r.Next(s));
                foreach (var a in p)
                    foreach (var b in p)
                        f.CreateGraphics().DrawLine(Pens.Tan, a, b);
            };
            f.ShowDialog();
        }
    }
}
```
[Answer]
# [Red](http://www.red-lang.org), 81 bytes
```
?(draw d: 200x200 loop n: 10[foreach x append[]y: random d[repend[]['line x y]]])
```
[Try it locally in REPL](https://www.red-lang.org/p/download.html)
[![enter image description here](https://i.stack.imgur.com/11rsb.png)](https://i.stack.imgur.com/11rsb.png)
[Answer]
# HTML/JS, 210, thanks to manatwork
```
<canvas id=q /><script>c=q.getContext("2d");r=Math.random;e=prompt(a=[]);for(i=0;i<e;i++){a[i]={x:r()*300,y:r()*150};for(j in a)c.beginPath()+c.moveTo(a[i].x,a[i].y)+c.lineTo(a[j].x,a[j].y)+c.stroke()}</script>
```
[JSFiddle](http://jsfiddle.net/e866azzs/9)
[Answer]
# C# WPF  ~~306~~  296
```
partial class W:Window{public W(){InitializeComponent();int x=5,i=0,j,z=200;int[]f=new int[x],s=new int[x];var r=new Random();var X=new Grid();AddChild(X);for(;i<x;i++){f[i]=r.Next(z);s[i]=r.Next(z);for(j=i;j>=0;)X.Children.Add(newLine(){X1=s[j],Y1=f[j--],X2=s[i],Y2=f[i],Stroke=Brushes.Red});}}}
```
I would like to say that I could remove Stroke=Brushed.Red. But Sadly that means that I am painting transparent lines, and my Guess is that it wouldn't really count. :P I can also shave of a couple of bytes by just creating a grid in the XAML view. But that seemed unfair, so I stripped the XAML to become a blank canvas. (I don't count the XAML as bytes...) 
```
partial class W:Window
{
    public W()
    {
        InitializeComponent();
        int x=5,i=0,j,z=200;
        int[]f=new int[x],s=new int[x];
        var r = new Random();
        var X = new Grid();
        AddChild(X);
        for (;i<x;i++)
        {
            f[i]=r.Next(z);
            s[i]=r.Next(z);
            for (j=i;j>=0;)
                X.Children.Add(new Line()
                {
                    X1 = s[j],
                    Y1 = f[j--],
                    X2 = s[i],
                    Y2 = f[i],
                    Stroke = Brushes.Red
                });
        }
    }
}
```
XAML
```
<Window x:Class="W"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
</Window>
```
# 5
![5](https://i.stack.imgur.com/01baZ.jpg)
# 100
![100](https://i.stack.imgur.com/PGnXN.jpg)
[Answer]
# HPPPL, ~~231~~ 220
(HP Prime Programming Language for the HP Prime color graphing calculator)
golfed it down. 11 fewer chars by drawing all possible new lines right after every new point creation. Only two nested loops instead of the previous three.
```
export c(n) begin rect();local g,h;a:=makemat(0,n,2);for g from 1 to n do a(g,1):=ip(random(1,320));a(g,2):=ip(random(1,240));if g>1 then for h from 1 to g-1 do line_p(a(h,1),a(h,2),a(g,1),a(g,2));end;end;end;freeze;end;
```
Ungolfed (270 chars):
```
export randomnet(n)
begin
rect();
local g,h;
a:=makemat(0,n,2);
for g from 1 to n do
  a(g,1):=ip(random(1,320));
  a(g,2):=ip(random(1,240));
    if g>1 then
      for h from 1 to g-1 do
        line_p(a(h,1),a(h,2),a(g,1),a(g,2));
      end;
    end;
end;
freeze;
end;
```
examples:
c(10)
[![connect_10_points_HPPPL](https://i.stack.imgur.com/0jQ97.png)](https://i.stack.imgur.com/0jQ97.png)
[![connect_10_points_HPPPL_2](https://i.stack.imgur.com/UK7af.png)](https://i.stack.imgur.com/UK7af.png)
c(30)
[![connect_30_points_HPPPL](https://i.stack.imgur.com/dqcSC.png)](https://i.stack.imgur.com/dqcSC.png)
The HP Prime color graphing calculator has a 320x240 pixel color display.
[![enter image description here](https://i.stack.imgur.com/xLV1t.png)](https://i.stack.imgur.com/xLV1t.png)
An emulator that also works with the connectivity kit is available at the HP website or here: <http://www.hp-prime.de/en/category/6-downloads>
... still waiting for the hardware to arrive. Update on the execution time will follow.
Today my HP Prime arrived. Here is the execution time for n=100 on an actual calculator:
[![average execution time](https://i.stack.imgur.com/CV3hS.png)](https://i.stack.imgur.com/CV3hS.png)
Around 0.65 s for n=100.
The emulator is about 4 times as fast (around 0.178 s) on my Core i5 2410M laptop.
[Answer]
## NetLogo, 51 bytes
```
crt 9 [create-links-with other turtles fd random 9]
```
Replace 9s with other constants or variables as needed.
![NetLogo output](https://i.stack.imgur.com/AWrtI.png)
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), 17 chars
Imports (excluded from character count):
```
"exec('global r,p;from pylab import rand as r,plot as p')".E\
```
---
```
‚Äôp(*≈í¬¨(*r(,2))‚Äô.E
```
Beats all other answers. Port of [Falko's Python answer](https://codegolf.stackexchange.com/a/36634). Go upvote him! Input is hard-coded before the first `,`.
```
‚Äô...‚Äô.E  # trimmed program
     .E  # evaluate...
‚Äô...‚Äô    # "p(*zip(*r(num,2)))"...
     .E  # as Python code
====================
p(*zip(*r(num,2)))  # full program
p(               )  # display plot with lines connecting all points at coordinates in ordered pairs...
  *                 # in...
   zip(         )   # each element of...
       *            # first element of...
        r(   , )    # array of...
          num       # input...
        r(     )    # arrays each containing...
              2     # literal...
        r(     )    # random numbers from 0 to 1, half-inclusive...
   zip(         )   # paired with corresponding element in...
       *            # second element of...
        r(   , )    # array of...
          num       # input...
        r(     )    # arrays each containing...
              2     # literal...
        r(     )    # random numbers from 0 to 1, half-inclusive
```
# Character scoring abuse (actually longer), 20 characters
```
"ÒôïöúØ§Ûãí≠¶ïüë®•"√á6¬∞Œ≤∆µ6B√é.:.E
```
---
```
"..."√á6¬∞Œ≤∆µ6B√é.:.E  # trimmed program
               .E  # evaluate...
     √á             # list of charcodes of...
"..."              # literal...
        Œ≤          # converted from list of base-10 values of base...
       ¬∞           # 10 to the power of...
      6            # literal...
        Œ≤          # digits to decimal...
           B       # in base...
         ∆µ6        # 107...
             .:    # with all...
            √é      # 0...
             .:    # s replaced with...
            √é      # input
====================
p(*zip(*r(num,2)))  # full program
p(               )  # display plot with lines connecting all points at coordinates in ordered pairs...
  *                 # in...
   zip(         )   # each element of...
       *            # first element of...
        r(   , )    # array of...
          num       # input...
        r(     )    # arrays each containing...
              2     # literal...
        r(     )    # random numbers from 0 to 1, half-inclusive...
   zip(         )   # paired with corresponding element in...
       *            # second element of...
        r(   , )    # array of...
          num       # input...
        r(     )    # arrays each containing...
              2     # literal...
        r(     )    # random numbers from 0 to 1, half-inclusive
```
[Answer]
# PostScript, 48 bytes
```
00000000: 8814 3292 6c7b 7261 6e64 887f 9204 7d92  ..2.l{rand....}.
00000010: 837b 7b92 6b92 1a92 1992 1a34 9252 7b92  .{{.k......4.R{.
00000020: 4e92 6392 a792 4d7d 9283 7d92 657d 92a3  N.c...M}..}.e}..
```
Number of points is in the second byte (here it is 0x14 = 20 points).
Un-tokenized version:
```
20                          % number of points
2 mul{rand 127 and}repeat   % random points on stack
{
    {
        moveto              % move to top point on stack
        count copy          % duplicate stack
            count 4 idiv{   % for each duplicated point
            gsave
            lineto stroke   % draw a line to it
            grestore        % (removing it from the stack)
        }repeat
    }loop
}stopped                    % stop when stack is empty
```
[![output](https://i.stack.imgur.com/QvKYf.png)](https://i.stack.imgur.com/QvKYf.png)
]