-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagglocluster.java
More file actions
104 lines (103 loc) · 1.76 KB
/
agglocluster.java
File metadata and controls
104 lines (103 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import java.util.*;
class agglocluster
{
public static void main(String args[])
{
double x[]=new double[10];
double y[]=new double[10];
double d[][]=new double[10][10];
double x1[]=new double[10];
double y1[]=new double[10];
int cls[]=new int[10];
double min,max;
int i,j,k,n,a=0,b=0,count=1;
Scanner sc=new Scanner(System.in);
System.out.println("enter no of points:");
n=sc.nextInt();
System.out.println("enter x co-ordinate:");
for(i=0;i<n;i++)
{
x[i]=sc.nextDouble();
}
System.out.println("enter y co-ordinate:");
for(i=0;i<n;i++)
{
y[i]=sc.nextDouble();
}
System.out.println("x co-ordinates are");
for(i=0;i<n;i++)
{
System.out.println(x[i]);
}
System.out.println("y co-ordinates are");
for(i=0;i<n;i++)
{
System.out.println(y[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==j)
{
d[i][j]=0.0;
}
else
{
x1[i]=Math.pow((x[i]-x[j]),2);
y1[i]=Math.pow((y[i]-y[j]),2);
d[i][j]=Math.sqrt(x1[i]+y1[i]);
}
}
}
System.out.println("the distances are:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
System.out.print(d[i][j]+" ");
}
System.out.println("\n");
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==j)
{
d[i][j]=99.99;
}
}
}
min=d[0][0];
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(d[i][j]<min)
{
min=d[i][j];
}
}
}
count++;
System.out.println("The minimum value is:"+min);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(d[i][j]==min)
{
a=i;
b=j;
break;
}
}
}
System.out.println("the cluster is p"+a+1+"and p"+b+1);
for(i=0;i<n;i++)
{
for
}
}
}