0% found this document useful (0 votes)
36 views16 pages

MAU Practica4

The document contains several math equations representing a network flow problem with constraints. It also includes sections describing a graph coloring problem involving provinces in Ecuador and their populations, as well as code for a program with two data grids to represent matrices and buttons to perform operations on the data.

Uploaded by

Paul Pinto J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views16 pages

MAU Practica4

The document contains several math equations representing a network flow problem with constraints. It also includes sections describing a graph coloring problem involving provinces in Ecuador and their populations, as well as code for a program with two data grids to represent matrices and buttons to perform operations on the data.

Uploaded by

Paul Pinto J
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

DEBER 10

TEMA 1

a)












b)
f(s,Ashton)+ f(s,Robert P.)+f(s,Johnny)+f(s,Rober D.)+f(s,Matt)-v=0
-f(Ashton,Anne)- f(Ashton,Anne)=0
-f(s,Robet P)+ f(Robert P,Mila)=0
-f(s,Johnny)+ f(Johnny,Mila)+ f(Johnny,Anne)=0
-f(s,Robert D)+ f(Robert D,Mila)+ f(Robert D,Anne)+ f(Robert D,Scarlett)=0
-f(s,matt)+ f(Matt,keyra)+ f(Matt,Megan)+ f(Megan,Scarlett)=0
-f(Rober P,Mila)- f(Rober D,Mila)-f(Johnny,Mila)+ f(Matt,f)=0
-f(Ashton,Anne)- f(Rober D,Mila)- f(Rober D,Anne)+ f(Anne,f)=0
-f(Matt,Keyra)+ f(Keyra,f)=0
-f(Matt,Megan)+ f(Megan,f)=0
-f(Robert D, Scarlett)- f(Matt,Scarlett)+ f(Scarlett,f)=0
-f(Matt,f)- f(Anne,f)- f(Keyra,f) f(Megan,f) -f(Scarlett,f)+v=0


Restricciones de capacidades
Ashton
Kutcher
Robert
Pattins
Johnny
Depp
Robert
Downe
Matt
Damon
Mila
Kunis
Anne
Hattew
Keyra
Knigth
Megan
Fox
Scarlett
Johanss
S F
1<=f(s,Ashton)<=1
1<=f(s,Robert P.)<=1
1<=f(s,jOHNNY)<=1
1<=f(s,Robert D.)<=1
1<=f(s,Matt)<=1
0<=f(Ashton,Anne)<=1
0<=f(Robet P,Mila)<=1
0<=f(Johnny,Anne)<=1
0<=f(Johnny,Mila)<=1
0<=f(Robet D,Mila)<=1
0<=f(Robet P,Anne)<=1
0<=f(Robet P,Scarlett)<=1
0<=f(Matt,Keyra)<=1
0<=f(Matt,Megan)<=1
1<=f(Matt,Scarlett)<=1
2<=f(Mila,f)<=2
2<=f(Anne,f)<=2
2<=f(Keyra,f)<=2
2<=f(Megan,f)<=2
2<=f(Scarlett,f)<=2





TEMA 2





















-Identificamos la cardinalidad de cada
nodo:
Esmeraldas = 5
Manab = 6
Carchi = 3
Imbabura = 4
Pichincha = 7
Sto Domingo = 4
Sta Elena = 2
Guayas = 6
Sucumbos = 5
Napo = 5
Fco. Orellana = 3
Pastaza = 4
Morona Santiago = 6
Zamora Chimchipe = 3
Loja = 3
El Oro = 3
Azuay = 6
Caar = 4
Chimborazo = 4
Bolvar = 4
Los Ros = 5
Galpagos = 0
Tungurahua = 6
Cotopaxi = 6





Pichincha = 7
Manab = 6
Guayas = 6
Morona Santiago = 6
Azuay = 6
Tungurahua = 6
Cotopaxi = 6
Sucumbos = 5
Napo = 5
Los Ros = 5
Esmeraldas = 5
Pastaza = 4
Imbabura = 4
Sto Domingo = 4
Caar = 4
Chimborazo = 4
Bolvar = 4
Carchi = 3
Fco. Orellana = 3
Zamora Chimchipe = 3
Loja = 3
El Oro = 3
Sta. Elena = 2
Galpagos = 0

- Agrupamos los estables para asignar los colores
1) x={Pichincha}
2) x={Manab}
3)x={Pichincha, Guayas, Morona Santiago}
x={Manab, Azuay, Tungurahua}
4)x={Pichincha, Guayas, Morona Santiago}
x={Manab, Azuay, Tungurahua}
x={Cotopaxi}
5)x={Pichincha, Guayas, Morona Santiago, Sucumbos}
x={Manab, Azuay, Tungurahua}
x={Cotopaxi}
6)x={Pichincha, Guayas, Morona Santiago, Bolvar, Carchi, Fco. Orellana, Loja}
x={Manab, Azuay, Tungurahua, Imbabura}
x={Cotopaxi, Sucumbos, Esmeraldas, Pastaza, Caar, Zamora Chimchipe, El Oro, Sta. Elena}
x={Napo, Sto. Domingo, Chimborazo, Galpagos}
TEMA 3



Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
DataGridView1.RowCount = 7
DataGridView1.ColumnCount = 6
DataGridView2.RowCount = 6
DataGridView2.ColumnCount = 6

For i = 0 To 5
For j = 0 To 5
DataGridView1.Item(i, i).Value = 0
DataGridView2.Item(i, i).Value = 0
Next
Next
For j = 0 To 5
DataGridView1.Item(j, 6).Value = 0
Next

'etiqueta colum
DataGridView1.Columns(0).Name = "A"
DataGridView1.Columns(1).Name = "B"
DataGridView1.Columns(2).Name = "C"
DataGridView1.Columns(3).Name = "D"
DataGridView1.Columns(4).Name = "E"
DataGridView1.Columns(5).Name = "F"
'etiqueta filas
DataGridView1.Rows(0).HeaderCell.Value = "A"
DataGridView1.Rows(1).HeaderCell.Value = "B"
DataGridView1.Rows(2).HeaderCell.Value = "C"
DataGridView1.Rows(3).HeaderCell.Value = "D"
DataGridView1.Rows(4).HeaderCell.Value = "E"
DataGridView1.Rows(5).HeaderCell.Value = "F"
DataGridView1.Rows(6).HeaderCell.Value = "GRADOS"

'etiqueta colum
DataGridView2.Columns(0).Name = "A"
DataGridView2.Columns(1).Name = "B"
DataGridView2.Columns(2).Name = "C"
DataGridView2.Columns(3).Name = "D"
DataGridView2.Columns(4).Name = "E"
DataGridView2.Columns(5).Name = "F"
'etiqueta filas
DataGridView2.Rows(0).HeaderCell.Value = "A"
DataGridView2.Rows(1).HeaderCell.Value = "B"
DataGridView2.Rows(2).HeaderCell.Value = "C"
DataGridView2.Rows(3).HeaderCell.Value = "D"
DataGridView2.Rows(4).HeaderCell.Value = "E"
DataGridView2.Rows(5).HeaderCell.Value = "F"


For i = 0 To 5
Dim column As DataGridViewColumn =
DataGridView1.Columns(i)
column.Width = 30
Dim columna As DataGridViewColumn =
DataGridView2.Columns(i)
columna.Width = 30
Next i

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button3.Click
Me.Close()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button2.Click
For j = 0 To 5
For i = 0 To 5
DataGridView1.Item(j, 6).Value =
DataGridView1.Item(j, 6).Value + DataGridView1.Item(j, i).Value
Next
Next



End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button4.Click

For j = 0 To 5
For i = 0 To 5
DataGridView1.Item(j, i).Value =
DataGridView1.Item(i, j).Value
Next
Next

For j = 0 To 5
For i = 0 To 5
If DataGridView1.Item(j, i).Value = 1 Then
DataGridView2.Item(j, i).Value = "No"
DataGridView2.Item(i, j).Value =
DataGridView2.Item(j, i).Value
End If
Next
Next

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click



Dim vec1(6) As Integer
Dim aux As Integer = 0
Dim cmd As Integer = 0
Dim menor As Integer

For i = 0 To 5
vec1(i) = DataGridView1.Item(i, 6).Value
Next

menor = 20000
For i = 0 To 5
If vec1(i) < menor Then
menor = vec1(i)
cmd = i
End If
Next

For i = 0 To 6
For j = 0 To 5
If vec1(j) < vec1(j + 1) Then
aux = vec1(j)
vec1(j) = vec1(j + 1)
vec1(j + 1) = aux
End If
Next j
Next i



For i = 0 To 5
ListBox1.Items.Add(vec1(i))
Next

ListBox2.Items.Add(cmd + 1)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button5.Click
Dim a As String = TextBox1.Text

ListBox3.Items.Add(a)
End Sub
End Class
















TEMA 4
clc;
clear;

acum=0;
f=7;
c=1;
while acum<f

if acum<f

f=input ('Numero de filas de la matriz A:');
c=input ('NUmero de columnas de la matriz A:');
a=zeros (f:c);

end

if acum<f
for i=1:f
for j=1:c
fprintf ('ingrese los nuevos valores de la
matriz A posicion: % d,% d \n',i,j)
a (i,j)=input ('');
end
end
end

a

if c==1
co=c;
anueva=zeros (f,c);

for i=1:f
for j=1:c
anueva (i,j)=a (i,j);
end
end
end


for i=1:c
fprintf ('ingrese el costo % d \n', i);
costos (i)=input ('');
end
costos

for i=1:c
uno (i)=0;
end

for i=1:c
for j=1:f
uno (i)=uno (i)+a (j,i);
end
end

uno


for i=1:c
cmas (i)=costos (i)/uno(i);
end
cmas


aux=1000;
p=0;
for i=1:c
if cmas (i)<aux
aux=cmas (i);
p=i;
end
end

fprintf ('la columna que debe eliminar es % d \n',p);
if c==1
for i=1:c
equis (c)=0;
end
end

posicion=input ('indique el inidice de X que tomara el
valor de 1');
equis (posicion)=1;
equis


rev=ao*equis'
acum=0;

for i=1:f
acum=acum+rev (i);
end

acum
c=c+1;

if acum<co
fprintf (Ingresar la matriz A eliminando la columna
que se le indico y las filas donde encuentre 1\n');
end
% if acum<f
% f=input ('Numero de filas de la matriz A:');
% c=input (Numero de columnas de la matriz A:');
% a=(f:c);
%
% end
%
% if acum<f
% for i=1:f
% for j=1:c
% fprintf ('Ingresar los valores de la nueva
matriz A posicion: % d,% d \n',i,j)
% a (i,j)=input ('');
% end
% end
% end
% a
end


















TEMA 5


a)













b) i) Vecino ms cercano (nodo inicial 3)
Nodo 3
e(3,1), e(3,2), e(3,4), e(3,5), e(3,6), e(3,7), e(3,8)
4 12 3 2 1 7 6 Min=e(3,6)=1 x={3,6}
Nodo 6
e(6,1), e(6,2), e(6,4), e(6,5), e(6,7), e(6,8)
6 5 10 9 5 10 Min=e(6,2)=5 x={3,6,2}
Nodo 2
e(2,1), e(2,4), e(2,5), e(2,7), e(2,8)
3 9 7 6 1 Min=e(2,8)=1 x={3,6,2,8}
Nodo 8
e(8,1), e(8,4), e(8,5), e(8,7)
5 7 2 4 Min=e(8,5)=2 x={3,6,2,8,5}
Nodo 5
e(5,1), e(5,4), e(5,7)
8 11 3 Min=e(5,7)=3 x={3,6,2,8,5,7}

Nodo 7
e(7,1), e(7,4)
4 8 Min=e(7,1)=4 x={3,6,2,8,5,7,1}

x={3,6,2,8,5,7,1,4,3}

z=1+5+1+2+3+4+10+3= 29















b) ii) Cadenas sin sub-ciclos
Ordenar de menor a mayor los nodos:
e(2,3)e(4,5) e(1,4) e(4,6) e(6,8) e(2,4) e(1,5) e(4,7) e(2,5) e(3,7)
e(4,8) e(1,6) e(2,7), e(3,8) e(1,8) e(2,6) e(6,7) e(1,3) e(1,7) e(7,8)
e(1,2) e(3,4) e(1,7) e(5,7) e(3,5) e(2,8) e(3,6)


















b) iii) Insecin con la terna inicial 1-3-5










P=6










(i,j) D6(i,j) Resultado
(1,3) c16+c63-c13=6+1-4 3
(1,5) c16+c65-c15=6+6-8 4
(3,5) C36+c65-c35=1+9-2 8






P=8



d(k) Minimo Resultado
d(2) Min(d21,d23,d25)=Min(3,12,7) 3
d(4) Min(d41,d43,d45)=Min(10,3,11) 3
d(6) Min(d61,d63,d65)=Min(6,1,9) 1
d(7) Min(d71,d73,d75)=Min(4,7,3) 3
d(8) Min(d81,d83,d85)=Min(5,6,2) 2
d(k) Minimo Resultado
d(2) Min(d21,d23,d25,d26)=Min(3,12,7,5) 3
d(4) Min(d41,d43,d45,d46)=Min(10,3,11,10) 3
d(7) Min(d71,d73,d75,d76)=Min(4,7,3,5) 3
d(8) Min(d81,d83,d85,d86)=Min(5,6,2,10) 2







(i,j) D8(i,j) Resultado
(1,6) c18+c84-c14 9
(6,3) c18+c85-c15 15
(3,5) C38+c84-c34 6
(1,5) C38+c85-c35 -1

















d(k) Minimo Resultado
d(2) Min(d21,d23,d25,d26,d28)=Min(3,12,7,5,1) 1
d(4) Min(d41,d43,d45,d46,d48)=Min(10,3,11,10,7) 3
d(7) Min(d71,d73,d75,d76,d78)=Min(4,7,3,5,4) 4
(i,j) D2(i,j) Resultado
(1,6) c12+c24-c14 12
(6,3) c12+c25-c15 16
(1,8) C32+c24-c34 -1
(8,5) C82+c25-c85 6
(3,5) C32+c25-c35 17












d(k) Minimo Resultado
d(4) Min(d41,d43,d45,d46,d48,d42) 3
d(7) Min(d41,d43,d45,d46,d48,d42) 3
(i,j) D4(i,j) Resultado
(1,6) c14+c64-c16 14
(1,2) c14+c24-c12 16
(3,5) C34+c54-c35 12
(6,3) C64+c34-c63 12
(2,8) C24+c84-c28 15
(8,5) C84+c54-c85 16
(i,j) D7(i,j) Resultado
(1,2) c17+c247-c12 7
(2,8) C27+c87-c28 9
(6,3) C67+c37-c63 11
(3,4) C37+c47-c34 12
(1,6) C17+c67-c16 3
(8,5) C87+c57-c85 5
(4,5) C47+c57-c45 0

You might also like