-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdeleted.java
131 lines (118 loc) · 5.88 KB
/
deleted.java
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
package Incognito;
import datafly.DGHTree;
import datafly.DataFly;
import datafly.PrivateTable;
import java.io.FileNotFoundException;
import java.util.ArrayList;
/**
*
* @author adenugad
*/
public class deleted {
Graph mainGraph;
PrivateTable table;
DataFly dataFly;
ArrayList<String> quasiCombinationList;
/**
* Modify quasi combination list to include level in DGH
* I can create graph from here, make vertex,
* add possible incident Edges
* @param table
* @param noOfAttribute
* @throws java.io.FileNotFoundException
*/
public void createGraphFromQuasiCombinationList(PrivateTable table, int noOfAttribute) throws FileNotFoundException{
//Graph graph = new Graph();
// lot of fors
//I should add labels for DGHTrees
//but I know they were created in order Race, DOB, ID
//should I assume, i know the number of quasiID
ArrayList<DGHTree> dghTrees = dataFly.createDGHTrees(table);
ArrayList<String> quasiIden = table.getQuasiIden().getData();
String[] input = new String[quasiIden.size()];
Incognito incognito = null;
incognito.combination(quasiIden.toArray(input), new String[quasiIden.size()],
0, quasiIden.size() - 1, 0, noOfAttribute);
for(int i = 0; i < quasiCombinationList.size(); i++){
Vertex vertex = new Vertex(quasiCombinationList.get(i));
//graph.addVertex(vertex);
String[] arr = quasiCombinationList.get(i).split(":");
//System.out.println("arr- " + Arrays.toString(arr));
for(int j = 0; j < arr.length; j++){
//System.out.println("arr[j]- " + arr[j]);
int treeIndex = checkListForCorrectDGH(dghTrees, arr[j]);
//System.out.println("tree " + treeIndex);
int dghHeight = dghTrees.get(treeIndex).getHeight();
int currHeightOfVertex = Integer.parseInt(arr[j].substring(arr[j].indexOf(" ")+1));
if(currHeightOfVertex + 1 <= dghHeight){
currHeightOfVertex = currHeightOfVertex + 1;
}
String possibleVertex = "";
for(int k = 0; k < arr.length; k++){
if(k == j){
possibleVertex = possibleVertex +
arr[j].substring(0, arr[j].indexOf(" ")+1 )
+ String.valueOf(currHeightOfVertex) + ":";
}
else{
possibleVertex = possibleVertex + arr[k] + ":";
}
}
Vertex vertex2 = new Vertex (possibleVertex.substring(0,
possibleVertex.lastIndexOf(":")));
Edge edge = new Edge(vertex, vertex2);
vertex.addIncidentEdges(edge);vertex2.addIncidentEdges(edge);
mainGraph.addVertex(vertex);mainGraph.addVertex(vertex2);
mainGraph.addEdge(edge);
}
}
}
public int checkListForCorrectDGH(ArrayList<DGHTree> dghTrees, String dghLabel){
// System.out.println("dghLabel I'm looking for - " + dghLabel);
//System.out.println("dghLabel I'm looking for2 - " + dghLabel.substring(0, dghLabel.indexOf(" ")));
for(int i = 0; i < dghTrees.size(); i++){
//System.out.println("dghLabel in the list - " + dghTrees.get(i).getLabel());
//System.out.println("index- " + dghLabel.indexOf(" "));
if(dghTrees.get(i).getLabel().equalsIgnoreCase(dghLabel.substring(0, dghLabel.indexOf(" ")))){
return i;
}
}
return -1;
}
public ArrayList<String> combineWithDGHeight(String valueToBeCombined, DGHTree dghTree){
ArrayList<String> possibleVertices = new ArrayList<>();
for(int i = 1; i < dghTree.getHeight(); i++){
String newValue = valueToBeCombined + ":" + dghTree.getLabel() + " " + String.valueOf(i);
possibleVertices.add(newValue);
}
return possibleVertices;
}
public void edgeUpVertex(Vertex v, ArrayList<DGHTree> dghTrees){
System.out.println("v.getData - " + v.getData());
String[] arr = v.getData().split(":");
for(int j = 0; j < arr.length; j++){
int treeIndex = checkListForCorrectDGH(dghTrees, arr[j]);
int dghHeight = dghTrees.get(treeIndex).getHeight();
int currHeightOfVertex = Integer.parseInt(arr[j].substring(arr[j].indexOf(" ")+1));
while(currHeightOfVertex + 1 <= dghHeight){
currHeightOfVertex = currHeightOfVertex + 1;
String possibleVertex = "";
for(int k = 0; k < arr.length; k++){
if(k == j){
possibleVertex = possibleVertex + ":" +
arr[j].substring(0, arr[j].indexOf(" ")+1 ) + " " + String.valueOf(currHeightOfVertex);
}
else{
possibleVertex = possibleVertex + ":" + arr[k];
}
}
Vertex vertex2 = new Vertex (possibleVertex);
Edge edge = new Edge(v, vertex2);
v.addIncidentEdges(edge);vertex2.addIncidentEdges(edge);
//mainGraph.addVertex(v);
mainGraph.addVertex(vertex2);
mainGraph.addEdge(edge);
}
}
}
}