forked from rostam/GraphTea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sss
144 lines (144 loc) · 4.39 KB
/
sss
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
+package graphtea.extensions.reports.zagreb;
+
+import graphtea.graph.graph.RendTable;
+import graphtea.graph.graph.Vertex;
+import graphtea.platform.lang.CommandAttitude;
+import graphtea.plugins.main.GraphData;
+import graphtea.plugins.main.core.AlgorithmUtils;
+import graphtea.plugins.reports.extension.GraphReportExtension;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Vector;
+
+/**
+ * @author Ali Rostami
+ */
+
+@CommandAttitude(name = "finalm2conj", abbreviation = "_finalm2conj")
+public class FinalNewM2Lower implements GraphReportExtension{
+ public String getName() {
+ return "Final New M2 Lower";
+ }
+
+ public String getDescription() {
+ return " Final New M2 Lower ";
+ }
+
+ public Object calculate(GraphData gd) {
+ ZagrebIndexFunctions zif = new ZagrebIndexFunctions(gd.getGraph());
+ RendTable ret = new RendTable();
+ ret.add(new Vector<Object>());
+ ret.get(0).add(" M^2_1(G) ");
+ ret.get(0).add("SR4 max ");
+ ret.get(0).add("SR4 min ");
+ ret.get(0).add("S3 max ");
+ ret.get(0).add("My FMC ");
+ ret.get(0).add("Das FMC ");
+ ret.get(0).add("S2 max ");
+ ret.get(0).add("S2 min ");
+ ret.get(0).add("My max ");
+ ret.get(0).add("Das max ");
+ ret.get(0).add("illc");
+
+ double maxDeg = 0;
+ double maxDeg2 = 0;
+ double minDeg = Integer.MAX_VALUE;
+
+ ArrayList<Integer> al = AlgorithmUtils.getDegreesList(gd.getGraph());
+ Collections.sort(al);
+ maxDeg = al.get(al.size()-1);
+ if(al.size()-2>=0) maxDeg2 = al.get(al.size()-2);
+ else maxDeg2 = maxDeg;
+ minDeg = al.get(0);
+
+ if(maxDeg2 == 0) maxDeg2=maxDeg;
+
+ double a=0;
+ double b=0;
+
+ for(Vertex v : gd.getGraph()) {
+ if(gd.getGraph().getDegree(v)==maxDeg) a++;
+ if(gd.getGraph().getDegree(v)==minDeg) b++;
+ }
+ if(maxDeg==minDeg) b=0;
+
+ double m = gd.getGraph().getEdgesCount();
+ double n = gd.getGraph().getVerticesCount();
+
+ double M12=zif.getSecondZagreb(1);
+ double M21=zif.getFirstZagreb(1);
+ double M22=zif.getSecondZagreb(2);
+ double Mm11=zif.getFirstZagreb(-2);
+
+ ret.add(new Vector<Object>());
+
+ ret.get(1).add(M21);
+
+//SR4 max
+ ret.get(1).add(maxDeg*maxDeg +
+ maxDeg2*maxDeg2
+ + Math.pow((2*(m+1) - (n+maxDeg+maxDeg2)
+ + Math.sqrt((2*m-maxDeg-maxDeg2)
+ *(Mm11-((1/maxDeg)-(1/maxDeg2))))),2)/(n-2));
+
+//SR4 min
+ ret.get(1).add(maxDeg*maxDeg +
+ minDeg*minDeg
+ + Math.pow((2*(m+1) - (n+maxDeg+minDeg)
+ + Math.sqrt((2*m-maxDeg-minDeg)
+ *(Mm11-((1/maxDeg)-(1/minDeg))))),2)/(n-2));
+//S3 max
+ ret.get(1).add(maxDeg*maxDeg +
+ maxDeg2*maxDeg2 +
+ ((2*m-maxDeg-maxDeg2)/(n-2))
+ *(Mm11+2*m-(maxDeg+maxDeg2+(1/maxDeg) +(1/maxDeg2)))-(n-2));
+
+//S3 min
+ ret.get(1).add(maxDeg*maxDeg +
+ minDeg*minDeg +
+ ((2*m-maxDeg-minDeg)/(n-2))
+ *(Mm11+2*m-(maxDeg+minDeg+(1/maxDeg) +(1/minDeg)))-(n-2));
+
+//My FMC
+ ret.get(1).add(Math.pow(maxDeg,2)+(Math.pow(2*m-maxDeg,2)/(n-1))
+ + ((Math.pow(n-2,2)*(maxDeg2-minDeg))/Math.pow(n-1,2)));
+
+//Das FMC
+ ret.get(1).add(Math.pow(maxDeg,2)+(Math.pow(2*m-maxDeg,2)/(n-1))
+ + ((2*(n-2)*(maxDeg2-minDeg))/Math.pow(n-1,2)));
+
+//S2 max
+ ret.get(1).add(maxDeg*maxDeg +
+ maxDeg2*maxDeg2 +
+ (((2*m-maxDeg-maxDeg2)*(n-2))/(Mm11-((1/maxDeg)+(1/maxDeg2)))));
+//S2 min
+ ret.get(1).add(maxDeg*maxDeg +
+ minDeg*minDeg +
+ (((2*m-maxDeg-minDeg)*(n-2))/(Mm11-((1/maxDeg)+(1/minDeg)))));
+
+//My max
+ ret.get(1).add(maxDeg*maxDeg +
+ maxDeg2*maxDeg2 +
+ (Math.pow(2*m-maxDeg-maxDeg2,2)/(n-2)));
+
+//Das max
+ ret.get(1).add(maxDeg*maxDeg +
+ minDeg*minDeg +
+ (Math.pow(2*m-maxDeg-minDeg,2)/(n-2)));
+
+
+ //illc
+ ret.get(1).Math.pow(2*m,2)/(n)));
+
+
+ return ret;
+ }
+
+ @Override
+ public String getCategory() {
+ // TODO Auto-generated method stub
+ return "Topological Indices";
+ }
+}
+