//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public java.util.ArrayList<N> DFS(IGrafo<N> grafo, N n) throws Excepciones.ExcepcionNodoNoEncontrado public virtual List<N> DFS(IGrafo<N> grafo, N n) { if (grafo.existeNodo(n)) { List<N> array = new List<N>(); grafo.buscarNodo(n).EstaVisitado = true; array.Add(n); List<N> aux = grafo.darAdyacentes(n); for (int i = 0; i < aux.Count; i++) { N sig = aux[i]; if (grafo.buscarNodo(sig).EstaVisitado == false) { List<N> array2 = DFS(grafo, sig); for (int j = 0; j < array2.Count; j++) { array.Add(array2[j]); } } } return array; } else { return null; } }
//PASO 1. Falta eliminar los estados //nodo inicial //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public java.util.ArrayList<N> BFS(IGrafo<N> grafo, N n) throws Excepciones.ExcepcionNodoNoEncontrado public virtual List<N> BFS(IGrafo<N> grafo, N n) { grafo.reestablecerNodos(); if (grafo.existeNodo(n)) { LinkedList<N> cola = new LinkedList<N>(); cola.AddLast(n); grafo.buscarNodo(n).EstaVisitado = true; List<N> array = new List<N>(); while (cola.Count > 0) { N actual = cola.RemoveFirst(); array.Add(actual); List<N> aux = grafo.darAdyacentes(actual); for (int i = 0; i < aux.Count; i++) { N sig = aux[i]; if (grafo.buscarNodo(sig).EstaVisitado == false) { grafo.buscarNodo(sig).EstaVisitado = true; cola.AddLast(sig); } } } return array; } else { return null; } }