//MemberFunction public void Search(DirectedEdgeMatrix edge) //Search the graph from the vertice with 0 indegree { //Menghitung derajat masuk for (int i = 0; i < Size; i++) { indegree[i] = edge.countIndegree(i); } int j; for (int i = 0; i < Size; i++) { j = 0; //Mencari simpul yang belum dikunjungi yang memiliki indegree 0 while (indegree[j] != 0 || VisitedSet.isVisited(j)) { j++; } VisitedSet.visit(j); Solution.Add(j); //Pencatatan indegree setiap langkah for (int k = 0; k < Size; k++) { indegreePerStep[i, k] = indegree[k]; } //Pengurangan indegree tentangga simpul yang dipilih for (int k = 0; k < Size; k++) { if (edge.isAdjacent(j, k)) { indegree[k] -= 1; } } } }
public void Search(DirectedEdgeMatrix edge, int VerticeCheck, ref int time) //Search the vertice Check, then search the next vertices from vertice Check { VisitedSet.visit(VerticeCheck); VerticeTimeStamps[VerticeCheck] = new TimeStamp(time); //Penelurusan mulai CheckOrder.Add(new DFSCheck(VerticeCheck, false)); time += 1; //Penelusuran anak for (int i = 0; i < Size; i++) { if ((!VisitedSet.isVisited(i)) && (edge.isAdjacent(VerticeCheck, i))) { Search(edge, i, ref time); } } //Penelusuran selesai VerticeTimeStamps[VerticeCheck].setEnd(time); CheckOrder.Add(new DFSCheck(VerticeCheck, true)); }