public int classifyGrid(Grid grid){
		GridNode[] nodes = grid.nodes;
		SparseMatrix A = grid.A;
		GridNode gn = null;
		int numOfC = 0;	
		
		strongInfluenceCaculation(nodes, A);
		
		while((gn = getMax(nodes)) != null){
			gn.type = NodeType.C;
			gn.order = numOfC++;

//			if(gn.id==1)System.out.println(gn.St.keySet());
//			for(int j : gn.St.keySet()){//Sti
//				if(j != gn.id && nodes[j].type == NodeType.UNASSIGN){
//					nodes[j].type = NodeType.F;
//					nodes[j].lamda = Double.MIN_VALUE;
//				}
//			}
//			
//
//			for(int j : gn.St.keySet()){//Sti
//				if(j != gn.id){
//					Iterator<Integer> itr2 =  A.getRow(j).Iterator();
//					while(itr2.hasNext()){
//						Integer n = itr2.next();
//						if(j != n && nodes[n].type == NodeType.UNASSIGN)
//							nodes[n].lamda++;
//					}
//				}
//			}

			
			SparseVector neighbors = A.getRow(gn.id);
			Iterator<Integer> itr = neighbors.Iterator();
			while(itr.hasNext()){
				Integer i = itr.next();
				if(i != gn.id && nodes[i].type == NodeType.UNASSIGN){
					nodes[i].type = NodeType.F;
					nodes[i].lamda = Double.MIN_VALUE;
				}
			}

			itr = neighbors.Iterator();

			while(itr.hasNext()){
				Integer i = itr.next();
				if(i != gn.id){
//					Iterator<Integer> itr2 = neighbors.Iterator();
					Iterator<Integer> itr2 =  A.getRow(i).Iterator();
					while(itr2.hasNext()){
						Integer n = itr2.next();
						if(i != n && nodes[n].type == NodeType.UNASSIGN)
							nodes[n].lamda++;
					}
				}
			}
		}

		Diagnostic.log("Before Second Pass Number Of C's: " + numOfC);
		//Second pass
		numOfC = secondPass(nodes, A, numOfC);
		
		Diagnostic.log("After Second Pass Number Of C's: " + numOfC);
		return numOfC;
	}