public CWarshall(CGrafo grafo) { G = grafo; n = grafo.getNumeroVertices(); C = G.getMatrizAdyacencia().getMatriz(); D = new bool[n, n]; }
public CGrafo construyeK5() { CGrafo k5 = new CGrafo(1, 0); for (int i = 0; i < 5; i++) { CVertice v = new CVertice(i+1,0,0,Color.White,Color.Black); v.setGrado(4); CNodoVertice cnv = new CNodoVertice(v); k5.getListaAdyacencia().Add(cnv); } foreach (CNodoVertice nv in k5.getListaAdyacencia()) { foreach (CNodoVertice nv2 in k5.getListaAdyacencia()) { if (nv.getVertice().getId() != nv2.getVertice().getId()) { nv.getRelaciones().Add(nv2); nv.getVertice().getVecinos().Add(nv2.getVertice()); if (!k5.aristaRepetida(nv.getVertice(), nv2.getVertice())) { CArista ar = new CArista(nv.getVertice(), nv2.getVertice(),new Point(0,0),new Point(0,0),0); k5.getListaAristas().Add(ar); } } } } k5.setNumeroAristas(10); k5.setNumeroVertices(5); return k5; }
public CGrafo construyeK5() { CGrafo k5 = new CGrafo(1, 0); for (int i = 0; i < 5; i++) { CVertice v = new CVertice(i + 1, 0, 0, Color.White, Color.Black); v.setGrado(4); CNodoVertice cnv = new CNodoVertice(v); k5.getListaAdyacencia().Add(cnv); } foreach (CNodoVertice nv in k5.getListaAdyacencia()) { foreach (CNodoVertice nv2 in k5.getListaAdyacencia()) { if (nv.getVertice().getId() != nv2.getVertice().getId()) { nv.getRelaciones().Add(nv2); nv.getVertice().getVecinos().Add(nv2.getVertice()); if (!k5.aristaRepetida(nv.getVertice(), nv2.getVertice())) { CArista ar = new CArista(nv.getVertice(), nv2.getVertice(), new Point(0, 0), new Point(0, 0), 0); k5.getListaAristas().Add(ar); } } } } k5.setNumeroAristas(10); k5.setNumeroVertices(5); return(k5); }
public CDijkstra(CGrafo grafo) { G = grafo; n = grafo.getNumeroVertices(); V = grafo.getListaAdyacencia(); C = construyeC(); }
public CGrafo construyeK33() { CGrafo k33 = new CGrafo(1, 0); for (int i = 0; i < 6; i++) { CVertice v = new CVertice(i + 1, 0, 0, Color.White, Color.Black); v.setGrado(3); CNodoVertice cnv = new CNodoVertice(v); k33.getListaAdyacencia().Add(cnv); } for (int i = 0; i < 3; i++) { for (int j = 3; j < 6; j++) { k33.getListaAdyacencia()[i].getRelaciones().Add(k33.getListaAdyacencia()[j]); k33.getListaAdyacencia()[i].getVertice().getVecinos().Add(k33.getListaAdyacencia()[j].getVertice()); k33.getListaAdyacencia()[j].getRelaciones().Add(k33.getListaAdyacencia()[i]); k33.getListaAdyacencia()[j].getVertice().getVecinos().Add(k33.getListaAdyacencia()[i].getVertice()); CArista ar = new CArista(k33.getListaAdyacencia()[i].getVertice(), k33.getListaAdyacencia()[j].getVertice(), new Point(0, 0), new Point(0, 0), 0); k33.getListaAristas().Add(ar); } } k33.setNumeroAristas(9); k33.setNumeroVertices(6); return(k33); }
//Menu Archivo private void proyectoDeGrafosToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog sd = new SaveFileDialog(); sd.AddExtension = true; sd.DefaultExt = ".grf"; sd.Title = "Nuevo Proyecto de Grafos"; sd.OverwritePrompt = true; sd.Filter = "Proyecto de Grafos (*.grf)|*.grf"; sd.FilterIndex = 1; sd.ValidateNames = true; if (sd.ShowDialog() == DialogResult.OK) { cierraProyecto(); FileInfo file = new FileInfo(sd.FileName); nom_proyecto = sd.FileName; string fileNameOnly = file.Name; this.Text = fileNameOnly; Stream stream = new FileStream(sd.FileName, FileMode.Create, FileAccess.Write, FileShare.None); stream.Close(); proyecto = true; grafos = new List <CGrafo>(); if (grafo_activo != null) { grafo_activo = null; } } }
public CGrafo construyeK33() { CGrafo k33 = new CGrafo(1, 0); for (int i = 0; i < 6; i++) { CVertice v = new CVertice(i + 1, 0, 0, Color.White, Color.Black); v.setGrado(3); CNodoVertice cnv = new CNodoVertice(v); k33.getListaAdyacencia().Add(cnv); } for (int i = 0; i < 3; i++) { for (int j = 3; j < 6; j++) { k33.getListaAdyacencia()[i].getRelaciones().Add(k33.getListaAdyacencia()[j]); k33.getListaAdyacencia()[i].getVertice().getVecinos().Add(k33.getListaAdyacencia()[j].getVertice()); k33.getListaAdyacencia()[j].getRelaciones().Add(k33.getListaAdyacencia()[i]); k33.getListaAdyacencia()[j].getVertice().getVecinos().Add(k33.getListaAdyacencia()[i].getVertice()); CArista ar = new CArista(k33.getListaAdyacencia()[i].getVertice(), k33.getListaAdyacencia()[j].getVertice(), new Point(0, 0), new Point(0, 0), 0); k33.getListaAristas().Add(ar); } } k33.setNumeroAristas(9); k33.setNumeroVertices(6); return k33; }
public CPrim(CGrafo grafo,TabPage t) { V = grafo.getListaAdyacencia(); E = grafo.getListaAristas(); U = new List<CVertice>(); G = grafo; tp = t; }
public CPrim(CGrafo grafo, TabPage t) { V = grafo.getListaAdyacencia(); E = grafo.getListaAristas(); U = new List <CVertice>(); G = grafo; tp = t; }
public CFloyd(CGrafo grafo) { G = grafo; n = grafo.getNumeroVertices(); V = grafo.getListaAdyacencia(); C = construyeC(); P = new int[n, n]; D = new int[n, n]; }
private void Pestanas_SelectedIndexChanged(object sender, EventArgs e) { if (grafos != null && grafos.Count != 0 && Pestanas.SelectedIndex != -1) { grafo_activo = grafos[Pestanas.SelectedIndex]; grafo_activo.op = Opmenu; SetBotonesAristas(grafo_activo.getTipo()); } }
public bool mismosNVyNA(CGrafo G, CGrafo H) { bool iguales = false; if (G.getNumeroAristas() == H.getNumeroAristas() && G.getNumeroVertices() == H.getNumeroVertices()) { iguales = true; } return(iguales); }
public void cargaTabPage() { if (grafos != null && grafos.Count != 0) { for (int i = 0; i < grafos.Count; i++) { grafos[i] = new CGrafo(Pestanas, grafos[i].getId(), grafos[i].getTipo(), grafos[i].getListaAdyacencia(), grafos[i].getListaAristas(), grafos[i].getNumeroAristas(), grafos[i].getNumeroVertices()); } } }
public bool esPlanoPorKuratowskyInteractivo(CGrafo grafo_evaluado) { if (esIsomorficoAK5(grafo_evaluado) || esIsomorficoAK33(grafo_evaluado)) { return(false); } else { return(true); } }
public void getGrados(CGrafo gx) //Obtiene los grados (sin repetirse) que tiene el grafo { foreach (CNodoVertice cnv in gx.getListaAdyacencia()) { if (!existeItem(grados, cnv.getVertice().getVecinos().Count)) { grados.Add(cnv.getVertice().getVecinos().Count); } } grados.Sort(); }
//Botones de operacion private void BNGrafo_Click(object sender, EventArgs e) { if (proyecto) { CGrafo grafo_nvo = new CGrafo(Pestanas, ++num_graf, -1); grafos.Add(grafo_nvo); if (grafos.Count == 1) { grafo_activo = grafos[0]; } } }
public bool esIsomorficoAK33(CGrafo grafo_evaluado) { CIsomorfismo ci = new CIsomorfismo(k33, grafo_evaluado); if (ci.sonIsomorficos()) { return(true); } else { return(false); } }
public CRecorridoP(CGrafo grafo, TabPage tpx) { arcos_arbol = new List <CArista>(); arcos_avance = new List <CArista>(); arcos_retroceso = new List <CArista>(); arcos_cruzados = new List <CArista>(); G = grafo; num = 0; descendientes = new int[G.getListaAdyacencia().Count]; tp = tpx; GR = new List <CNodoVertice>(); ids_cf = new List <List <int> >(); }
public CRecorridoP(CGrafo grafo,TabPage tpx) { arcos_arbol = new List<CArista>(); arcos_avance = new List<CArista>(); arcos_retroceso = new List<CArista>(); arcos_cruzados = new List<CArista>(); G = grafo; num = 0; descendientes = new int[G.getListaAdyacencia().Count]; tp = tpx; GR = new List<CNodoVertice>(); ids_cf = new List<List<int>>(); }
public CKruskal(CGrafo grafo,TabPage tpx) { G = grafo; V = G.getListaAdyacencia(); E = G.getListaAristas(); Q = new List<CArista>(); T = new List<CArista>(); tp = tpx; componentes = new List<List<CVertice>>(); foreach (CArista a in E) Q.Add(a); Q.Sort(comparaArista); }
public CKruskal(CGrafo grafo, TabPage tpx) { G = grafo; V = G.getListaAdyacencia(); E = G.getListaAristas(); Q = new List <CArista>(); T = new List <CArista>(); tp = tpx; componentes = new List <List <CVertice> >(); foreach (CArista a in E) { Q.Add(a); } Q.Sort(comparaArista); }
//Constructor public CColoreado(CGrafo grafo) { colores = new Color[10]; colores[AZUL]= Color.DeepSkyBlue; colores[ROJO]= Color.Red; colores[VERDE]= Color.Lime; colores[AMARILLO]= Color.Yellow; colores[NARANJA]= Color.Orange; colores[CAFE]= Color.Peru; colores[MORADO]= Color.DarkOrchid; colores[ROSA]= Color.HotPink; colores[AQUA]= Color.Aqua; colores[NEGRO]= Color.Black; band = band2=false; G = grafo; foreach (CNodoVertice cnv in G.getListaAdyacencia()) cnv.getVertice().setGradoError(cnv.getVertice().getGrado()); }
//Constructor public CColoreado(CGrafo grafo) { colores = new Color[10]; colores[AZUL] = Color.DeepSkyBlue; colores[ROJO] = Color.Red; colores[VERDE] = Color.Lime; colores[AMARILLO] = Color.Yellow; colores[NARANJA] = Color.Orange; colores[CAFE] = Color.Peru; colores[MORADO] = Color.DarkOrchid; colores[ROSA] = Color.HotPink; colores[AQUA] = Color.Aqua; colores[NEGRO] = Color.Black; band = band2 = false; G = grafo; foreach (CNodoVertice cnv in G.getListaAdyacencia()) { cnv.getVertice().setGradoError(cnv.getVertice().getGrado()); } }
private void abrirProyectoDeGrafosToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog od = new OpenFileDialog(); od.DefaultExt = ".grf"; od.Title = "Abrir Proyecto de Grafos"; od.Filter = "Proyecto de Grafos (*.grf)|*.grf"; od.CheckFileExists = true; if (od.ShowDialog() == DialogResult.OK) { cierraProyecto(); FileInfo file = new FileInfo(od.FileName); string fileNameOnly = file.Name; this.Text = fileNameOnly; IFormatter formatter = new BinaryFormatter(); Stream stream = new FileStream(od.FileName, FileMode.Open, FileAccess.Read, FileShare.None); if (stream.Length != 0) { grafos = (List <CGrafo>)formatter.Deserialize(stream); if (grafos.Count != 0) { grafo_activo = grafos[0]; SetBotonesAristas(grafo_activo.getTipo()); } } else { grafos = new List <CGrafo>(); } stream.Close(); num_graf = grafos.Count; nom_proyecto = od.FileName; proyecto = true; Opmenu = 0; cargaTabPage(); } }
public bool mismosNVyNA(CGrafo G,CGrafo H) { bool iguales = false; if (G.getNumeroAristas() == H.getNumeroAristas() && G.getNumeroVertices() == H.getNumeroVertices()) iguales = true; return iguales; }
public CIsomorfismo(CGrafo grafo_1, CGrafo grafo_2) : base() { G = grafo_1; H = grafo_2; }
//Obtiene los grados (sin repetirse) que tiene el grafo public void getGrados(CGrafo gx) { foreach (CNodoVertice cnv in gx.getListaAdyacencia()) { if (!existeItem(grados, cnv.getVertice().getVecinos().Count)) { grados.Add(cnv.getVertice().getVecinos().Count); } } grados.Sort(); }
public CKuratowsky() : base() { k5 = this.construyeK5(); k33 = this.construyeK33(); }