DE CASUALIDAD ALGUNO TIENE ENLACES O LIBROS, O PDF, QUE ME PUEDAN FACILITAR, PORQUE TENGO UNOS PERO CREO QUE SON MUY VIEJOS ,Y PUEDO CONSIDERARLOS OBSOLETOS
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menúvoid Grafo::InsertarArista(Vertice *origen, Vertice *destino)
{
Arista *nueva = new Arista;
nueva->sig=NULL;
nueva ->ady=NULL;
Arista *aux;
aux = origen->ady;
if(aux==NULL)
{
origen->ady = nueva;
nueva->ady = destino;
}
else
{
while (aux !=NULL)
{
aux=aux->sig;
}
aux->sig = nueva;
nueva->ady=destino;
}
}
case 2:
{
string origen, destino;
system("cls");
if(G.vacio())
{
cout<<"El grafo esta vacio"<<endl;
}
else
{
cout<<"Ingrese del nombre del vertice origen: ";
cin.ignore();
getline(cin, origen, '\n');
cout<<"Ingrese el nombre del vertice destino: ";
getline(cin, destino, '\n');
system("cls");
if(G.GetVertice(origen) == NULL || G.GetVertice(destino) == NULL)
{
cout<<"Uno de los vertices no es valido"<<endl;
}
else
{
G.InsertarArista(G.GetVertice(origen), G.GetVertice(destino));//, peso);
}
}
cin.get();
cin.get();
break;
}
package matriz_adyacencia;
/**
*
* @author PAPAYO
*/
public class Matriz_Adyacencia {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Matriz_de_adyacencia matriz = new Matriz_de_adyacencia(5);
matriz.agregar(0, 1);
matriz.agregar(0, 1);
matriz.agregar(0, 2);
matriz.agregar(0, 3);
matriz.agregar(1, 0);
matriz.agregar(1, 0);
matriz.agregar(1, 4);
matriz.agregar(2, 0);
matriz.agregar(2, 3);
matriz.agregar(2, 4);
matriz.agregar(3, 0);
matriz.agregar(3, 2);
matriz.agregar(4, 1);
matriz.agregar(4, 2);
matriz.agregar(4, 4);
matriz.agregar(4, 4);
matriz.imprimir();
}
}
package matriz_adyacencia;
public class Matriz_de_adyacencia {
public int n;
public int[][] matriz;
/**
* Constructor de clase
* @param n numero de nodos
*/
public Matriz_de_adyacencia(int n) {
this.n = n;
matriz = new int[this.n][this.n];
//se inicializa matriz en 0
for(int i=0; i< n; i++){
for(int j=0; j< n; j++){
matriz[i][j] = 0;
}
}
}
public void agregar(int i, int j){
matriz[i][j] += 1;
}
public void remover(int i, int j){
if(matriz[i][j]>0)
matriz[i][j] -= 1;
}
public void imprimir(){
for(int i=0; i< n; i++){
for(int j=0; j< n; j++){
System.out.print( matriz[i][j] + " " );
}
System.out.println("");
}
}
}
#include<iostream>
#include<conio.h>
#include<stdlib.h>
using namespace std;
struct nodo {
int dato;
nodo * der;
nodo* iz;
};
nodo *crearNodo(int);
void insertar_nodo (nodo *&, int);
void menu();
void mostrarArbol(nodo,int);
nodo *arbol = NULL;
int main() {
menu();
return 0;
}
void menu(){
int dato,opcion,contador = 0;
do {
cout<<"Menus: "<<endl;
cout<<"1. Insertar un nuevo nodo: "<<endl;
cout<<"2. Mostar arbol Completo: "<<endl;
cout<<"3. Salir"<<endl;
cin>>opcion;
void mostarArbol(nodo*,int);
switch (opcion){
case 1 : cout<<"digite Numero: ";
cin >> dato;
insertar_nodo (arbol , dato);
cout<<"";
system("PAUSE");
break;
case 2: cout<<"Arbol";
mostarArbol(arbol,contador);
system ("PAUSE");
break;
}
system ("cls");
}while (opcion = !3);
}
nodo *crearNodo(int n){
nodo *nuevo_nodo = new nodo();
}
void insertar_nodo (nodo *& arbol,int n){
if (arbol == NULL){
nodo *nuevo_nodo = crearNodo(n);
arbol = nuevo_nodo;
}else {
int valorRaiz = arbol ->dato;
if(n < valorRaiz){
insertar_nodo (arbol ->iz,n);
}
else{
insertar_nodo (arbol->der,n);
}
}
}
void mostrarArbol(nodo *arbol,int cont){
if (arbol == NULL){
return;
}else {
mostrarArbol(arbol->der,cont+1);
for(int i=0;i<cont;i++){
cout<<" ";
}
cout << arbol ->dato<<endl;
mostrarArbol(arbol->iz,cont+1);
}
}