00001
'***************************************************************00002
'* *00003
'* GRAFOS http://ttt.upv.es/~arodrigu/grafos/ *00004
'* *00005
'* Software para la construcción y análisis de grafos *00006
'* *00007
'* *00008
'* (cc) 2003..2005 Alejandro Rodríguez Villalobos *00009
'* *00010
'* Creative Commons License *00011
'* Reconocimiento-NoComercial-CompartirIgual 2.1 *00012
'* http://ttt.upv.es/~arodrigu/grafos/http://creativecommons.org/licenses/by-nc-sa/3.0/deed.es*» *
00013
'* *00014
'***************************************************************00015
00016
'Advertencia: este programa está protegido por las leyes de derechos de autor00017
'y otros tratados internacionales. Grafos es un software libre y gratuito. Se00018
'distribuye bajo las condiciones:Reconocimiento-NoComercial-CompartirIgual 2.1.00019
'(Creative Commons License). La comercialización sin consentimiento del autor00020
'de este programa o cualquier parte del mismo, está penada por la ley con00021
'severas sanciones civiles y penales, y será objeto de todas las acciones00022
'judiciales que correspondan." & vbcrlf & "Grafos incluye la librería lp_solve00023
'5.x Copyright 1991, 2005 Free Software Foundation, Inc. bajo licencia LGPL.00024
00025
00026
00027
'Importa espacio de nombres de lp_solve500028
Imports Grafos . lpsolve5100029
00030
00031
'Para las funciones de apertura/escritura de ficheros00032
Imports System . IO00033
Imports System . Xml00034
'Imports System.Runtime.Serialization.Formatters.Soap00035
'Imports System.Runtime.Serialization.Formatters.Binary00036
00037
00038
'pruebas con otro solver00039
'Imports Grafos.QSopt100040
00041
00042
Public Class Form100043
Inherits System . Windows . Forms . Form00044
'declaración global para lp_solve 500045
'Private lpsolve As lpsolve5100046
00047
# Region " Código generado por el Diseñador de Windows Forms "00048
00049
Public Sub New ()00050
MyBase . New ()00051
00052
'El Diseñador de Windows Forms requiere esta llamada.00053
InitializeComponent ()00054
00055
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00056
00057
00058
00059
'Inicialización del Solver lp_solver 500060
'lpsolve = New lpsolve5100061
00062
System . Diagnostics . Debug . WriteLine ( CurDir ())00063
'lpsolve.Init(".")00064
00065
00066
00067
00068
00069
00070
00071
00072
End Sub00073
00074
'Form reemplaza a Dispose para limpiar la lista de componentes.00075
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00076
If disposing Then00077
If Not ( components Is Nothing ) Then00078
components . Dispose ()00079
End If00080
End If00081
MyBase . Dispose ( disposing )00082
End Sub00083
00084
'Requerido por el Diseñador de Windows Forms00085
Private components As System . ComponentModel . IContainer00086
00087
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00088
'Puede modificarse utilizando el Diseñador de Windows Forms.00089
'No lo modifique con el editor de código.00090
Friend WithEvents MainMenu1 As System . Windows . Forms . MainMenu00091
Friend WithEvents MenuItem1 As System . Windows . Forms . MenuItem00092
Friend WithEvents mnuEdicion As System . Windows . Forms . MenuItem00093
Friend WithEvents mnuFormato As System . Windows . Forms . MenuItem00094
Friend WithEvents mnuAnalisis As System . Windows . Forms . MenuItem00095
Friend WithEvents MenuItem5 As System . Windows . Forms . MenuItem00096
Friend WithEvents mnuArchivoNuevo As System . Windows . Forms . MenuItem00097
Friend WithEvents mnuArchivoAbrir As System . Windows . Forms . MenuItem00098
Friend WithEvents MenuItem8 As System . Windows . Forms . MenuItem00099
Friend WithEvents mnuArchivoGuardar As System . Windows . Forms . MenuItem00100
Friend WithEvents mnuArchivoGuardarComo As System . Windows . Forms . MenuItem00101
Friend WithEvents MenuItem11 As System . Windows . Forms . MenuItem00102
Friend WithEvents mnuArchivoSalir As System . Windows . Forms . MenuItem00103
Friend WithEvents mnuEdicionGrafica As System . Windows . Forms . MenuItem00104
Friend WithEvents mnuFormatoOpciones As System . Windows . Forms . MenuItem00105
Friend WithEvents PictureBox1 As System . Windows . Forms . PictureBox00106
Friend WithEvents PanelX As System . Windows . Forms . StatusBarPanel00107
Friend WithEvents PanelY As System . Windows . Forms . StatusBarPanel00108
Friend WithEvents StatusBar As System . Windows . Forms . StatusBar00109
Friend WithEvents Panel1 As System . Windows . Forms . Panel00110
Friend WithEvents mnuFormatoRejilla As System . Windows . Forms . MenuItem00111
Friend WithEvents mnuFormatoIman As System . Windows . Forms . MenuItem00112
Friend WithEvents MenuItem19 As System . Windows . Forms . MenuItem00113
Friend WithEvents mnuAyudaAcercade As System . Windows . Forms . MenuItem00114
Friend WithEvents mnuArchivoImprimir As System . Windows . Forms . MenuItem00115
Friend WithEvents mnuEdicion2 As System . Windows . Forms . MenuItem00116
Friend WithEvents PrintDialog1 As System . Windows . Forms . PrintDialog00117
Friend WithEvents PrintPreviewDialog1 As System . Windows . Forms .» PrintPreviewDialog
00118
Friend WithEvents mnuArchivoConfigurarPag As System . Windows . Forms . MenuItem00119
Friend WithEvents PrintDocument1 As System . Drawing . Printing . PrintDocument00120
Friend WithEvents PageSetupDialog1 As System . Windows . Forms . PageSetupDialog00121
Friend WithEvents mnuArchivoConfigurarImp As System . Windows . Forms . MenuItem00122
Friend WithEvents SobreObj As System . Windows . Forms . StatusBarPanel00123
Friend WithEvents Nd1 As System . Windows . Forms . StatusBarPanel00124
Friend WithEvents Nd2 As System . Windows . Forms . StatusBarPanel00125
Friend WithEvents mnuPopUp As System . Windows . Forms . ContextMenu00126
Friend WithEvents mnuAñadirNodo As System . Windows . Forms . MenuItem00127
Friend WithEvents mnuEditarNodo As System . Windows . Forms . MenuItem00128
Friend WithEvents mnuBorrarNodo As System . Windows . Forms . MenuItem00129
Friend WithEvents mnuEdicion4 As System . Windows . Forms . MenuItem00130
Friend WithEvents mnuAñadirArco As System . Windows . Forms . MenuItem00131
Friend WithEvents mnuEdicion8 As System . Windows . Forms . MenuItem00132
Friend WithEvents mnuZoomMas As System . Windows . Forms . MenuItem00133
Friend WithEvents mnuZoomMenos As System . Windows . Forms . MenuItem00134
Friend WithEvents mnuZoomAjustar As System . Windows . Forms . MenuItem00135
Friend WithEvents mnuEditarArco As System . Windows . Forms . MenuItem00136
Friend WithEvents mnuBorrarArco As System . Windows . Forms . MenuItem00137
Friend WithEvents z As System . Windows . Forms . StatusBarPanel00138
Friend WithEvents mnuArchivoCopiarImg As System . Windows . Forms . MenuItem00139
Friend WithEvents mnuArchivoExportarImg As System . Windows . Forms . MenuItem00140
Friend WithEvents TextBox1 As System . Windows . Forms . TextBox00141
Friend WithEvents mnuEdicionTabular As System . Windows . Forms . MenuItem00142
Friend WithEvents mnuPopTabla As System . Windows . Forms . ContextMenu00143
Friend WithEvents mnuTablaBorrarNodo As System . Windows . Forms . MenuItem00144
Friend WithEvents mnuTablaAñadirNodo As System . Windows . Forms . MenuItem00145
Friend WithEvents mnuTablaTotalNodos As System . Windows . Forms . MenuItem00146
Friend WithEvents MenuItem2 As System . Windows . Forms . MenuItem00147
Friend WithEvents hfgTabla As AxMSFlexGridLib . AxMSFlexGrid00148
Friend WithEvents MenuItem6 As System . Windows . Forms . MenuItem00149
Friend WithEvents mnuFormatoCircular As System . Windows . Forms . MenuItem00150
Friend WithEvents mnuFormatoAleatorio As System . Windows . Forms . MenuItem00151
Friend WithEvents mnuFormatoTablero As System . Windows . Forms . MenuItem00152
Friend WithEvents MenuItem3 As System . Windows . Forms . MenuItem00153
Friend WithEvents mnuTablaCopiarTabla As System . Windows . Forms . MenuItem00154
Friend WithEvents mnuAlinearNodos As System . Windows . Forms . MenuItem00155
Friend WithEvents mnuAlinearNodosH As System . Windows . Forms . MenuItem00156
Friend WithEvents mnuAlinearNodosV As System . Windows . Forms . MenuItem00157
Friend WithEvents mnuAnalisisDijkstra As System . Windows . Forms . MenuItem00158
Friend WithEvents mnuAnalisisDijkstraMax As System . Windows . Forms . MenuItem00159
Friend WithEvents mnuAnalisisDijkstraCC As System . Windows . Forms . MenuItem00160
Friend WithEvents mnuAnalisisDijkstraCM As System . Windows . Forms . MenuItem00161
Friend WithEvents MenuItem4 As System . Windows . Forms . MenuItem00162
Friend WithEvents MenuItem7 As System . Windows . Forms . MenuItem00163
Friend WithEvents mnuAnalisisBellmanFordCmin As System . Windows . Forms . MenuItem00164
Friend WithEvents mnuAnalisisBellmanFordCmax As System . Windows . Forms . MenuItem00165
Friend WithEvents MenuItem9 As System . Windows . Forms . MenuItem00166
Friend WithEvents mnuAnalisisKruskalmin As System . Windows . Forms . MenuItem00167
Friend WithEvents mnuAnalisisKruskalmax As System . Windows . Forms . MenuItem00168
Friend WithEvents mnuFormatoFlujo As System . Windows . Forms . MenuItem00169
Friend WithEvents MenuItem10 As System . Windows . Forms . MenuItem00170
Friend WithEvents mnuAnalisisPrimMin As System . Windows . Forms . MenuItem00171
Friend WithEvents mnuAnalisisPrimMax As System . Windows . Forms . MenuItem00172
Friend WithEvents MenuItem12 As System . Windows . Forms . MenuItem00173
Friend WithEvents mnuFormatoAjustar As System . Windows . Forms . MenuItem00174
Friend WithEvents mnuFormatoCentrar As System . Windows . Forms . MenuItem00175
Friend WithEvents MenuItem15 As System . Windows . Forms . MenuItem00176
Friend WithEvents mnuAnalisisFordFulkersonMax As System . Windows . Forms .» MenuItem
00177
Friend WithEvents MenuItem13 As System . Windows . Forms . MenuItem00178
Friend WithEvents mnuAnalisisFloydWarshallmin As System . Windows . Forms .» MenuItem
00179
Friend WithEvents MenuItem14 As System . Windows . Forms . MenuItem00180
Friend WithEvents mnuAnalisis_Transbordo As System . Windows . Forms . MenuItem00181
'Friend WithEvents mnuAnalisis_Transporte As System.Windows.Forms.MenuItem00182
Friend WithEvents mnuAnalisis_TSP As System . Windows . Forms . MenuItem00183
Friend WithEvents mnuFormatoOrganico As System . Windows . Forms . MenuItem00184
Friend WithEvents mnuFormatoImantar As System . Windows . Forms . MenuItem00185
Friend WithEvents mnuArchivoImportarDatos As System . Windows . Forms . MenuItem00186
Friend WithEvents mnuArchivoExportarDatos As System . Windows . Forms . MenuItem00187
Friend WithEvents MenuItem20 As System . Windows . Forms . MenuItem00188
Friend WithEvents mnuArchivoNuevoAleatorio As System . Windows . Forms . MenuItem00189
Friend WithEvents filestatusbar As System . Windows . Forms . StatusBarPanel00190
Friend WithEvents mnuFormatoAutoRadio As System . Windows . Forms . MenuItem00191
Friend WithEvents mnuFormatoAutoTrazo As System . Windows . Forms . MenuItem00192
Friend WithEvents MenuItem18 As System . Windows . Forms . MenuItem00193
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00194
Dim resources As System . Resources . ResourceManager = New System . Resources» . ResourceManager ( GetType ( Form1 ))
00195
Me . MainMenu1 = New System . Windows . Forms . MainMenu00196
Me . MenuItem1 = New System . Windows . Forms . MenuItem00197
Me . mnuArchivoNuevo = New System . Windows . Forms . MenuItem00198
Me . mnuArchivoNuevoAleatorio = New System . Windows . Forms . MenuItem00199
Me . mnuArchivoAbrir = New System . Windows . Forms . MenuItem00200
Me . mnuArchivoImportarDatos = New System . Windows . Forms . MenuItem00201
Me . MenuItem8 = New System . Windows . Forms . MenuItem00202
Me . mnuArchivoGuardar = New System . Windows . Forms . MenuItem00203
Me . mnuArchivoGuardarComo = New System . Windows . Forms . MenuItem00204
Me . mnuArchivoExportarDatos = New System . Windows . Forms . MenuItem00205
Me . MenuItem20 = New System . Windows . Forms . MenuItem00206
Me . mnuArchivoCopiarImg = New System . Windows . Forms . MenuItem00207
Me . mnuArchivoExportarImg = New System . Windows . Forms . MenuItem00208
Me . mnuEdicion2 = New System . Windows . Forms . MenuItem00209
Me . mnuArchivoConfigurarImp = New System . Windows . Forms . MenuItem00210
Me . mnuArchivoConfigurarPag = New System . Windows . Forms . MenuItem00211
Me . mnuArchivoImprimir = New System . Windows . Forms . MenuItem00212
Me . MenuItem11 = New System . Windows . Forms . MenuItem00213
Me . mnuArchivoSalir = New System . Windows . Forms . MenuItem00214
Me . mnuEdicion = New System . Windows . Forms . MenuItem00215
Me . mnuEdicionGrafica = New System . Windows . Forms . MenuItem00216
Me . mnuEdicionTabular = New System . Windows . Forms . MenuItem00217
Me . mnuFormato = New System . Windows . Forms . MenuItem00218
Me . mnuFormatoOpciones = New System . Windows . Forms . MenuItem00219
Me . MenuItem19 = New System . Windows . Forms . MenuItem00220
Me . mnuFormatoRejilla = New System . Windows . Forms . MenuItem00221
Me . mnuFormatoIman = New System . Windows . Forms . MenuItem00222
Me . MenuItem15 = New System . Windows . Forms . MenuItem00223
Me . mnuFormatoCentrar = New System . Windows . Forms . MenuItem00224
Me . mnuFormatoAjustar = New System . Windows . Forms . MenuItem00225
Me . mnuFormatoImantar = New System . Windows . Forms . MenuItem00226
Me . MenuItem18 = New System . Windows . Forms . MenuItem00227
Me . mnuFormatoAutoRadio = New System . Windows . Forms . MenuItem00228
Me . mnuFormatoAutoTrazo = New System . Windows . Forms . MenuItem00229
Me . MenuItem6 = New System . Windows . Forms . MenuItem00230
Me . mnuFormatoAleatorio = New System . Windows . Forms . MenuItem00231
Me . mnuFormatoCircular = New System . Windows . Forms . MenuItem00232
Me . mnuFormatoTablero = New System . Windows . Forms . MenuItem00233
Me . mnuFormatoFlujo = New System . Windows . Forms . MenuItem00234
Me . mnuFormatoOrganico = New System . Windows . Forms . MenuItem00235
Me . mnuAnalisis = New System . Windows . Forms . MenuItem00236
Me . mnuAnalisisDijkstra = New System . Windows . Forms . MenuItem00237
Me . mnuAnalisisDijkstraMax = New System . Windows . Forms . MenuItem00238
Me . MenuItem4 = New System . Windows . Forms . MenuItem00239
Me . mnuAnalisisDijkstraCM = New System . Windows . Forms . MenuItem00240
Me . mnuAnalisisDijkstraCC = New System . Windows . Forms . MenuItem00241
Me . MenuItem7 = New System . Windows . Forms . MenuItem00242
Me . mnuAnalisisBellmanFordCmin = New System . Windows . Forms . MenuItem00243
Me . mnuAnalisisBellmanFordCmax = New System . Windows . Forms . MenuItem00244
Me . MenuItem13 = New System . Windows . Forms . MenuItem00245
Me . mnuAnalisisFloydWarshallmin = New System . Windows . Forms . MenuItem00246
Me . MenuItem9 = New System . Windows . Forms . MenuItem00247
Me . mnuAnalisisKruskalmin = New System . Windows . Forms . MenuItem00248
Me . mnuAnalisisKruskalmax = New System . Windows . Forms . MenuItem00249
Me . MenuItem10 = New System . Windows . Forms . MenuItem00250
Me . mnuAnalisisPrimMin = New System . Windows . Forms . MenuItem00251
Me . mnuAnalisisPrimMax = New System . Windows . Forms . MenuItem00252
Me . MenuItem12 = New System . Windows . Forms . MenuItem00253
Me . mnuAnalisisFordFulkersonMax = New System . Windows . Forms . MenuItem00254
Me . MenuItem14 = New System . Windows . Forms . MenuItem00255
Me . mnuAnalisis_Transbordo = New System . Windows . Forms . MenuItem00256
Me . mnuAnalisis_TSP = New System . Windows . Forms . MenuItem00257
Me . MenuItem5 = New System . Windows . Forms . MenuItem00258
Me . mnuAyudaAcercade = New System . Windows . Forms . MenuItem00259
Me . StatusBar = New System . Windows . Forms . StatusBar00260
Me . PanelX = New System . Windows . Forms . StatusBarPanel00261
Me . PanelY = New System . Windows . Forms . StatusBarPanel00262
Me . SobreObj = New System . Windows . Forms . StatusBarPanel00263
Me . Nd1 = New System . Windows . Forms . StatusBarPanel00264
Me . Nd2 = New System . Windows . Forms . StatusBarPanel00265
Me . z = New System . Windows . Forms . StatusBarPanel00266
Me . filestatusbar = New System . Windows . Forms . StatusBarPanel00267
Me . PictureBox1 = New System . Windows . Forms . PictureBox00268
Me . mnuPopUp = New System . Windows . Forms . ContextMenu00269
Me . mnuAñadirNodo = New System . Windows . Forms . MenuItem00270
Me . mnuEditarNodo = New System . Windows . Forms . MenuItem00271
Me . mnuBorrarNodo = New System . Windows . Forms . MenuItem00272
Me . mnuAlinearNodos = New System . Windows . Forms . MenuItem00273
Me . mnuAlinearNodosH = New System . Windows . Forms . MenuItem00274
Me . mnuAlinearNodosV = New System . Windows . Forms . MenuItem00275
Me . mnuEdicion4 = New System . Windows . Forms . MenuItem00276
Me . mnuAñadirArco = New System . Windows . Forms . MenuItem00277
Me . mnuEditarArco = New System . Windows . Forms . MenuItem00278
Me . mnuBorrarArco = New System . Windows . Forms . MenuItem00279
Me . mnuEdicion8 = New System . Windows . Forms . MenuItem00280
Me . mnuZoomMas = New System . Windows . Forms . MenuItem00281
Me . mnuZoomMenos = New System . Windows . Forms . MenuItem00282
Me . mnuZoomAjustar = New System . Windows . Forms . MenuItem00283
Me . Panel1 = New System . Windows . Forms . Panel00284
Me . TextBox1 = New System . Windows . Forms . TextBox00285
Me . mnuPopTabla = New System . Windows . Forms . ContextMenu00286
Me . mnuTablaAñadirNodo = New System . Windows . Forms . MenuItem00287
Me . mnuTablaBorrarNodo = New System . Windows . Forms . MenuItem00288
Me . MenuItem2 = New System . Windows . Forms . MenuItem00289
Me . mnuTablaTotalNodos = New System . Windows . Forms . MenuItem00290
Me . MenuItem3 = New System . Windows . Forms . MenuItem00291
Me . mnuTablaCopiarTabla = New System . Windows . Forms . MenuItem00292
Me . hfgTabla = New AxMSFlexGridLib . AxMSFlexGrid00293
Me . PrintDialog1 = New System . Windows . Forms . PrintDialog00294
Me . PrintPreviewDialog1 = New System . Windows . Forms . PrintPreviewDialog00295
Me . PrintDocument1 = New System . Drawing . Printing . PrintDocument00296
CType ( Me . PanelX , System . ComponentModel . ISupportInitialize ) . BeginInit ()00297
CType ( Me . PanelY , System . ComponentModel . ISupportInitialize ) . BeginInit ()00298
CType ( Me . SobreObj , System . ComponentModel . ISupportInitialize ) . BeginInit ()00299
CType ( Me . Nd1 , System . ComponentModel . ISupportInitialize ) . BeginInit ()00300
CType ( Me . Nd2 , System . ComponentModel . ISupportInitialize ) . BeginInit ()00301
CType ( Me . z , System . ComponentModel . ISupportInitialize ) . BeginInit ()00302
CType ( Me . filestatusbar , System . ComponentModel . ISupportInitialize ) .» BeginInit ()
00303
Me . Panel1 . SuspendLayout ()00304
CType ( Me . hfgTabla , System . ComponentModel . ISupportInitialize ) . BeginInit ()00305
Me . SuspendLayout ()00306
'00307
'MainMenu100308
'00309
Me . MainMenu1 . MenuItems . AddRange ( New System . Windows . Forms . MenuItem () { Me .» MenuItem1 , Me . mnuEdicion , Me . mnuFormato , Me . mnuAnalisis , Me . MenuItem5
» })
00310
'00311
'MenuItem100312
'00313
Me . MenuItem1 . Index = 000314
Me . MenuItem1 . MenuItems . AddRange ( New System . Windows . Forms . MenuItem () { Me .» mnuArchivoNuevo , Me . mnuArchivoNuevoAleatorio , Me . mnuArchivoAbrir , Me .
» mnuArchivoImportarDatos , Me . MenuItem8 , Me . mnuArchivoGuardar , Me .
» mnuArchivoGuardarComo , Me . mnuArchivoExportarDatos , Me . MenuItem20 , Me .
» mnuArchivoCopiarImg , Me . mnuArchivoExportarImg , Me . mnuEdicion2 , Me .
» mnuArchivoConfigurarImp , Me . mnuArchivoConfigurarPag , Me .
» mnuArchivoImprimir , Me . MenuItem11 , Me . mnuArchivoSalir })
00315
Me . MenuItem1 . Text = "&Archivo"00316
'00317
'mnuArchivoNuevo00318
'00319
Me . mnuArchivoNuevo . Index = 000320
Me . mnuArchivoNuevo . Shortcut = System . Windows . Forms . Shortcut . CtrlU00321
Me . mnuArchivoNuevo . Text = "&Nuevo"00322
'00323
'mnuArchivoNuevoAleatorio00324
'00325
Me . mnuArchivoNuevoAleatorio . Index = 100326
Me . mnuArchivoNuevoAleatorio . Text = "Crear alea&torio..."00327
'00328
'mnuArchivoAbrir00329
'00330
Me . mnuArchivoAbrir . Index = 200331
Me . mnuArchivoAbrir . Shortcut = System . Windows . Forms . Shortcut . CtrlA00332
Me . mnuArchivoAbrir . Text = "&Abrir"00333
'00334
'mnuArchivoImportarDatos00335
'00336
Me . mnuArchivoImportarDatos . Enabled = False00337
Me . mnuArchivoImportarDatos . Index = 300338
Me . mnuArchivoImportarDatos . Text = "I&mportar datos..."00339
'00340
'MenuItem800341
'00342
Me . MenuItem8 . Index = 400343
Me . MenuItem8 . Text = "-"00344
'00345
'mnuArchivoGuardar00346
'00347
Me . mnuArchivoGuardar . Enabled = False00348
Me . mnuArchivoGuardar . Index = 500349
Me . mnuArchivoGuardar . Shortcut = System . Windows . Forms . Shortcut . CtrlG00350
Me . mnuArchivoGuardar . Text = "&Guardar"00351
'00352
'mnuArchivoGuardarComo00353
'00354
Me . mnuArchivoGuardarComo . Enabled = False00355
Me . mnuArchivoGuardarComo . Index = 600356
Me . mnuArchivoGuardarComo . Text = "G&uardar como..."00357
'00358
'mnuArchivoExportarDatos00359
'00360
Me . mnuArchivoExportarDatos . Enabled = False00361
Me . mnuArchivoExportarDatos . Index = 700362
Me . mnuArchivoExportarDatos . Text = "Exportar &datos..."00363
'00364
'MenuItem2000365
'00366
Me . MenuItem20 . Index = 800367
Me . MenuItem20 . Text = "-"00368
'00369
'mnuArchivoCopiarImg00370
'00371
Me . mnuArchivoCopiarImg . Enabled = False00372
Me . mnuArchivoCopiarImg . Index = 900373
Me . mnuArchivoCopiarImg . Shortcut = System . Windows . Forms . Shortcut . CtrlC00374
Me . mnuArchivoCopiarImg . Text = "&Copiar imagen"00375
'00376
'mnuArchivoExportarImg00377
'00378
Me . mnuArchivoExportarImg . Enabled = False00379
Me . mnuArchivoExportarImg . Index = 1000380
Me . mnuArchivoExportarImg . Shortcut = System . Windows . Forms . Shortcut . CtrlE00381
Me . mnuArchivoExportarImg . Text = "&Exportar imagen..."00382
'00383
'mnuEdicion200384
'00385
Me . mnuEdicion2 . Index = 1100386
Me . mnuEdicion2 . Text = "-"00387
'00388
'mnuArchivoConfigurarImp00389
'00390
Me . mnuArchivoConfigurarImp . Index = 1200391
Me . mnuArchivoConfigurarImp . Text = "C&onfigurar impresora..."00392
'00393
'mnuArchivoConfigurarPag00394
'00395
Me . mnuArchivoConfigurarPag . Enabled = False00396
Me . mnuArchivoConfigurarPag . Index = 1300397
Me . mnuArchivoConfigurarPag . Text = "Con&figurar página..."00398
'00399
'mnuArchivoImprimir00400
'00401
Me . mnuArchivoImprimir . Enabled = False00402
Me . mnuArchivoImprimir . Index = 1400403
Me . mnuArchivoImprimir . Shortcut = System . Windows . Forms . Shortcut . CtrlP00404
Me . mnuArchivoImprimir . Text = "&Imprimir..."00405
'00406
'MenuItem1100407
'00408
Me . MenuItem11 . Index = 1500409
Me . MenuItem11 . Text = "-"00410
'00411
'mnuArchivoSalir00412
'00413
Me . mnuArchivoSalir . Index = 1600414
Me . mnuArchivoSalir . Text = "&Salir"00415
'00416
'mnuEdicion00417
'00418
Me . mnuEdicion . Enabled = False00419
Me . mnuEdicion . Index = 100420
Me . mnuEdicion . MenuItems . AddRange ( New System . Windows . Forms . MenuItem () { Me» . mnuEdicionGrafica , Me . mnuEdicionTabular })
00421
Me . mnuEdicion . Text = "&Edición"00422
'00423
'mnuEdicionGrafica00424
'00425
Me . mnuEdicionGrafica . Checked = True00426
Me . mnuEdicionGrafica . Index = 000427
Me . mnuEdicionGrafica . RadioCheck = True00428
Me . mnuEdicionGrafica . Text = "&Gráfica"00429
'00430
'mnuEdicionTabular00431
'00432
Me . mnuEdicionTabular . Index = 100433
Me . mnuEdicionTabular . RadioCheck = True00434
Me . mnuEdicionTabular . Text = "&Tabular"00435
'00436
'mnuFormato00437
'00438
Me . mnuFormato . Enabled = False00439
Me . mnuFormato . Index = 200440
Me . mnuFormato . MenuItems . AddRange ( New System . Windows . Forms . MenuItem () { Me» . mnuFormatoOpciones , Me . MenuItem19 , Me . mnuFormatoRejilla , Me .
» mnuFormatoIman , Me . MenuItem15 , Me . mnuFormatoCentrar , Me .
» mnuFormatoAjustar , Me . mnuFormatoImantar , Me . MenuItem18 , Me .
» mnuFormatoAutoRadio , Me . mnuFormatoAutoTrazo , Me . MenuItem6 , Me .
» mnuFormatoAleatorio , Me . mnuFormatoCircular , Me . mnuFormatoTablero , Me .
» mnuFormatoFlujo , Me . mnuFormatoOrganico })
00441
Me . mnuFormato . Text = "&Formato"00442
'00443
'mnuFormatoOpciones00444
'00445
Me . mnuFormatoOpciones . Enabled = False00446
Me . mnuFormatoOpciones . Index = 000447
Me . mnuFormatoOpciones . Shortcut = System . Windows . Forms . Shortcut . CtrlO00448
Me . mnuFormatoOpciones . Text = "&Opciones..."00449
'00450
'MenuItem1900451
'00452
Me . MenuItem19 . Index = 100453
Me . MenuItem19 . Text = "-"00454
'00455
'mnuFormatoRejilla00456
'00457
Me . mnuFormatoRejilla . Checked = True00458
Me . mnuFormatoRejilla . Index = 200459
Me . mnuFormatoRejilla . Shortcut = System . Windows . Forms . Shortcut . CtrlR00460
Me . mnuFormatoRejilla . Text = "&Rejilla"00461
'00462
'mnuFormatoIman00463
'00464
Me . mnuFormatoIman . Checked = True00465
Me . mnuFormatoIman . Index = 300466
Me . mnuFormatoIman . Shortcut = System . Windows . Forms . Shortcut . CtrlI00467
Me . mnuFormatoIman . Text = "&Imán"00468
'00469
'MenuItem1500470
'00471
Me . MenuItem15 . Index = 400472
Me . MenuItem15 . Text = "-"00473
'00474
'mnuFormatoCentrar00475
'00476
Me . mnuFormatoCentrar . Index = 500477
Me . mnuFormatoCentrar . Text = "&Centrar grafo"00478
'00479
'mnuFormatoAjustar00480
'00481
Me . mnuFormatoAjustar . Index = 600482
Me . mnuFormatoAjustar . Text = "&Ajustar tapiz"00483
'00484
'mnuFormatoImantar00485
'00486
Me . mnuFormatoImantar . Index = 700487
Me . mnuFormatoImantar . Text = "I&mantar"00488
'00489
'MenuItem1800490
'00491
Me . MenuItem18 . Index = 800492
Me . MenuItem18 . Text = "-"00493
'00494
'mnuFormatoAutoRadio00495
'00496
Me . mnuFormatoAutoRadio . Index = 900497
Me . mnuFormatoAutoRadio . Text = "&1 Auto-radio nodos (valor)"00498
'00499
'mnuFormatoAutoTrazo00500
'00501
Me . mnuFormatoAutoTrazo . Index = 1000502
Me . mnuFormatoAutoTrazo . Text = "&2 Auto-trazo arcos (coste)"00503
'00504
'MenuItem600505
'00506
Me . MenuItem6 . Index = 1100507
Me . MenuItem6 . Text = "-"00508
'00509
'mnuFormatoAleatorio00510
'00511
Me . mnuFormatoAleatorio . Index = 1200512
Me . mnuFormatoAleatorio . RadioCheck = True00513
Me . mnuFormatoAleatorio . Text = "A&leatorio"00514
'00515
'mnuFormatoCircular00516
'00517
Me . mnuFormatoCircular . Checked = True00518
Me . mnuFormatoCircular . Index = 1300519
Me . mnuFormatoCircular . RadioCheck = True00520
Me . mnuFormatoCircular . Text = "Circ&ular"00521
'00522
'mnuFormatoTablero00523
'00524
Me . mnuFormatoTablero . Index = 1400525
Me . mnuFormatoTablero . RadioCheck = True00526
Me . mnuFormatoTablero . Text = "&Tablero"00527
'00528
'mnuFormatoFlujo00529
'00530
Me . mnuFormatoFlujo . Index = 1500531
Me . mnuFormatoFlujo . RadioCheck = True00532
Me . mnuFormatoFlujo . Text = "&Flujo"00533
'00534
'mnuFormatoOrganico00535
'00536
Me . mnuFormatoOrganico . Index = 1600537
Me . mnuFormatoOrganico . Text = "Or&gánico"00538
'00539
'mnuAnalisis00540
'00541
Me . mnuAnalisis . Enabled = False00542
Me . mnuAnalisis . Index = 300543
Me . mnuAnalisis . MenuItems . AddRange ( New System . Windows . Forms . MenuItem () {» Me . mnuAnalisisDijkstra , Me . mnuAnalisisDijkstraMax , Me . MenuItem4 , Me .
» mnuAnalisisDijkstraCM , Me . mnuAnalisisDijkstraCC , Me . MenuItem7 , Me .
» mnuAnalisisBellmanFordCmin , Me . mnuAnalisisBellmanFordCmax , Me .
» MenuItem13 , Me . mnuAnalisisFloydWarshallmin , Me . MenuItem9 , Me .
» mnuAnalisisKruskalmin , Me . mnuAnalisisKruskalmax , Me . MenuItem10 , Me .
» mnuAnalisisPrimMin , Me . mnuAnalisisPrimMax , Me . MenuItem12 , Me .
» mnuAnalisisFordFulkersonMax , Me . MenuItem14 , Me . mnuAnalisis_Transbordo
» , Me . mnuAnalisis_TSP })
00544
Me . mnuAnalisis . Text = "A&nálisis"00545
'00546
'mnuAnalisisDijkstra00547
'00548
Me . mnuAnalisisDijkstra . Enabled = False00549
Me . mnuAnalisisDijkstra . Index = 000550
Me . mnuAnalisisDijkstra . Text = "Árbol mínimo - Alg. Dijkstra (Nd1)"00551
'00552
'mnuAnalisisDijkstraMax00553
'00554
Me . mnuAnalisisDijkstraMax . Enabled = False00555
Me . mnuAnalisisDijkstraMax . Index = 100556
Me . mnuAnalisisDijkstraMax . Text = "Árbol máximo - Alg. Dijkstra (Nd1)"00557
'00558
'MenuItem400559
'00560
Me . MenuItem4 . Index = 200561
Me . MenuItem4 . Text = "-"00562
'00563
'mnuAnalisisDijkstraCM00564
'00565
Me . mnuAnalisisDijkstraCM . Enabled = False00566
Me . mnuAnalisisDijkstraCM . Index = 300567
Me . mnuAnalisisDijkstraCM . Text = "Camino mínimo - Alg. Dijkstra» (Nd1-Nd2)"
00568
'00569
'mnuAnalisisDijkstraCC00570
'00571
Me . mnuAnalisisDijkstraCC . Enabled = False00572
Me . mnuAnalisisDijkstraCC . Index = 400573
Me . mnuAnalisisDijkstraCC . Text = "Camino crítico - Alg. Dijkstra» (Nd1-Nd2)"
00574
'00575
'MenuItem700576
'00577
Me . MenuItem7 . Index = 500578
Me . MenuItem7 . Text = "-"00579
'00580
'mnuAnalisisBellmanFordCmin00581
'00582
Me . mnuAnalisisBellmanFordCmin . Enabled = False00583
Me . mnuAnalisisBellmanFordCmin . Index = 600584
Me . mnuAnalisisBellmanFordCmin . Text = "Camino mínimo - Alg. BellmanFord» (Nd1-Nd2)"
00585
'00586
'mnuAnalisisBellmanFordCmax00587
'00588
Me . mnuAnalisisBellmanFordCmax . Enabled = False00589
Me . mnuAnalisisBellmanFordCmax . Index = 700590
Me . mnuAnalisisBellmanFordCmax . Text = "Camino máximo - Alg. BellmanFord» (Nd1-Nd2)"
00591
'00592
'MenuItem1300593
'00594
Me . MenuItem13 . Index = 800595
Me . MenuItem13 . Text = "-"00596
'00597
'mnuAnalisisFloydWarshallmin00598
'00599
Me . mnuAnalisisFloydWarshallmin . Enabled = False00600
Me . mnuAnalisisFloydWarshallmin . Index = 900601
Me . mnuAnalisisFloydWarshallmin . Text = "Todos los Caminos mínimos - Alg.» FloydWarshall"
00602
'00603
'MenuItem900604
'00605
Me . MenuItem9 . Index = 1000606
Me . MenuItem9 . Text = "-"00607
'00608
'mnuAnalisisKruskalmin00609
'00610
Me . mnuAnalisisKruskalmin . Enabled = False00611
Me . mnuAnalisisKruskalmin . Index = 1100612
Me . mnuAnalisisKruskalmin . Text = "Árbol de valor total mínimo - Alg.» Kruskal"
00613
'00614
'mnuAnalisisKruskalmax00615
'00616
Me . mnuAnalisisKruskalmax . Enabled = False00617
Me . mnuAnalisisKruskalmax . Index = 1200618
Me . mnuAnalisisKruskalmax . Text = "Árbol de valor total máximo - Alg.» Kruskal"
00619
'00620
'MenuItem1000621
'00622
Me . MenuItem10 . Index = 1300623
Me . MenuItem10 . Text = "-"00624
'00625
'mnuAnalisisPrimMin00626
'00627
Me . mnuAnalisisPrimMin . Enabled = False00628
Me . mnuAnalisisPrimMin . Index = 1400629
Me . mnuAnalisisPrimMin . Text = "Árbol de valor total mínimo - Alg. Prim"00630
'00631
'mnuAnalisisPrimMax00632
'00633
Me . mnuAnalisisPrimMax . Enabled = False00634
Me . mnuAnalisisPrimMax . Index = 1500635
Me . mnuAnalisisPrimMax . Text = "Árbol de valor total máximo - Alg. Prim"00636
'00637
'MenuItem1200638
'00639
Me . MenuItem12 . Index = 1600640
Me . MenuItem12 . Text = "-"00641
'00642
'mnuAnalisisFordFulkersonMax00643
'00644
Me . mnuAnalisisFordFulkersonMax . Enabled = False00645
Me . mnuAnalisisFordFulkersonMax . Index = 1700646
Me . mnuAnalisisFordFulkersonMax . Text = "Flujo máximo - Alg. FordFulkerson» (Nd1-Nd2)"
00647
'00648
'MenuItem1400649
'00650
Me . MenuItem14 . Index = 1800651
Me . MenuItem14 . Text = "-"00652
'00653
'mnuAnalisis_Transbordo00654
'00655
Me . mnuAnalisis_Transbordo . Enabled = False00656
Me . mnuAnalisis_Transbordo . Index = 1900657
Me . mnuAnalisis_Transbordo . Text = "Transbordo a coste mínimo - LP» (equilibrado)"
00658
'00659
'mnuAnalisis_TSP00660
'00661
Me . mnuAnalisis_TSP . Enabled = False00662
Me . mnuAnalisis_TSP . Index = 2000663
Me . mnuAnalisis_TSP . Text = "Viajante de Comercio - MILP"00664
'00665
'MenuItem500666
'00667
Me . MenuItem5 . Index = 400668
Me . MenuItem5 . MenuItems . AddRange ( New System . Windows . Forms . MenuItem () { Me .» mnuAyudaAcercade })
00669
Me . MenuItem5 . Text = "Ay&uda"00670
'00671
'mnuAyudaAcercade00672
'00673
Me . mnuAyudaAcercade . Index = 000674
Me . mnuAyudaAcercade . Text = "&Acerca de..."00675
'00676
'StatusBar00677
'00678
Me . StatusBar . Location = New System . Drawing . Point ( 0 , 346 )00679
Me . StatusBar . Name = "StatusBar"00680
Me . StatusBar . Panels . AddRange ( New System . Windows . Forms . StatusBarPanel () {» Me . PanelX , Me . PanelY , Me . SobreObj , Me . Nd1 , Me . Nd2 , Me . z , Me .
» filestatusbar })
00681
Me . StatusBar . ShowPanels = True00682
Me . StatusBar . Size = New System . Drawing . Size ( 624 , 16 )00683
Me . StatusBar . TabIndex = 000684
Me . StatusBar . Text = "StatusBar1"00685
'00686
'PanelX00687
'00688
Me . PanelX . BorderStyle = System . Windows . Forms . StatusBarPanelBorderStyle .» None
00689
Me . PanelX . MinWidth = 6000690
Me . PanelX . Width = 6000691
'00692
'PanelY00693
'00694
Me . PanelY . BorderStyle = System . Windows . Forms . StatusBarPanelBorderStyle .» None
00695
Me . PanelY . MinWidth = 6000696
Me . PanelY . Width = 6000697
'00698
'SobreObj00699
'00700
Me . SobreObj . BorderStyle = System . Windows . Forms . StatusBarPanelBorderStyle» . None
00701
Me . SobreObj . MinWidth = 12000702
Me . SobreObj . Width = 12000703
'00704
'Nd100705
'00706
Me . Nd1 . MinWidth = 10000707
'00708
'Nd200709
'00710
Me . Nd2 . MinWidth = 10000711
'00712
'z00713
'00714
Me . z . BorderStyle = System . Windows . Forms . StatusBarPanelBorderStyle . None00715
Me . z . MinWidth = 12000716
Me . z . Width = 12000717
'00718
'filestatusbar00719
'00720
Me . filestatusbar . AutoSize = System . Windows . Forms . StatusBarPanelAutoSize .» Spring
00721
Me . filestatusbar . Width = 4800722
'00723
'PictureBox100724
'00725
Me . PictureBox1 . BackColor = System . Drawing . Color . White00726
Me . PictureBox1 . BorderStyle = System . Windows . Forms . BorderStyle .» FixedSingle
00727
Me . PictureBox1 . ContextMenu = Me . mnuPopUp00728
Me . PictureBox1 . Cursor = System . Windows . Forms . Cursors . Cross00729
Me . PictureBox1 . Location = New System . Drawing . Point ( 0 , 0 )00730
Me . PictureBox1 . Name = "PictureBox1"00731
Me . PictureBox1 . Size = New System . Drawing . Size ( 168 , 160 )00732
Me . PictureBox1 . SizeMode = System . Windows . Forms . PictureBoxSizeMode .» CenterImage
00733
Me . PictureBox1 . TabIndex = 100734
Me . PictureBox1 . TabStop = False00735
Me . PictureBox1 . Visible = False00736
'00737
'mnuPopUp00738
'00739
Me . mnuPopUp . MenuItems . AddRange ( New System . Windows . Forms . MenuItem () { Me .» mnuAñadirNodo , Me . mnuEditarNodo , Me . mnuBorrarNodo , Me . mnuAlinearNodos
» , Me . mnuEdicion4 , Me . mnuAñadirArco , Me . mnuEditarArco , Me .
» mnuBorrarArco , Me . mnuEdicion8 , Me . mnuZoomMas , Me . mnuZoomMenos , Me .
» mnuZoomAjustar })
00740
'00741
'mnuAñadirNodo00742
'00743
Me . mnuAñadirNodo . Index = 000744
Me . mnuAñadirNodo . Text = "Añadir Nodo"00745
'00746
'mnuEditarNodo00747
'00748
Me . mnuEditarNodo . Index = 100749
Me . mnuEditarNodo . Text = "Editar Nodo"00750
'00751
'mnuBorrarNodo00752
'00753
Me . mnuBorrarNodo . Index = 200754
Me . mnuBorrarNodo . Text = "Borrar Nodo"00755
'00756
'mnuAlinearNodos00757
'00758
Me . mnuAlinearNodos . Index = 300759
Me . mnuAlinearNodos . MenuItems . AddRange ( New System . Windows . Forms . MenuItem (» ) { Me . mnuAlinearNodosH , Me . mnuAlinearNodosV })
00760
Me . mnuAlinearNodos . Text = "Alinear Nodos"00761
'00762
'mnuAlinearNodosH00763
'00764
Me . mnuAlinearNodosH . Index = 000765
Me . mnuAlinearNodosH . Text = "Horizontalmente"00766
'00767
'mnuAlinearNodosV00768
'00769
Me . mnuAlinearNodosV . Index = 100770
Me . mnuAlinearNodosV . Text = "Verticalmente"00771
'00772
'mnuEdicion400773
'00774
Me . mnuEdicion4 . Index = 400775
Me . mnuEdicion4 . Text = "-"00776
'00777
'mnuAñadirArco00778
'00779
Me . mnuAñadirArco . Index = 500780
Me . mnuAñadirArco . Text = "Añadir Arco"00781
'00782
'mnuEditarArco00783
'00784
Me . mnuEditarArco . Index = 600785
Me . mnuEditarArco . Text = "Editar Arco"00786
'00787
'mnuBorrarArco00788
'00789
Me . mnuBorrarArco . Index = 700790
Me . mnuBorrarArco . Text = "Borrar Arco"00791
'00792
'mnuEdicion800793
'00794
Me . mnuEdicion8 . Index = 800795
Me . mnuEdicion8 . Text = "-"00796
'00797
'mnuZoomMas00798
'00799
Me . mnuZoomMas . Index = 900800
Me . mnuZoomMas . Text = "Zoom +"00801
'00802
'mnuZoomMenos00803
'00804
Me . mnuZoomMenos . Index = 1000805
Me . mnuZoomMenos . Text = "Zoom -"00806
'00807
'mnuZoomAjustar00808
'00809
Me . mnuZoomAjustar . Index = 1100810
Me . mnuZoomAjustar . Text = "Zoom ajustado"00811
'00812
'Panel100813
'00814
Me . Panel1 . AutoScroll = True00815
Me . Panel1 . AutoScrollMinSize = New System . Drawing . Size ( 20 , 20 )00816
Me . Panel1 . BorderStyle = System . Windows . Forms . BorderStyle . Fixed3D00817
Me . Panel1 . Controls . Add ( Me . PictureBox1 )00818
Me . Panel1 . Controls . Add ( Me . TextBox1 )00819
Me . Panel1 . Controls . Add ( Me . hfgTabla )00820
Me . Panel1 . Dock = System . Windows . Forms . DockStyle . Fill00821
Me . Panel1 . Font = New System . Drawing . Font ( "Verdana" , 9.75 !, System .» Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , CType ( 0
» , Byte ))
00822
Me . Panel1 . Location = New System . Drawing . Point ( 0 , 0 )00823
Me . Panel1 . Name = "Panel1"00824
Me . Panel1 . Size = New System . Drawing . Size ( 624 , 346 )00825
Me . Panel1 . TabIndex = 300826
'00827
'TextBox100828
'00829
Me . TextBox1 . AutoSize = False00830
Me . TextBox1 . BackColor = System . Drawing . Color . FromArgb ( CType ( 255 , Byte ),» CType ( 255 , Byte ), CType ( 192 , Byte ))
00831
Me . TextBox1 . BorderStyle = System . Windows . Forms . BorderStyle . FixedSingle00832
Me . TextBox1 . ContextMenu = Me . mnuPopTabla00833
Me . TextBox1 . Font = New System . Drawing . Font ( "Verdana" , 9.75 !, System .» Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , CType ( 0
» , Byte ))
00834
Me . TextBox1 . HideSelection = False00835
Me . TextBox1 . Location = New System . Drawing . Point ( 432 , 96 )00836
Me . TextBox1 . Name = "TextBox1"00837
Me . TextBox1 . Size = New System . Drawing . Size ( 88 , 20 )00838
Me . TextBox1 . TabIndex = 200839
Me . TextBox1 . Text = "TextBox1"00840
Me . TextBox1 . TextAlign = System . Windows . Forms . HorizontalAlignment . Right00841
Me . TextBox1 . Visible = False00842
'00843
'mnuPopTabla00844
'00845
Me . mnuPopTabla . MenuItems . AddRange ( New System . Windows . Forms . MenuItem () {» Me . mnuTablaAñadirNodo , Me . mnuTablaBorrarNodo , Me . MenuItem2 , Me .
» mnuTablaTotalNodos , Me . MenuItem3 , Me . mnuTablaCopiarTabla })
00846
'00847
'mnuTablaAñadirNodo00848
'00849
Me . mnuTablaAñadirNodo . Index = 000850
Me . mnuTablaAñadirNodo . Text = "Añadir Nodo"00851
'00852
'mnuTablaBorrarNodo00853
'00854
Me . mnuTablaBorrarNodo . Index = 100855
Me . mnuTablaBorrarNodo . Text = "Borrar Nodo"00856
'00857
'MenuItem200858
'00859
Me . MenuItem2 . Index = 200860
Me . MenuItem2 . Text = "-"00861
'00862
'mnuTablaTotalNodos00863
'00864
Me . mnuTablaTotalNodos . Index = 300865
Me . mnuTablaTotalNodos . Text = "Total Nodos..."00866
'00867
'MenuItem300868
'00869
Me . MenuItem3 . Index = 400870
Me . MenuItem3 . Text = "-"00871
'00872
'mnuTablaCopiarTabla00873
'00874
Me . mnuTablaCopiarTabla . Index = 500875
Me . mnuTablaCopiarTabla . Text = "Copiar Tabla"00876
'00877
'hfgTabla00878
'00879
Me . hfgTabla . ContainingControl = Me00880
Me . hfgTabla . Location = New System . Drawing . Point ( 152 , 64 )00881
Me . hfgTabla . Name = "hfgTabla"00882
Me . hfgTabla . OcxState = CType ( resources . GetObject ( "hfgTabla.OcxState" ),» System . Windows . Forms . AxHost . State )
00883
Me . hfgTabla . Size = New System . Drawing . Size ( 224 , 144 )00884
Me . hfgTabla . TabIndex = 400885
Me . hfgTabla . Visible = False00886
'00887
'PrintPreviewDialog100888
'00889
Me . PrintPreviewDialog1 . AutoScrollMargin = New System . Drawing . Size ( 0 , 0 )00890
Me . PrintPreviewDialog1 . AutoScrollMinSize = New System . Drawing . Size ( 0 , 0 )00891
Me . PrintPreviewDialog1 . ClientSize = New System . Drawing . Size ( 400 , 300 )00892
Me . PrintPreviewDialog1 . Enabled = True00893
Me . PrintPreviewDialog1 . Icon = CType ( resources . GetObject (» "PrintPreviewDialog1.Icon" ), System . Drawing . Icon )
00894
Me . PrintPreviewDialog1 . Location = New System . Drawing . Point ( 462 , 17 )00895
Me . PrintPreviewDialog1 . MinimumSize = New System . Drawing . Size ( 375 , 250 )00896
Me . PrintPreviewDialog1 . Name = "PrintPreviewDialog1"00897
Me . PrintPreviewDialog1 . TransparencyKey = System . Drawing . Color . Empty00898
Me . PrintPreviewDialog1 . Visible = False00899
'00900
'PrintDocument100901
'00902
'00903
'Form100904
'00905
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00906
Me . AutoScroll = True00907
Me . ClientSize = New System . Drawing . Size ( 624 , 362 )00908
Me . Controls . Add ( Me . Panel1 )00909
Me . Controls . Add ( Me . StatusBar )00910
Me . Icon = CType ( resources . GetObject ( "$this.Icon" ), System . Drawing . Icon )00911
Me . Menu = Me . MainMenu100912
Me . Name = "Form1"00913
Me . StartPosition = System . Windows . Forms . FormStartPosition . CenterScreen00914
Me . Text = "Grafos - (cc) 2003..2005 - Alejandro Rodríguez Villalobos "00915
Me . WindowState = System . Windows . Forms . FormWindowState . Maximized00916
CType ( Me . PanelX , System . ComponentModel . ISupportInitialize ) . EndInit ()00917
CType ( Me . PanelY , System . ComponentModel . ISupportInitialize ) . EndInit ()00918
CType ( Me . SobreObj , System . ComponentModel . ISupportInitialize ) . EndInit ()00919
CType ( Me . Nd1 , System . ComponentModel . ISupportInitialize ) . EndInit ()00920
CType ( Me . Nd2 , System . ComponentModel . ISupportInitialize ) . EndInit ()00921
CType ( Me . z , System . ComponentModel . ISupportInitialize ) . EndInit ()00922
CType ( Me . filestatusbar , System . ComponentModel . ISupportInitialize ) .» EndInit ()
00923
Me . Panel1 . ResumeLayout ( False )00924
CType ( Me . hfgTabla , System . ComponentModel . ISupportInitialize ) . EndInit ()00925
Me . ResumeLayout ( False )00926
00927
End Sub00928
00929
# End Region00930
00931
'Declaraciones de DLLs de Análisis00932
Dim WithEvents Dijkstra1 As New Dijkstra . Dijkstra00933
Dim WithEvents BellmanFord1 As New BellmanFord . BellmanFord00934
Dim WithEvents Kruskal1 As New Kruskal . Kruskal00935
Dim WithEvents Prim1 As New Prim . Prim00936
Dim WithEvents FordFulkerson1 As New FordFulkerson . FordFulkerson00937
Dim WithEvents FloydWarshall1 As New FloydWarshall . FloydWarshall00938
00939
'declaración de ventana de opciones de formato00940
Dim WithEvents CajaPropiedades As New Form200941
'declaración de ventana de importar datos00942
Dim WithEvents CajaImportar As New frmImportarDatos00943
Dim CajaExportar As New frmExportarDatos00944
Dim WithEvents CajaNuevoAleatorio As New frmNuevoAleatorio00945
'Array donde guardará la solución de las00946
'variables de decisión del modelo LP_solve00947
Dim SolucionModeloLP ()00948
Dim TiempoModelado As Long00949
'Estructura de árbol para guardar datos XML00950
Public EstructuraArbol As New ArrayList00951
Public XMLValido As Boolean00952
00953
'Declara la estructura del objeto Nodo00954
Public Structure Nodo00955
Dim Texto As String 'etiqueta00956
Dim Valor As Single 'valor del nodo00957
Dim X As Single 'coordenadas00958
Dim Y As Single00959
Dim Z As Single00960
Dim Col As Color 'color de relleno del nodo00961
Dim Radio As Single 'radio del nodo00962
Dim Grosor As Single 'trazo del nodo00963
End Structure00964
'Declara la estructura del objeto Arco o relación entre nodos00965
Public Structure Arco00966
Dim Texto As String 'etiqueta00967
Dim Min As Single 'valor de mínimo00968
Dim Max As Single 'valor de máximo00969
Dim Coste As Single 'valor de coste00970
Dim Col As Color 'color del arco00971
Dim Grosor As Single 'trazo del arco00972
Dim Nd1 As Long 'nodo origen00973
Dim Nd2 As Long 'nodo destino00974
Dim B As Boolean 'doble flecha si o no00975
End Structure00976
'Declara la estructura del objeto Grafo00977
Public Structure Graf00978
Dim Fichero As String 'nombre del fichero00979
Dim Extension As String 'extensión del formato de fichero00980
Dim Zoom As Single00981
Dim Rejilla As Single00982
Dim Iman As Boolean00983
Dim MostrarRejilla As Boolean00984
Dim TapizX As Single00985
Dim TapizY As Single00986
Dim ColorRejilla As Color00987
Dim ColorTapiz As Color00988
Dim ImagenTapiz As String00989
Dim MostrarImagenTapiz As Boolean00990
00991
'Nodos00992
Dim Fuente As Font00993
Dim RadioNodo As Single00994
Dim TrazoNodo As Single00995
Dim ColNodo As Color00996
Dim textoNodo As Boolean00997
Dim costNodo As Boolean00998
00999
'Arcos01000
Dim minArco As Boolean01001
Dim maxArco As Boolean01002
Dim costArco As Boolean01003
Dim ColArco As Color01004
Dim TrazoArco As Single01005
Dim BArco As Boolean 'bidireccional01006
01007
End Structure01008
01009
'Nodos Seleccionados01010
Public Shared Nd1S As Long = - 1 'primer nodo seleccionado01011
Public Shared Nd2S As Long = - 1 'segundo nodo seleccionado01012
'Arco Seleccionado01013
Dim ArcS As Long = - 1 'Arco seleccionado01014
01015
'Coordenadas de creación de un nuevo nodo01016
Dim XNuevo , YNuevo As Single01017
01018
'Totales de Nodos y Arcos01019
Public Shared TotalNodos As Long01020
Public Shared TotalArcos As Long01021
01022
'Crea las colecciones para ambos objetos01023
Public Shared Nodos ( 1 ) As Nodo01024
Public Shared Arcos ( 1 ) As Arco01025
'para copia previo a solución01026
Public Shared NodosPrev ( 1 ) As Nodo01027
Public Shared ArcosPrev ( 1 ) As Arco01028
'para copia de solución01029
Public Shared NodosSol ( 1 ) As Nodo01030
Public Shared ArcosSol ( 1 ) As Arco01031
01032
'crea objeto grafo01033
Public Shared Grafico As Graf 'public shared para compartir entre forms01034
01035
'crea matriz para la tabla de arcos01036
Public Matriz (- 1 , - 1 ) As String01037
'crea matriz para la cabecera de nodos01038
Public Cabecera1 () As String01039
'crea matriz par los valore de nodos01040
Public Cabecera2 () As String01041
'total nodos en la matriz01042
Public Shared NodosMatriz As Long01043
Public Shared NuevoNodosMatriz As Long 'para ser cambiado por usuario01044
'Celda en edición01045
Public CeldaX As Long01046
Public CeldaY As Long01047
01048
'Crea el objeto Graphics principal01049
Public G As Graphics01050
01051
'para la publicación de resultados del algoritmo01052
Public Shared txtResultadosAlgoritmo As String01053
Public Shared AlgoritmoMILP As Boolean01054
Public WithEvents CajaSolucion As New Form601055
01056
Sub DibujaGrafo ()01057
'Me.Cursor = Cursors.WaitCursor01058
Try01059
PictureBox1 . Width = Grafico . TapizX * Grafico . Zoom01060
PictureBox1 . Height = Grafico . TapizY * Grafico . Zoom01061
'PictureBox1.BackColor = Grafico.ColorTapiz01062
'Pone la información de zoom en panel01063
StatusBar . Panels ( 5 ) . Text = "Zoom = " & Format ( Grafico . Zoom , "#0.00"» )
01064
01065
'Crea un objeto Graphics01066
'Dim G As Graphics01067
01068
'toma el objeto graphics01069
G = TomaObjetoGraphics ( PictureBox1 )01070
01071
'borra el objeto graphics01072
G . Clear ( Grafico . ColorTapiz )01073
If Grafico . MostrarImagenTapiz = True And Grafico . ImagenTapiz <> ""» Then
01074
'carga y ajusta la imagen de fondo al tamaño del tapiz01075
G . DrawImage ( Image . FromFile ( Grafico . ImagenTapiz ), 0 , 0 , Grafico .» TapizX * Grafico . Zoom , Grafico . TapizY * Grafico . Zoom )
01076
Else01077
G . Clear ( Grafico . ColorTapiz )01078
End If01079
01080
'Opciones de prestaciones gráficas01081
G . SmoothingMode = Drawing . Drawing2D . SmoothingMode . None01082
'G.InterpolationMode = Drawing.Drawing2D.InterpolationMode.Low01083
'G.TextRenderingHint = Drawing.Text.TextRenderingHint.SystemDefault01084
01085
'definiciones01086
Dim p As Pen 'pluma01087
Dim brocha As System . Drawing . SolidBrush01088
01089
Dim pf As Pen ' pluma01090
01091
Dim b As Rectangle01092
Dim i As Long 'contador01093
01094
Dim x , y As Single01095
Dim x2 , y2 As Single01096
Dim radio As Single01097
Dim t As String 'para texto01098
Dim v As Single 'para valor01099
01100
Dim tamañotexto As SizeF01101
01102
Dim LV As Single01103
Dim Xa As Single , Ya As Single01104
Dim Xb As Single , Yb As Single01105
01106
Dim fuente As Font01107
01108
Dim f As Form201109
f = New Form201110
01111
'prueba de linea con cabezas flecha01112
'#######01113
Dim Fxa , Fya , Fxb , Fyb As Single01114
Dim pff As Pen ' pluma01115
'#######01116
01117
'Cambia escala del tipo de letra01118
fuente = New Font ( Grafico . Fuente . Name , Grafico . Fuente . Size *» Grafico . Zoom , Grafico . Fuente . Style , GraphicsUnit . Pixel )
01119
01120
'--------------01121
'DibujaRejilla01122
'--------------01123
If mnuFormatoRejilla . Checked = True Then01124
'define trazo y color de pluma01125
p = New Pen ( Grafico . ColorRejilla , 1 )01126
p . DashStyle = Drawing . Drawing2D . DashStyle . Dash01127
For x = 0 To PictureBox1 . Width Step Grafico . Rejilla * Grafico .» Zoom
01128
'líneas verticales01129
G . DrawLine ( p , x , 0 , x , PictureBox1 . Height )01130
For y = 0 To PictureBox1 . Height Step Grafico . Rejilla *» Grafico . Zoom
01131
'líneas horizontales01132
G . DrawLine ( p , 0 , y , PictureBox1 . Width , y )01133
Next y01134
Next x01135
End If01136
'-------------01137
01138
'----------------------------01139
'Dibuja la colección de Arcos01140
'----------------------------01141
Dim nArcosR As Long01142
Dim xxa , yya As Single01143
Dim rra As Single01144
01145
Dim ArcS As Long01146
01147
For i = 0 To TotalArcos - 101148
01149
'define el trazo y su color01150
p = New Pen ( Arcos ( i ) . Col , Arcos ( i ) . Grosor * Grafico . Zoom )01151
01152
'Compone etiqueta del arco01153
If Grafico . minArco Or Grafico . maxArco Or Grafico . costArco Then01154
t = "("01155
01156
If Grafico . minArco Then01157
t = t & Arcos ( i ) . Min . ToString01158
End If01159
01160
If Grafico . maxArco Then01161
If Grafico . minArco Then t = t & "; "01162
t = t & Arcos ( i ) . Max . ToString01163
End If01164
01165
If Grafico . costArco Then01166
If ( Grafico . maxArco Or Grafico . minArco ) Then t = t &» "; "
01167
t = t & Arcos ( i ) . Coste . ToString01168
End If01169
01170
t = t & ")"01171
End If01172
01173
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then01174
'Arco entre un mismo nodo01175
'----------01176
rra = Nodos ( Arcos ( i ) . Nd1 ) . Radio * Grafico . Zoom01177
x = Nodos ( Arcos ( i ) . Nd1 ) . X * Grafico . Zoom01178
y = Nodos ( Arcos ( i ) . Nd1 ) . Y * Grafico . Zoom01179
'dibuja beizer01180
G . DrawBezier ( p , x - rra , y , x - rra * 3 , y + rra * 3 , x +» rra * 5 , y + rra * 4.6 , x , y )
01181
Else01182
'El arco va entre nodos diferentes01183
'----------01184
'Comprueba si entre nodos existe doble arco01185
nArcosR = 001186
nArcosR = ExisteArcoReves ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 )01187
01188
'Busca un arco simétrico01189
ArcS = - 101190
ArcS = BuscaArcoSimetrico ( i )01191
01192
If ArcS <> - 1 Then01193
If ArcS > i Then01194
Arcos ( i ) . B = True01195
Arcos ( ArcS ) . B = False01196
End If01197
Else01198
Arcos ( i ) . B = False01199
End If01200
01201
If nArcosR = 0 Or ( ArcS <> - 1 And Grafico . BArco = True )» Then 'un sólo arco también si es simétrico
01202
'un sólo arco01203
'toma datos del nodo 101204
x = Nodos ( Arcos ( i ) . Nd1 ) . X * Grafico . Zoom01205
y = Nodos ( Arcos ( i ) . Nd1 ) . Y * Grafico . Zoom01206
01207
'toma datos del nodo 201208
x2 = Nodos ( Arcos ( i ) . Nd2 ) . X * Grafico . Zoom01209
y2 = Nodos ( Arcos ( i ) . Nd2 ) . Y * Grafico . Zoom01210
01211
Else01212
'toma datos del nodo 101213
x = Nodos ( Arcos ( i ) . Nd1 ) . X * Grafico . Zoom01214
y = Nodos ( Arcos ( i ) . Nd1 ) . Y * Grafico . Zoom01215
01216
'toma datos del nodo 201217
x2 = Nodos ( Arcos ( i ) . Nd2 ) . X * Grafico . Zoom01218
y2 = Nodos ( Arcos ( i ) . Nd2 ) . Y * Grafico . Zoom01219
01220
01221
'dos arcos en diferentes sentidos01222
'calcula vector unitario01223
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )01224
If LV = 0 Then LV = 0.000000101225
01226
'vector unitario de tamaño radio más pequeño01227
If Nodos ( Arcos ( i ) . Nd1 ) . Radio < Nodos ( Arcos ( i ) . Nd2 ) .» Radio Then
01228
rra = Nodos ( Arcos ( i ) . Nd1 ) . Radio * 0.501229
Else01230
rra = Nodos ( Arcos ( i ) . Nd2 ) . Radio * 0.501231
End If01232
'vector perpendicular01233
yya = ( x2 - x ) / LV * rra * Grafico . Zoom01234
xxa = (- 1 ) * ( y2 - y ) / LV * rra * Grafico . Zoom01235
'traslada el punto de origen y destino01236
x = x + xxa01237
y = y + yya01238
x2 = x2 + xxa01239
y2 = y2 + yya01240
End If01241
01242
'línea principal de centro a centro01243
'------------------------------------01244
G . DrawLine ( p , x , y , x2 , y2 )01245
01246
''prueba de dibujar flecha de otra manera01247
''######01248
''---------01249
01250
''dos arcos en diferentes sentidos01251
''calcula vector unitario01252
'LV = Math.Sqrt(((x2 - x)) ^ 2 + ((y2 - y)) ^ 2)01253
'If LV = 0 Then LV = 0.000000101254
'xxa = (x2 - x) / LV * Grafico.Zoom01255
'yya = (y2 - y) / LV * Grafico.Zoom01256
''calcula puntos de intersección con la circunferencia de» ambos nodos
01257
'rra = Nodos(Arcos(i).Nd1).Radio * 101258
'Fxa = x + xxa * rra01259
'Fya = y + yya * rra01260
'rra = Nodos(Arcos(i).Nd2).Radio * 101261
'Fxb = x2 - xxa * rra01262
'Fyb = y2 - yya * rra01263
''--------01264
''define el trazo y su color01265
'p = New Pen(Arcos(i).Col, Arcos(i).Grosor * Grafico.Zoom)01266
'p.StartCap = Drawing2D.LineCap.NoAnchor01267
'p.EndCap = Drawing2D.LineCap.NoAnchor01268
'G.DrawLine(p, Fxb, Fyb + 30, Fxa, Fya + 30)01269
01270
''define el trazo y su color01271
'pff = New Pen(Arcos(i).Col, Arcos(i).Grosor * 5 *» Grafico.Zoom)
01272
'pff.StartCap = Drawing2D.LineCap.ArrowAnchor01273
'pff.EndCap = Drawing2D.LineCap.NoAnchor01274
'G.DrawLine(pff, Fxb, Fyb + 30, Fxb - xxa * 5, Fyb + 30 -» yya * 5)
01275
'pff.StartCap = Drawing2D.LineCap.ArrowAnchor01276
'pff.EndCap = Drawing2D.LineCap.NoAnchor01277
'G.DrawLine(pff, Fxa, Fya + 30, Fxa + xxa * 5, Fya + 30 +» yya * 5)
01278
''#########01279
01280
End If01281
01282
'Dibuja etiqueta del arco01283
'-------------------------01284
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then01285
'Arco sobre un mismo nodo01286
'si se quisiera a la mitad, sustituir por 0.501287
tamañotexto = G . MeasureString ( t , fuente )01288
'rectangulo blanco debajo para que el texto se lea más» claro
01289
b = New Rectangle ( x - tamañotexto . Width / 2 , y + rra * 2 -» tamañotexto . Height / 2 , tamañotexto . Width , tamañotexto .
» Height )
01290
brocha = New System . Drawing . SolidBrush ( Grafico . ColorTapiz )01291
G . FillRectangle ( brocha , b )01292
'escribe el texto01293
G . DrawString ( t , fuente , Brushes . Black , x - tamañotexto .» Width / 2 , y + rra * 2 - tamañotexto . Height / 2 )
01294
01295
'punta de flecha en arco sobre un mismo nodo01296
y2 = y + rra * 301297
x2 = x + rra * 301298
'calcula vector unitario01299
01300
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )01301
If LV = 0 Then LV = 0.000000101302
'vector unitario de tamaño radio destino01303
x = (- 1 ) * ( x2 - x ) / LV * Nodos ( Arcos ( i ) . Nd2 ) . Radio *» Grafico . Zoom
01304
y = (- 1 ) * ( y2 - y ) / LV * Nodos ( Arcos ( i ) . Nd2 ) . Radio *» Grafico . Zoom
01305
01306
'punto de intersección de la línea principal con el» círculo del nodo destino
01307
Xa = x2 - rra * 2.301308
Ya = y2 - rra * 2.301309
'cambia el tamaño de la flecha01310
x = x / Nodos ( Arcos ( i ) . Nd2 ) . Radio * 1001311
y = y / Nodos ( Arcos ( i ) . Nd2 ) . Radio * 1001312
'segmento estribor de la punta de la flecha01313
Xb = Xa - x * Arcos ( i ) . Grosor - y / 2 * Arcos ( i ) . Grosor01314
Yb = Ya - y * Arcos ( i ) . Grosor + x / 2 * Arcos ( i ) . Grosor01315
G . DrawLine ( p , Xb , Yb , Xa , Ya )01316
'segmento babor de la punta de la flecha01317
Xb = Xa - x * Arcos ( i ) . Grosor + y / 2 * Arcos ( i ) . Grosor01318
Yb = Ya - y * Arcos ( i ) . Grosor - x / 2 * Arcos ( i ) . Grosor01319
G . DrawLine ( p , Xb , Yb , Xa , Ya )01320
01321
Else01322
01323
If Arcos ( i ) . B = True And Grafico . BArco = True Then01324
'si se quisiera a la mitad, sustituir por 0.501325
tamañotexto = G . MeasureString ( t , fuente )01326
'rectangulo blanco debajo para que el texto se lea más» claro
01327
b = New Rectangle ( x + 0.3 * ( x2 - x ) - tamañotexto .» Width / 2 , y + 0.3 * ( y2 - y ) - tamañotexto . Height /
» 2 , tamañotexto . Width , tamañotexto . Height )
01328
brocha = New System . Drawing . SolidBrush ( Grafico .» ColorTapiz )
01329
G . FillRectangle ( brocha , b )01330
'escribe el texto01331
G . DrawString ( t , fuente , Brushes . Black , x + 0.3 * ( x2 -» x ) - tamañotexto . Width / 2 , y + 0.3 * ( y2 - y ) -
» tamañotexto . Height / 2 )
01332
Else01333
'el 0.7 hace que el texto del arco se encuentre cerca» del destino
01334
'si se quisiera a la mitad, sustituir por 0.501335
tamañotexto = G . MeasureString ( t , fuente )01336
'rectangulo blanco debajo para que el texto se lea más» claro
01337
b = New Rectangle ( x + 0.7 * ( x2 - x ) - tamañotexto .» Width / 2 , y + 0.7 * ( y2 - y ) - tamañotexto . Height /
» 2 , tamañotexto . Width , tamañotexto . Height )
01338
brocha = New System . Drawing . SolidBrush ( Grafico .» ColorTapiz )
01339
G . FillRectangle ( brocha , b )01340
'escribe el texto01341
G . DrawString ( t , fuente , Brushes . Black , x + 0.7 * ( x2 -» x ) - tamañotexto . Width / 2 , y + 0.7 * ( y2 - y ) -
» tamañotexto . Height / 2 )
01342
End If01343
01344
'punta de flecha destino01345
'-----------------------01346
01347
'calcula vector unitario01348
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )01349
If LV = 0 Then LV = 0.000000101350
'vector unitario de tamaño radio destino01351
x = ( x2 - x ) / LV * Nodos ( Arcos ( i ) . Nd2 ) . Radio * Grafico .» Zoom
01352
y = ( y2 - y ) / LV * Nodos ( Arcos ( i ) . Nd2 ) . Radio * Grafico .» Zoom
01353
01354
'punto de intersección de la línea principal con el» círculo del nodo destino
01355
Xa = x2 - x01356
Ya = y2 - y01357
01358
'cambia el tamaño de la flecha01359
x = x / Nodos ( Arcos ( i ) . Nd2 ) . Radio * 1001360
y = y / Nodos ( Arcos ( i ) . Nd2 ) . Radio * 1001361
'segmento estribor de la punta de la flecha01362
Xb = Xa - x * Arcos ( i ) . Grosor - y / 2 * Arcos ( i ) . Grosor01363
Yb = Ya - y * Arcos ( i ) . Grosor + x / 2 * Arcos ( i ) . Grosor01364
G . DrawLine ( p , Xb , Yb , Xa , Ya )01365
'segmento babor de la punta de la flecha01366
Xb = Xa - x * Arcos ( i ) . Grosor + y / 2 * Arcos ( i ) . Grosor01367
Yb = Ya - y * Arcos ( i ) . Grosor - x / 2 * Arcos ( i ) . Grosor01368
G . DrawLine ( p , Xb , Yb , Xa , Ya )01369
01370
'Caso de arco bidireccional01371
'con dos puntas de flecha01372
If Arcos ( i ) . B = True And Grafico . BArco = True Then01373
'punta de flecha origen01374
'-----------------------01375
'toma los nodos al revés y ya está!01376
'toma datos del nodo 101377
x = Nodos ( Arcos ( i ) . Nd2 ) . X * Grafico . Zoom01378
y = Nodos ( Arcos ( i ) . Nd2 ) . Y * Grafico . Zoom01379
01380
'toma datos del nodo 201381
x2 = Nodos ( Arcos ( i ) . Nd1 ) . X * Grafico . Zoom01382
y2 = Nodos ( Arcos ( i ) . Nd1 ) . Y * Grafico . Zoom01383
01384
'calcula vector unitario01385
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )01386
If LV = 0 Then LV = 0.000000101387
'vector unitario de tamaño radio destino01388
x = ( x2 - x ) / LV * Nodos ( Arcos ( i ) . Nd1 ) . Radio *» Grafico . Zoom
01389
y = ( y2 - y ) / LV * Nodos ( Arcos ( i ) . Nd1 ) . Radio *» Grafico . Zoom
01390
01391
'punto de intersección de la línea principal con el» círculo del nodo destino
01392
Xa = x2 - x01393
Ya = y2 - y01394
01395
'cambia el tamaño de la flecha01396
x = x / Nodos ( Arcos ( i ) . Nd1 ) . Radio * 1001397
y = y / Nodos ( Arcos ( i ) . Nd1 ) . Radio * 1001398
'segmento estribor de la punta de la flecha01399
Xb = Xa - x * Arcos ( i ) . Grosor - y / 2 * Arcos ( i ) .» Grosor
01400
Yb = Ya - y * Arcos ( i ) . Grosor + x / 2 * Arcos ( i ) .» Grosor
01401
G . DrawLine ( p , Xb , Yb , Xa , Ya )01402
'segmento babor de la punta de la flecha01403
Xb = Xa - x * Arcos ( i ) . Grosor + y / 2 * Arcos ( i ) .» Grosor
01404
Yb = Ya - y * Arcos ( i ) . Grosor - x / 2 * Arcos ( i ) .» Grosor
01405
G . DrawLine ( p , Xb , Yb , Xa , Ya )01406
End If01407
End If01408
Next i01409
01410
'----------------------------01411
'Dibuja la colección de Nodos01412
'----------------------------01413
For i = 0 To TotalNodos - 101414
'toma datos del nodo01415
x = Nodos ( i ) . X * Grafico . Zoom01416
y = Nodos ( i ) . Y * Grafico . Zoom01417
radio = Nodos ( i ) . Radio * Grafico . Zoom01418
01419
'define el trazo y su color01420
p = New Pen ( Color . Black , Nodos ( i ) . Grosor * Grafico . Zoom )01421
'dibuja círculo del nodo01422
b = New Rectangle ( x - radio , y - radio , radio * 2 , radio * 2 )01423
'rellena el círculo del nodo01424
Select Case i01425
Case Nd1S 'primer nodo seleccionado01426
brocha = New System . Drawing . SolidBrush ( Color . LightGreen» )
01427
Case Nd2S 'segundo nodo seleccionado01428
brocha = New System . Drawing . SolidBrush ( Color . Red )01429
Case Else 'no seleccionado - color original01430
brocha = New System . Drawing . SolidBrush ( Nodos ( i ) . Col )01431
End Select01432
01433
'condicion de dibujado de ambos textos separados por ecuador01434
'o uno sólo centrado en el nodo01435
Dim condicion As Integer01436
If Grafico . textoNodo = False Or Grafico . costNodo = False Then01437
condicion = 001438
Else01439
condicion = 101440
End If01441
01442
G . FillEllipse ( brocha , b )01443
If Grafico . textoNodo And Grafico . costNodo Then01444
'dibuja ecuador del nodo01445
G . DrawLine ( p , x - radio , y , x + radio , y )01446
End If01447
If Grafico . textoNodo Then01448
'pone texto etiqueta en la mitad superior01449
t = Nodos ( i ) . Texto01450
tamañotexto = G . MeasureString ( t , fuente )01451
G . DrawString ( t , fuente , Brushes . Black , x - tamañotexto .» Width / 2 , y - tamañotexto . Height / 2 - radio / 2 *
» condicion )
01452
End If01453
If Grafico . costNodo Then01454
'pone texto valor en la mitad inferior01455
t = Nodos ( i ) . Valor . ToString01456
tamañotexto = G . MeasureString ( t , fuente )01457
G . DrawString ( t , fuente , Brushes . Black , x - tamañotexto .» Width / 2 , y - tamañotexto . Height / 2 + radio / 2 *
» condicion )
01458
End If01459
01460
'dibuja el borde del nodo01461
G . DrawEllipse ( p , b )01462
Next i01463
'----------------------------01464
01465
'Intercepción de posibles errores al dibujar01466
Catch ex As Exception01467
Me . Cursor = Cursors . Default01468
MsgBox ( "Ha fallado el proceso de dibujar el grafo" & vbCrLf & ex .» Message , MsgBoxStyle . Exclamation , "Grafos - Excepción" )
01469
Exit Sub01470
Finally01471
End Try01472
01473
End Sub01474
01475
Public Sub DibujaGrafoSVG ( ByVal fichero As String )01476
'Esta rutina se basa en la rutina DibujaGrafo01477
'transforma todas los comandos gráficos en instrucciones01478
'xml que serán guardadas como texto en un fichero de01479
'extensión .svg (Scalable Vector Graphics) que puede ser01480
'interpretado por un navegador con el plugin svg instalado.01481
Try01482
Dim txt , txt0 , txt1 , txt2 , txt3 , txt4 As String01483
Dim cdn As String01484
Dim cr , cg , cb As Integer01485
01486
01487
Dim version As String01488
version = System . Diagnostics . FileVersionInfo . GetVersionInfo ( System .» Reflection . Assembly . GetExecutingAssembly . Location ) . FileMajorPart
01489
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileMinorPart
01490
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileBuildPart
01491
01492
'cabecera del fichero xml01493
txt = ""01494
txt = "<?xml version=""1.0"" encoding=""UTF-8""?>"01495
txt & = vbCrLf01496
txt & = "<!-- This file was written by Grafos software. -->" &» vbCrLf
01497
txt & = "<!-- http://ttt.upv.es/~arodrigu/grafos -->" &» vbCrLf
01498
txt & = "<!-- (cc) 2003..2005 - Alejandro Rodriguez Villalobos -->" &» vbCrLf
01499
txt & = "<!-- Fecha: " & Now . ToShortDateString & " -->" & vbCrLf01500
txt & = "<!-- Version: " & version & " -->" & vbCrLf01501
txt & = vbCrLf01502
'tamaño del grafo01503
txt & = "<!-- Tamaño del objeto -->"01504
txt & = vbCrLf01505
txt & = "<svg xml:space=""preserve"" width=""" & Grafico . TapizX *» Grafico . Zoom + 2 & """ height=""" & Grafico . TapizY * Grafico . Zoom
» + 2 & """>"
01506
txt & = vbCrLf01507
txt & = "<!-- Escala general 1:1 en pixeles -->"01508
txt & = vbCrLf01509
txt & = "<g transform=""scale(1)"">"01510
txt & = vbCrLf01511
'tapiz01512
txt0 & = "<g id=""0"">"01513
txt0 & = vbCrLf01514
txt0 & = "<!-- Tapiz -->"01515
txt0 & = vbCrLf01516
cr = Grafico . ColorTapiz . R01517
cg = Grafico . ColorTapiz . G01518
cb = Grafico . ColorTapiz . B01519
01520
txt0 & = "<rect style=""fill:rgb(" & cr & "," & cg & "," & cb &» ");stroke:rgb(127,127,127)"" width=""" & Grafico . TapizX * Grafico
» . Zoom + 1 & """ height=""" & Grafico . TapizY * Grafico . Zoom + 1 &
» """/>"
01521
txt0 & = vbCrLf01522
txt0 & = "</g>"01523
txt0 & = vbCrLf01524
'definiciones01525
G = TomaObjetoGraphics ( PictureBox1 )01526
01527
Dim p As Pen 'pluma01528
Dim brocha As System . Drawing . SolidBrush01529
01530
Dim b As Rectangle01531
Dim i As Long 'contador01532
01533
Dim x , y As Single01534
Dim x2 , y2 As Single01535
Dim radio As Single01536
Dim t As String 'para texto01537
Dim v As Single 'para valor01538
01539
Dim tamañotexto As SizeF01540
01541
Dim LV As Single01542
Dim Xa As Single , Ya As Single01543
Dim Xb As Single , Yb As Single01544
01545
Dim fuente As Font01546
01547
Dim f As Form201548
f = New Form201549
'Cambia escala del tipo de letra01550
fuente = New Font ( Grafico . Fuente . Name , Grafico . Fuente . Size *» Grafico . Zoom , Grafico . Fuente . Style , GraphicsUnit . Pixel )
01551
01552
'--------------01553
'DibujaRejilla01554
'--------------01555
txt1 & = "<g id=""1"">"01556
txt1 & = vbCrLf01557
If mnuFormatoRejilla . Checked = True Then01558
txt1 & = "<!-- rejilla -->"01559
txt1 & = vbCrLf01560
cr = Grafico . ColorRejilla . R01561
cg = Grafico . ColorRejilla . G01562
cb = Grafico . ColorRejilla . B01563
01564
For x = 0 To Grafico . TapizX * Grafico . Zoom Step Grafico . Rejilla» * Grafico . Zoom
01565
'líneas verticales01566
txt1 & = "<line x1=""" & x & """ y1=""" & 0 & """ x2=""" & x» & """ y2=""" & Grafico . TapizY * Grafico . Zoom & """
» style=""stroke-width:" & 1 & ";stroke:rgb(" & cr & "," &
» cg & "," & cb & ")""></line>"
01567
txt1 & = vbCrLf01568
For y = 0 To Grafico . TapizY * Grafico . Zoom Step Grafico .» Rejilla * Grafico . Zoom
01569
'líneas horizontales01570
txt1 & = "<line x1=""" & 0 & """ y1=""" & y & """ x2="""» & Grafico . TapizX * Grafico . Zoom & """ y2=""" & y &
» """ style=""stroke-width:" & 1 & ";stroke:rgb(" & cr
» & "," & cg & "," & cb & ")""></line>"
01571
txt1 & = vbCrLf01572
Next y01573
Next x01574
End If01575
txt1 & = "</g>"01576
txt1 & = vbCrLf01577
'------------01578
01579
'----------------------------01580
'Dibuja la colección de Arcos01581
'----------------------------01582
Dim nArcosR As Long01583
Dim xxa , yya As Single01584
Dim rra As Single01585
01586
Dim ArcS As Long01587
01588
txt2 & = "<!-- arcos -->"01589
txt2 & = "<g id=""2"">"01590
txt2 & = vbCrLf01591
txt2 & = vbCrLf01592
01593
txt3 & = "<!-- textos -->"01594
txt3 & = "<g id=""3"">"01595
txt3 & = vbCrLf01596
txt3 & = vbCrLf01597
01598
For i = 0 To TotalArcos - 101599
01600
'define el trazo y su color01601
cr = Arcos ( i ) . Col . R01602
cg = Arcos ( i ) . Col . G01603
cb = Arcos ( i ) . Col . B01604
01605
'Compone etiqueta del arco01606
If Grafico . minArco Or Grafico . maxArco Or Grafico . costArco Then01607
t = "("01608
01609
If Grafico . minArco Then01610
t = t & Arcos ( i ) . Min . ToString01611
End If01612
01613
If Grafico . maxArco Then01614
If Grafico . minArco Then t = t & "; "01615
t = t & Arcos ( i ) . Max . ToString01616
End If01617
01618
If Grafico . costArco Then01619
If ( Grafico . maxArco Or Grafico . minArco ) Then t = t &» "; "
01620
t = t & Arcos ( i ) . Coste . ToString01621
End If01622
01623
t = t & ")"01624
End If01625
01626
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then01627
'Arco entre un mismo nodo01628
'----------01629
rra = Nodos ( Arcos ( i ) . Nd1 ) . Radio * Grafico . Zoom01630
x = Nodos ( Arcos ( i ) . Nd1 ) . X * Grafico . Zoom01631
y = Nodos ( Arcos ( i ) . Nd1 ) . Y * Grafico . Zoom01632
'dibuja beizer01633
'g.DrawBezier(p,, x - rra, y, x - rra * 3, y + rra * 3, x» + rra * 5, y + rra * 4.6, x, y)
01634
txt2 & = "<path style=""stroke-width:" & Arcos ( i ) . Grosor *» Grafico . Zoom & ";stroke:rgb(" & cr & "," & cg & "," & cb
» & ");fill:none"""
01635
txt2 & = " d=""M " & Int ( x - rra ) & "," & Int ( y ) & " "01636
txt2 & = " Q " & Int ( x - rra * 3.5 ) & "," & Int ( y + rra * 2» ) & " " & Int ( x ) & "," & Int ( y + rra * 3 ) & " "
01637
txt2 & = " Q " & Int ( x + rra * 3.5 ) & "," & Int ( y + rra *» 3.8 ) & " " & Int ( x ) & "," & Int ( y - 6 ) & " "
01638
01639
txt2 & = "Z""/> "01640
txt2 & = vbCrLf01641
01642
Else01643
'El arco va entre nodos diferentes01644
'----------01645
'Comprueba si entre nodos existe doble arco01646
nArcosR = 001647
nArcosR = ExisteArcoReves ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 )01648
01649
'Busca un arco simétrico01650
ArcS = - 101651
ArcS = BuscaArcoSimetrico ( i )01652
01653
If ArcS <> - 1 Then01654
If ArcS > i Then01655
Arcos ( i ) . B = True01656
Arcos ( ArcS ) . B = False01657
End If01658
Else01659
Arcos ( i ) . B = False01660
End If01661
01662
If nArcosR = 0 Or ( ArcS <> - 1 And Grafico . BArco = True )» Then 'un sólo arco también si es simétrico
01663
'un sólo arco01664
'toma datos del nodo 101665
x = Nodos ( Arcos ( i ) . Nd1 ) . X * Grafico . Zoom01666
y = Nodos ( Arcos ( i ) . Nd1 ) . Y * Grafico . Zoom01667
01668
'toma datos del nodo 201669
x2 = Nodos ( Arcos ( i ) . Nd2 ) . X * Grafico . Zoom01670
y2 = Nodos ( Arcos ( i ) . Nd2 ) . Y * Grafico . Zoom01671
01672
Else01673
'toma datos del nodo 101674
x = Nodos ( Arcos ( i ) . Nd1 ) . X * Grafico . Zoom01675
y = Nodos ( Arcos ( i ) . Nd1 ) . Y * Grafico . Zoom01676
01677
'toma datos del nodo 201678
x2 = Nodos ( Arcos ( i ) . Nd2 ) . X * Grafico . Zoom01679
y2 = Nodos ( Arcos ( i ) . Nd2 ) . Y * Grafico . Zoom01680
01681
01682
'dos arcos en diferentes sentidos01683
'calcula vector unitario01684
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )01685
If LV = 0 Then LV = 0.000000101686
01687
01688
'vector unitario de tamaño radio más pequeño01689
If Nodos ( Arcos ( i ) . Nd1 ) . Radio < Nodos ( Arcos ( i ) . Nd2 ) .» Radio Then
01690
rra = Nodos ( Arcos ( i ) . Nd1 ) . Radio * 0.501691
Else01692
rra = Nodos ( Arcos ( i ) . Nd2 ) . Radio * 0.501693
End If01694
'vector perpendicular01695
yya = ( x2 - x ) / LV * rra * Grafico . Zoom01696
xxa = (- 1 ) * ( y2 - y ) / LV * rra * Grafico . Zoom01697
'traslada el punto de origen y destino01698
x = x + xxa01699
y = y + yya01700
x2 = x2 + xxa01701
y2 = y2 + yya01702
End If01703
01704
'línea principal de centro a centro01705
'------------------------------------01706
txt2 & = "<line x1=""" & x & """ y1=""" & y & """ x2=""" &» x2 & """ y2=""" & y2 & """ style=""stroke-width:" & Arcos
» ( i ) . Grosor * Grafico . Zoom & ";stroke:rgb(" & cr & "," &
» cg & "," & cb & ")""></line>"
01707
txt2 & = vbCrLf01708
01709
End If01710
01711
'Dibuja etiqueta del arco01712
'-------------------------01713
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then01714
'Arco sobre un mismo nodo01715
'si se quisiera a la mitad, sustituir por 0.501716
tamañotexto = G . MeasureString ( t , fuente )01717
01718
'escribe el texto01719
txt3 & = "<text x=""" & Int ( x ) & """ y=""" & Int ( y + rra *» 2 ) & """ style=""font-family:" & Grafico . Fuente . Name .
» ToString & ";font-size:" & Int ( tamañotexto . Height ) &
» ";fill:rgb(0,0,0);text-anchor:middle;"">" & t & "</text>"
01720
txt3 & = vbCrLf01721
01722
'punta de flecha en arco sobre un mismo nodo01723
y2 = y + rra * 301724
x2 = x + rra * 301725
'calcula vector unitario01726
01727
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )01728
If LV = 0 Then LV = 0.000000101729
'vector unitario de tamaño radio destino01730
x = (- 1 ) * ( x2 - x ) / LV * Nodos ( Arcos ( i ) . Nd2 ) . Radio *» Grafico . Zoom
01731
y = (- 1 ) * ( y2 - y ) / LV * Nodos ( Arcos ( i ) . Nd2 ) . Radio *» Grafico . Zoom
01732
01733
'punto de intersección de la línea principal con el» círculo del nodo destino
01734
Xa = x2 - rra * 2.301735
Ya = y2 - rra * 2.301736
01737
'cambia el tamaño de la flecha01738
x = x / Nodos ( Arcos ( i ) . Nd2 ) . Radio * 1001739
y = y / Nodos ( Arcos ( i ) . Nd2 ) . Radio * 1001740
'segmento estribor de la punta de la flecha01741
Xb = Xa - x * Arcos ( i ) . Grosor - y / 2 * Arcos ( i ) . Grosor01742
Yb = Ya - y * Arcos ( i ) . Grosor + x / 2 * Arcos ( i ) . Grosor01743
01744
txt2 & = "<line x1=""" & Xb & """ y1=""" & Yb & """ x2=""" &» Xa & """ y2=""" & Ya & """ style=""stroke-width:" &
» Arcos ( i ) . Grosor * Grafico . Zoom & ";stroke:rgb(" & cr &
» "," & cg & "," & cb & ")""></line>"
01745
txt2 & = vbCrLf01746
'segmento babor de la punta de la flecha01747
Xb = Xa - x * Arcos ( i ) . Grosor + y / 2 * Arcos ( i ) . Grosor01748
Yb = Ya - y * Arcos ( i ) . Grosor - x / 2 * Arcos ( i ) . Grosor01749
01750
txt2 & = "<line x1=""" & Xb & """ y1=""" & Yb & """ x2=""" &» Xa & """ y2=""" & Ya & """ style=""stroke-width:" &
» Arcos ( i ) . Grosor * Grafico . Zoom & ";stroke:rgb(" & cr &
» "," & cg & "," & cb & ")""></line>"
01751
txt2 & = vbCrLf01752
Else01753
If Arcos ( i ) . B = True And Grafico . BArco = True Then01754
'si se quisiera a la mitad, sustituir por 0.501755
tamañotexto = G . MeasureString ( t , fuente )01756
01757
'escribe el texto01758
txt3 & = "<text x=""" & Int ( x + 0.3 * ( x2 - x )) & """» y=""" & Int ( y + 0.3 * ( y2 - y )) & """ style="
» "font-family:" & Grafico . Fuente . Name . ToString &
» ";font-size:" & Int ( tamañotexto . Height ) &
» ";fill:rgb(0,0,0);text-anchor:middle;"">" & t &
» "</text>"
01759
txt3 & = vbCrLf01760
01761
Else01762
'el 0.7 hace que el texto del arco se encuentre cerca» del destino
01763
'si se quisiera a la mitad, sustituir por 0.501764
tamañotexto = G . MeasureString ( t , fuente )01765
01766
'escribe el texto01767
txt3 & = "<text x=""" & Int ( x + 0.7 * ( x2 - x )) & """» y=""" & Int ( y + 0.7 * ( y2 - y )) & """ style="
» "font-family:" & Grafico . Fuente . Name . ToString &
» ";font-size:" & Int ( tamañotexto . Height ) &
» ";fill:rgb(0,0,0);text-anchor:middle;"">" & t &
» "</text>"
01768
txt3 & = vbCrLf01769
End If01770
01771
'punta de flecha destino01772
'-----------------------01773
01774
'calcula vector unitario01775
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )01776
If LV = 0 Then LV = 0.000000101777
'vector unitario de tamaño radio destino01778
x = ( x2 - x ) / LV * Nodos ( Arcos ( i ) . Nd2 ) . Radio * Grafico .» Zoom
01779
y = ( y2 - y ) / LV * Nodos ( Arcos ( i ) . Nd2 ) . Radio * Grafico .» Zoom
01780
01781
'punto de intersección de la línea principal con el» círculo del nodo destino
01782
Xa = x2 - x01783
Ya = y2 - y01784
01785
'cambia el tamaño de la flecha01786
x = x / Nodos ( Arcos ( i ) . Nd2 ) . Radio * 1001787
y = y / Nodos ( Arcos ( i ) . Nd2 ) . Radio * 1001788
'segmento estribor de la punta de la flecha01789
Xb = Xa - x * Arcos ( i ) . Grosor - y / 2 * Arcos ( i ) . Grosor01790
Yb = Ya - y * Arcos ( i ) . Grosor + x / 2 * Arcos ( i ) . Grosor01791
01792
txt2 & = "<line x1=""" & Xb & """ y1=""" & Yb & """ x2=""" &» Xa & """ y2=""" & Ya & """ style=""stroke-width:" &
» Arcos ( i ) . Grosor * Grafico . Zoom & ";stroke:rgb(" & cr &
» "," & cg & "," & cb & ")""></line>"
01793
txt2 & = vbCrLf01794
'segmento babor de la punta de la flecha01795
Xb = Xa - x * Arcos ( i ) . Grosor + y / 2 * Arcos ( i ) . Grosor01796
Yb = Ya - y * Arcos ( i ) . Grosor - x / 2 * Arcos ( i ) . Grosor01797
01798
txt2 & = "<line x1=""" & Xb & """ y1=""" & Yb & """ x2=""" &» Xa & """ y2=""" & Ya & """ style=""stroke-width:" &
» Arcos ( i ) . Grosor * Grafico . Zoom & ";stroke:rgb(" & cr &
» "," & cg & "," & cb & ")""></line>"
01799
txt2 & = vbCrLf01800
01801
'Caso de arco bidireccional01802
'con dos puntas de flecha01803
If Arcos ( i ) . B = True And Grafico . BArco = True Then01804
'punta de flecha origen01805
'-----------------------01806
'toma los nodos al revés y ya está!01807
'toma datos del nodo 101808
x = Nodos ( Arcos ( i ) . Nd2 ) . X * Grafico . Zoom01809
y = Nodos ( Arcos ( i ) . Nd2 ) . Y * Grafico . Zoom01810
01811
'toma datos del nodo 201812
x2 = Nodos ( Arcos ( i ) . Nd1 ) . X * Grafico . Zoom01813
y2 = Nodos ( Arcos ( i ) . Nd1 ) . Y * Grafico . Zoom01814
01815
'calcula vector unitario01816
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )01817
If LV = 0 Then LV = 0.000000101818
'vector unitario de tamaño radio destino01819
x = ( x2 - x ) / LV * Nodos ( Arcos ( i ) . Nd1 ) . Radio *» Grafico . Zoom
01820
y = ( y2 - y ) / LV * Nodos ( Arcos ( i ) . Nd1 ) . Radio *» Grafico . Zoom
01821
01822
'punto de intersección de la línea principal con el» círculo del nodo destino
01823
Xa = x2 - x01824
Ya = y2 - y01825
'cambia el tamaño de la flecha01826
x = x / Nodos ( Arcos ( i ) . Nd1 ) . Radio * 1001827
y = y / Nodos ( Arcos ( i ) . Nd1 ) . Radio * 1001828
'segmento estribor de la punta de la flecha01829
Xb = Xa - x * Arcos ( i ) . Grosor - y / 2 * Arcos ( i ) .» Grosor
01830
Yb = Ya - y * Arcos ( i ) . Grosor + x / 2 * Arcos ( i ) .» Grosor
01831
01832
txt2 & = "<line x1=""" & Xb & """ y1=""" & Yb & """ x2="» "" & Xa & """ y2=""" & Ya & """ style="
» "stroke-width:" & Arcos ( i ) . Grosor * Grafico . Zoom &
» ";stroke:rgb(" & cr & "," & cg & "," & cb & ")"
» "></line>"
01833
txt2 & = vbCrLf01834
'segmento babor de la punta de la flecha01835
Xb = Xa - x * Arcos ( i ) . Grosor + y / 2 * Arcos ( i ) .» Grosor
01836
Yb = Ya - y * Arcos ( i ) . Grosor - x / 2 * Arcos ( i ) .» Grosor
01837
01838
txt2 & = "<line x1=""" & Xb & """ y1=""" & Yb & """ x2="» "" & Xa & """ y2=""" & Ya & """ style="
» "stroke-width:" & Arcos ( i ) . Grosor * Grafico . Zoom &
» ";stroke:rgb(" & cr & "," & cg & "," & cb & ")"
» "></line>"
01839
txt2 & = vbCrLf01840
End If01841
End If01842
Next i01843
01844
txt2 & = "</g>"01845
txt2 & = vbCrLf01846
01847
txt4 & = "<!-- nodos -->"01848
txt4 & = "<g id=""4"">"01849
txt4 & = vbCrLf01850
01851
'----------------------------01852
'Dibuja la colección de Nodos01853
'----------------------------01854
For i = 0 To TotalNodos - 101855
'toma datos del nodo01856
x = Nodos ( i ) . X * Grafico . Zoom01857
y = Nodos ( i ) . Y * Grafico . Zoom01858
radio = Nodos ( i ) . Radio * Grafico . Zoom01859
01860
'condicion de dibujado de ambos textos separados por ecuador01861
'o uno sólo centrado en el nodo01862
Dim condicion As Integer01863
If Grafico . textoNodo = False Or Grafico . costNodo = False Then01864
condicion = 001865
Else01866
condicion = 101867
End If01868
01869
'dibuja nodo en svg01870
txt4 & = "<!-- nodo " & i & " -->"01871
txt4 & = vbCrLf01872
txt4 & = "<ellipse cx=""" & x & """ cy=""" & y & """ rx=""" &» radio & """ ry=""" & radio & """ style=""fill:rgb(" & Nodos ( i
» ) . Col . R & "," & Nodos ( i ) . Col . G & "," & Nodos ( i ) . Col . B &
» ");stroke:rgb(0,0,0);stroke-width:" & Nodos ( i ) . Grosor *
» Grafico . Zoom & ";""/>"
01873
txt4 & = vbCrLf01874
01875
If Grafico . textoNodo And Grafico . costNodo Then01876
'dibuja ecuador del nodo01877
txt4 & = "<line x1=""" & x - radio & """ y1=""" & y & """» x2=""" & x + radio & """ y2=""" & y & """ style="
» "stroke-width:" & Nodos ( i ) . Grosor * Grafico . Zoom &
» ";stroke:rgb(0,0,0)""></line>"
01878
txt4 & = vbCrLf01879
End If01880
If Grafico . textoNodo Then01881
' 'pone texto etiqueta en la mitad superior01882
t = Nodos ( i ) . Texto01883
tamañotexto = G . MeasureString ( t , fuente )01884
txt3 & = "<text x=""" & Int ( x ) & """ y=""" & Int ( y +» tamañotexto . Height * 0.25 - radio / 2 * condicion ) & """
» style=""font-family:" & Grafico . Fuente . Name . ToString &
» ";font-size:" & Int ( tamañotexto . Height ) &
» ";fill:rgb(0,0,0);text-anchor:middle;"">" & t & "</text>"
01885
txt3 & = vbCrLf01886
End If01887
If Grafico . costNodo Then01888
' 'pone texto valor en la mitad inferior01889
t = Nodos ( i ) . Valor . ToString01890
tamañotexto = G . MeasureString ( t , fuente )01891
txt3 & = "<text x=""" & Int ( x ) & """ y=""" & Int ( y +» tamañotexto . Height * 0.25 + radio / 2 * condicion ) & """
» style=""font-family:" & Grafico . Fuente . Name . ToString &
» ";font-size:" & Int ( tamañotexto . Height ) &
» ";fill:rgb(0,0,0);text-anchor:middle;"">" & t & "</text>"
01892
txt3 & = vbCrLf01893
End If01894
Next i01895
'----------------------------01896
txt3 & = "</g>"01897
txt3 & = vbCrLf01898
txt4 & = "</g>"01899
txt4 & = vbCrLf01900
01901
'consolida todos los textos01902
'lo último en dibujar son los textos,01903
'las capas van de izq a dcha. y de abajo a arriba.01904
txt & = txt0 & txt1 & txt2 & txt4 & txt301905
01906
'pie del fichero xml01907
txt & = "</g></svg>"01908
'Guarda el fichero .svg01909
EscribeFicheroTexto ( fichero , txt )01910
01911
'fichero .htm anexo que permite activar/desactivar capas01912
txt = "<HTML>"01913
txt & = vbCrLf & "<HEAD>"01914
txt & = vbCrLf & "<TITLE>Grafo en formato SVG - (cc) 2003..2005 -» Alejandro Rodriguez Villalobos</TITLE>"
01915
txt & = vbCrLf & "<SCRIPT LANGUAGE=""JavaScript1.2""><!--"01916
txt & = vbCrLf & "/*"01917
txt & = vbCrLf & "* Esta función activa/desactiva las capas de la» imagen SVG."
01918
txt & = vbCrLf & "* Para ello hay que hacer click en los checkbox del» lateral."
01919
txt & = vbCrLf & "*"01920
txt & = vbCrLf & "* Input Parameters:"01921
txt & = vbCrLf & "* checkbox - Form object (checkbox) that was» clicked on."
01922
txt & = vbCrLf & "* element_name - SVG element name that should be» made visible/"
01923
txt & = vbCrLf & "* invisible."01924
txt & = vbCrLf & "*/"01925
txt & = vbCrLf & "function hilite_elem (checkbox, element_name)"01926
txt & = vbCrLf & "{"01927
txt & = vbCrLf & " var svgobj;"01928
txt & = vbCrLf & " var svgstyle;"01929
txt & = vbCrLf & " var svgdoc = document.network.getSVGDocument();"01930
txt & = vbCrLf & " // For selected element, get the elements style» object, then set"
01931
txt & = vbCrLf & " // its visibility according to the state of the» checkbox."
01932
txt & = vbCrLf & " svgobj = svgdoc.getElementById(element_name);"01933
txt & = vbCrLf & " svgstyle = svgobj.getStyle();"01934
txt & = vbCrLf & " if (!checkbox.checked) "01935
txt & = vbCrLf & " { // Hide layer."01936
txt & = vbCrLf & " svgstyle.setProperty('visibility',» 'hidden');"
01937
txt & = vbCrLf & " }"01938
txt & = vbCrLf & " else"01939
txt & = vbCrLf & " { // SHow layer."01940
txt & = vbCrLf & " svgstyle.setProperty('visibility',» 'visible');"
01941
txt & = vbCrLf & " }"01942
txt & = vbCrLf & "}"01943
txt & = vbCrLf & "// -->"01944
txt & = vbCrLf & "</SCRIPT>"01945
txt & = vbCrLf & " </HEAD>"01946
txt & = vbCrLf & "<BODY>"01947
txt & = vbCrLf & "<center>"01948
txt & = vbCrLf & "<table><tr><td>"01949
txt & = vbCrLf & "<EMBED SRC=""" & fichero & " "" NAME=""network"""01950
txt & = vbCrLf & " HEIGHT=""555.00"" WIDTH=""887.00"""01951
txt & = vbCrLf & " TYPE=""image/svg-xml"""01952
txt & = vbCrLf & " PLUGINSPAGE="» "http://www.adobe.com/svg/viewer/install/"">"
01953
txt & = vbCrLf & "</td><td>"01954
txt & = vbCrLf & "<FORM NAME=""hilite_form"">"01955
txt & = vbCrLf & " <TABLE BORDER=""0"" CELLPADDING=""0""» CELLSPACING=""2"" WIDTH=""100%"">"
01956
txt & = vbCrLf & " <TR>"01957
txt & = vbCrLf & " <TD><INPUT TYPE=""checkbox"" VALUE="""" ONCLICK="» "hilite_elem(this,0)"">Tapiz</TD></tr>"
01958
txt & = vbCrLf & " <TD><INPUT TYPE=""checkbox"" VALUE="""" ONCLICK="» "hilite_elem(this,1)"">Rejilla</TD></tr>"
01959
txt & = vbCrLf & " <TD><INPUT TYPE=""checkbox"" VALUE="""" ONCLICK="» "hilite_elem(this,2)"">Arcos</TD></tr>"
01960
txt & = vbCrLf & " <TD><INPUT TYPE=""checkbox"" VALUE="""" ONCLICK="» "hilite_elem(this,3)"">Textos</TD></tr>"
01961
txt & = vbCrLf & " </TABLE>"01962
txt & = vbCrLf & "<SCRIPT><!--"01963
txt & = vbCrLf & " // Make sure all checkboxes are checked whenever» the page"
01964
txt & = vbCrLf & " // is reloaded in the browser."01965
txt & = vbCrLf & " for (var i = 0; i <» document.hilite_form.elements.length; i++)"
01966
txt & = vbCrLf & " if (document.hilite_form.elements[i].type ==» 'checkbox')"
01967
txt & = vbCrLf & " document.hilite_form.elements[i].checked =» true;"
01968
txt & = vbCrLf & " // -->"01969
txt & = vbCrLf & "</SCRIPT>"01970
txt & = vbCrLf & "</FORM>"01971
txt & = vbCrLf & "</td></tr>"01972
txt & = vbCrLf & "</table>"01973
txt & = vbCrLf & " </center>"01974
txt & = vbCrLf & "</BODY>"01975
txt & = vbCrLf & "</HTML>"01976
'Guarda el fichero .htm01977
EscribeFicheroTexto ( fichero & ".htm" , txt )01978
01979
'Intercepción de posibles errores al dibujar01980
Catch ex As Exception01981
Me . Cursor = Cursors . Default01982
MsgBox ( "Ha fallado el proceso de exportación gráfica a .svg" &» vbCrLf & ex . Message , MsgBoxStyle . Exclamation , "Grafos -
» Excepción" )
01983
Exit Sub01984
Finally01985
End Try01986
End Sub01987
Function BuscaArcoSimetrico ( ByVal i As Long ) As Long01988
'Busca un arco simétrico al pasado como parámetro01989
'para ser fusionado en el grafo (en caso de opción bidireccional)01990
'y que aparezca sólo un arco con doble flecha01991
Dim j As Long01992
For j = 0 To TotalArcos - 101993
'que no sea él mismo01994
If j <> i Then01995
01996
'coincide dirección y sentido inverso01997
If Arcos ( i ) . Nd1 = Arcos ( j ) . Nd2 And Arcos ( i ) . Nd2 = Arcos ( j ) . Nd1» Then
01998
01999
'coinciden valores02000
If Arcos ( i ) . Min = Arcos ( j ) . Min And Arcos ( i ) . Max = Arcos ( j )» . Max And Arcos ( i ) . Coste = Arcos ( j ) . Coste Then
02001
'encontrado02002
Return j02003
End If02004
End If02005
End If02006
Next j02007
02008
Return - 102009
End Function02010
Private Sub PictureBox1_MouseMove ( ByVal sender As Object , ByVal e As System .» Windows . Forms . MouseEventArgs ) Handles PictureBox1 . MouseMove
02011
02012
'Muestra en el panel de estado las coordenadas del ratón en movimiento.02013
StatusBar . Panels ( 0 ) . Text = "X = " & e . X . ToString02014
StatusBar . Panels ( 1 ) . Text = "Y = " & e . Y . ToString02015
Dim nd As Long02016
nd = XYSobreNodo ( e . X , e . Y )02017
If nd <> - 1 Then02018
StatusBar . Panels ( 2 ) . Text = "Nodo = " & Nodos ( nd ) . Texto02019
Else02020
StatusBar . Panels ( 2 ) . Text = " "02021
End If02022
02023
If e . Button = MouseButtons . Left And Nd1S <> - 1 Then02024
'redondea el valor de las coordenadas al ancho de la rejilla02025
'si la opción imán está seleccionada en el menú02026
If mnuFormatoIman . Checked = True Then02027
Nodos ( Nd1S ) . X = Int (( e . X - XNuevo ) / Grafico . Zoom / Grafico .» Rejilla ) * Grafico . Rejilla
02028
Nodos ( Nd1S ) . Y = Int (( e . Y - YNuevo ) / Grafico . Zoom / Grafico .» Rejilla ) * Grafico . Rejilla
02029
Else02030
'sino, toma los valores tal cual02031
'Nodos(Nd1S).X = e.X / Grafico.Zoom02032
'Nodos(Nd1S).Y = e.Y / Grafico.Zoom02033
' If e.X / Grafico.Zoom <> XNuevo Or e.Y / Grafico.Zoom <>» YNuevo Then
02034
Nodos ( Nd1S ) . X = ( e . X - XNuevo ) / Grafico . Zoom02035
Nodos ( Nd1S ) . Y = ( e . Y - YNuevo ) / Grafico . Zoom02036
'End If02037
End If02038
02039
DibujaGrafo ()02040
PictureBox1 . Refresh ()02041
02042
End If02043
02044
'Activa o desactiva menús de análisis02045
'debe existir al menos un arco para tener un grafo02046
If TotalArcos > 0 Then02047
mnuAnalisisDijkstra . Enabled = True02048
mnuAnalisisDijkstraCC . Enabled = True02049
mnuAnalisisDijkstraCM . Enabled = True02050
mnuAnalisisDijkstraMax . Enabled = True02051
mnuAnalisisBellmanFordCmin . Enabled = True02052
mnuAnalisisBellmanFordCmax . Enabled = True02053
mnuAnalisisFordFulkersonMax . Enabled = True02054
02055
mnuAnalisisKruskalmin . Enabled = True02056
mnuAnalisisKruskalmax . Enabled = True02057
mnuAnalisisPrimMin . Enabled = True02058
mnuAnalisisPrimMax . Enabled = True02059
mnuAnalisisFloydWarshallmin . Enabled = True02060
mnuAnalisis_Transbordo . Enabled = True02061
mnuAnalisis_TSP . Enabled = True02062
Else02063
mnuAnalisisDijkstra . Enabled = False02064
mnuAnalisisDijkstraCC . Enabled = False02065
mnuAnalisisDijkstraCM . Enabled = False02066
mnuAnalisisDijkstraMax . Enabled = False02067
mnuAnalisisBellmanFordCmin . Enabled = False02068
mnuAnalisisBellmanFordCmax . Enabled = False02069
mnuAnalisisFordFulkersonMax . Enabled = False02070
02071
mnuAnalisisKruskalmin . Enabled = False02072
mnuAnalisisKruskalmax . Enabled = False02073
mnuAnalisisPrimMin . Enabled = False02074
mnuAnalisisPrimMax . Enabled = False02075
mnuAnalisisFloydWarshallmin . Enabled = False02076
mnuAnalisis_Transbordo . Enabled = False02077
mnuAnalisis_TSP . Enabled = False02078
End If02079
End Sub02080
Function XYSobreNodo ( ByVal x As Single , ByVal y As Single ) As Long02081
02082
Dim i As Long02083
Dim Dist As Single02084
02085
Dim minDist As Single02086
Dim NdProx As Long02087
02088
minDist = 100000000000000000002089
NdProx = - 102090
02091
For i = 0 To UBound ( Nodos )02092
Dist = Math . Sqrt (( x - Nodos ( i ) . X * Grafico . Zoom ) ^ 2 + ( y - Nodos (» i ) . Y * Grafico . Zoom ) ^ 2 )
02093
If Dist <= minDist And Dist <= Nodos ( i ) . Radio * Grafico . Zoom Then02094
minDist = Dist02095
NdProx = i02096
End If02097
Next i02098
02099
Return NdProx02100
End Function02101
Private Sub mnuFormatoRejilla_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoRejilla . Click
02102
'Activa o desactiva la visualización de la rejilla02103
If mnuFormatoRejilla . Checked = True Then02104
mnuFormatoRejilla . Checked = False02105
Grafico . MostrarRejilla = False02106
CajaPropiedades . chkMostrarRejilla . Checked = False02107
DibujaGrafo () 'redibuja el grafo02108
Else02109
mnuFormatoRejilla . Checked = True02110
Grafico . MostrarRejilla = True02111
CajaPropiedades . chkMostrarRejilla . Checked = True02112
02113
DibujaGrafo () 'redibuja el grafo02114
End If02115
02116
End Sub02117
Private Sub mnuArchivoImprimir_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuArchivoImprimir . Click
02118
'Muestra el diálogo de previsualización02119
'que a su vez llama al evento PrintPage de PrintDocument102120
02121
Try02122
PrintPreviewDialog1 . Document = PrintDocument102123
PrintPreviewDialog1 . ShowDialog ()02124
02125
'si ocurriera algún error lo muestra en pantalla02126
Catch ex As Exception02127
MsgBox ( "Ha fallado la operación de impresión." & vbCrLf & ex . Message» , MsgBoxStyle . Exclamation , "Grafos - Excepción" )
02128
End Try02129
02130
End Sub02131
Private Sub mnuArchivoConfigurarPag_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuArchivoConfigurarPag . Click
02132
'Establece configuración de página02133
With PageSetupDialog102134
. PageSettings = PrintDocument1 . DefaultPageSettings02135
If . ShowDialog () = DialogResult . OK Then02136
PrintDocument1 . DefaultPageSettings = . PageSettings02137
End If02138
End With02139
End Sub02140
Private Sub mnuArchivoConfigurarImp_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuArchivoConfigurarImp . Click
02141
'Configura impresora y parámetros de impresión02142
With PrintDialog102143
. PrinterSettings = PrintDocument1 . PrinterSettings02144
If . ShowDialog () = DialogResult . OK Then02145
PrintDocument1 . PrinterSettings = . PrinterSettings02146
End If02147
End With02148
End Sub02149
Private Sub PrintDocument1_PrintPage ( ByVal sender As Object , ByVal e As» System . Drawing . Printing . PrintPageEventArgs ) Handles PrintDocument1 .
» PrintPage
02150
'Es llamado por el previsualizador02151
'rellena el PrintDocument con la imagen del picturebox02152
'ajustada al tamaño de página.02153
Me . Cursor = Cursors . WaitCursor02154
Dim r As Rectangle02155
Dim pw , ph , pl , pt As Integer02156
02157
pw = PictureBox1 . Width02158
ph = PictureBox1 . Height02159
'si la imagen del picturebox es más pequeña que la página la centra en» ella
02160
'si no se cortará!!!! (ver posibilidad de ajustar)02161
With PrintDocument1 . DefaultPageSettings . PaperSize02162
If pw < . Width Then02163
pl = ( . Width - pw ) / 202164
Else02165
pl = 002166
End If02167
If ph < . Height Then02168
pt = ( . Height - ph ) / 202169
Else02170
pt = 002171
End If02172
End With02173
02174
'dibuja la imagen en la impresora02175
r = New Rectangle ( pl , pt , pw , ph )02176
e . Graphics . DrawImage ( PictureBox1 . Image , r )02177
Me . Cursor = Cursors . Default02178
End Sub02179
Private Sub PictureBox1_MouseDown ( ByVal sender As Object , ByVal e As System .» Windows . Forms . MouseEventArgs ) Handles PictureBox1 . MouseDown
02180
Dim nd As Long02181
'Selección del nodo origen02182
If e . Button = MouseButtons . Left Then02183
nd = XYSobreNodo ( e . X , e . Y )02184
If nd <> - 1 Then02185
Nd1S = nd02186
'If Nd1S = Nd2S Then02187
'Nd2S = -1 'si selecciona encima del nd2s, deselecciona el nd2s02188
'End If02189
02190
'PRUEBA ALEX02191
'PUNTOS PANTALLA02192
XNuevo = ( e . X - Nodos ( nd ) . X * Grafico . Zoom )02193
YNuevo = ( e . Y - Nodos ( nd ) . Y * Grafico . Zoom )02194
02195
Else02196
Nd1S = - 102197
End If02198
DibujaGrafo ()02199
End If02200
02201
'Selección del nodo destino02202
If e . Button = MouseButtons . Right Then02203
02204
'Guarda coordenadas para la creación de un nuevo nodo02205
XNuevo = e . X / Grafico . Zoom02206
YNuevo = e . Y / Grafico . Zoom02207
02208
nd = XYSobreNodo ( e . X , e . Y )02209
If nd <> - 1 Then02210
Nd2S = nd02211
'If Nd2S = Nd1S Then02212
' Nd1S = -1 'si selecciona encima del nd1s, deselecciona el» nd1s
02213
'End If02214
Else02215
Nd2S = - 102216
End If02217
DibujaGrafo ()02218
End If02219
02220
'evita errores de selección fuera de rango02221
If Nd1S > TotalNodos - 1 Then Nd1S = - 102222
If Nd2S > TotalNodos - 1 Then Nd2S = - 102223
02224
'Cambia visualizaciones según las selecciones02225
'según el nodo seleccionado02226
If Nd1S = - 1 Then02227
StatusBar . Panels ( 3 ) . Text = "-"02228
02229
mnuAnalisisDijkstra . Enabled = False02230
mnuAnalisisDijkstraMax . Enabled = False02231
Else02232
StatusBar . Panels ( 3 ) . Text = "Nd1 = " & Nodos ( Nd1S ) . Texto02233
02234
mnuAnalisisDijkstra . Enabled = True02235
mnuAnalisisDijkstraMax . Enabled = True02236
End If02237
If Nd2S = - 1 Then02238
StatusBar . Panels ( 4 ) . Text = "-"02239
mnuBorrarNodo . Enabled = False02240
mnuEditarNodo . Enabled = False02241
Else02242
StatusBar . Panels ( 4 ) . Text = "Nd2 = " & Nodos ( Nd2S ) . Texto02243
mnuBorrarNodo . Enabled = True02244
mnuEditarNodo . Enabled = True02245
End If02246
'dos nodos seleccionados02247
If Nd1S <> - 1 And Nd2S <> - 1 Then 'And Nd1S <> Nd2S Then02248
Dim nArcos As Long02249
nArcos = ExisteArco ( Nd1S , Nd2S )02250
Dim nArcosR As Long02251
nArcosR = ExisteArcoReves ( Nd1S , Nd2S )02252
'comprobaciones02253
'If nArcos > 0 Or nArcosR > 0 Then 'sólo un arco y en un sólo» sentido
02254
If nArcos > 0 Then 'dos arcos si son en sentidos opuestos02255
mnuAñadirArco . Enabled = False02256
Else02257
mnuAñadirArco . Enabled = True02258
End If02259
If nArcos = 0 Then02260
'no se puede borrar y editar algo que no existe02261
mnuBorrarArco . Enabled = False02262
mnuEditarArco . Enabled = False02263
Else02264
'si existe si se puede borrar y editar02265
mnuBorrarArco . Enabled = True02266
mnuEditarArco . Enabled = True02267
02268
End If02269
mnuAlinearNodos . Enabled = True02270
mnuAnalisisDijkstraCC . Enabled = True02271
mnuAnalisisDijkstraCM . Enabled = True02272
mnuAnalisisBellmanFordCmax . Enabled = True02273
mnuAnalisisBellmanFordCmin . Enabled = True02274
mnuAnalisisFordFulkersonMax . Enabled = True02275
Else02276
'si no se seleccionan dos no se pueden efectuar operaciones de arco02277
mnuAñadirArco . Enabled = False02278
mnuBorrarArco . Enabled = False02279
mnuEditarArco . Enabled = False02280
mnuAlinearNodos . Enabled = False02281
mnuAnalisisDijkstraCC . Enabled = False02282
mnuAnalisisDijkstraCM . Enabled = False02283
mnuAnalisisBellmanFordCmax . Enabled = False02284
mnuAnalisisBellmanFordCmin . Enabled = False02285
mnuAnalisisFordFulkersonMax . Enabled = False02286
End If02287
02288
If Nd1S = Nd2S Then mnuAlinearNodos . Enabled = False02289
End Sub02290
Private Sub mnuAñadirArco_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuAñadirArco . Click
02291
'Añade un arco nuevo a la colección02292
'El arco no puede ser entre un mismo nodo02293
'If Nd1S = Nd2S Then Exit Sub02294
02295
Dim i As Long02296
'i = UBound(Arcos) + 102297
TotalArcos = TotalArcos + 102298
02299
ReDim Preserve Arcos ( TotalArcos - 1 )02300
i = TotalArcos - 102301
Arcos ( i ) . Nd1 = Nd1S02302
Arcos ( i ) . Nd2 = Nd2S02303
02304
Arcos ( i ) . Min = 002305
Arcos ( i ) . Max = 002306
Arcos ( i ) . Coste = 002307
02308
'tomar opciones gráficas de la configuración por defecto02309
Arcos ( i ) . B = False 'por defecto false, se trata en DibujaGrafo02310
02311
Arcos ( i ) . Grosor = Grafico . TrazoArco02312
Arcos ( i ) . Col = Grafico . ColArco02313
02314
DibujaGrafo ()02315
End Sub02316
Private Sub mnuAñadirNodo_Click ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles mnuAñadirNodo . Click
02317
'Añade un nodo nuevo a la colección02318
02319
Dim i As Long02320
' i = UBound(Nodos) + 102321
02322
If TotalNodos = 200 Then Exit Sub02323
02324
TotalNodos = TotalNodos + 102325
02326
ReDim Preserve Nodos ( TotalNodos - 1 )02327
i = TotalNodos - 1 'ultimo nodo02328
Nodos ( i ) . X = XNuevo02329
Nodos ( i ) . Y = YNuevo02330
Nodos ( i ) . Z = 002331
02332
If Grafico . Iman Then02333
Nodos ( i ) . X = Int ( Nodos ( i ) . X / Grafico . Rejilla ) * Grafico . Rejilla02334
Nodos ( i ) . Y = Int ( Nodos ( i ) . Y / Grafico . Rejilla ) * Grafico . Rejilla02335
End If02336
02337
'tomará datos de un formulario02338
Nodos ( i ) . Texto = i . ToString02339
Nodos ( i ) . Valor = 002340
'tomar opciones gráficas de la configuración por defecto02341
'si no peta cuando el grafo está vacio y se pone el primer nodo02342
Nodos ( i ) . Radio = Grafico . RadioNodo 'todos los radios iguales02343
Nodos ( i ) . Grosor = Grafico . TrazoNodo02344
Nodos ( i ) . Col = Grafico . ColNodo02345
02346
DibujaGrafo ()02347
End Sub02348
Sub BorraArco ( ByVal n As Long )02349
'Redimensiona la matriz de arcos para borrar el arco seleccionado02350
Dim i As Long02351
02352
If n > TotalArcos - 1 Or n < 0 Then Exit Sub02353
02354
If n = TotalArcos - 1 Then 'se borra el último02355
ReDim Preserve Arcos ( TotalArcos - 1 - 1 )02356
Else 'se corren los valores02357
For i = n To TotalArcos - 1 - 102358
Arcos ( i ) = Arcos ( i + 1 )02359
Next i02360
ReDim Preserve Arcos ( TotalArcos - 1 - 1 )02361
End If02362
02363
TotalArcos = TotalArcos - 102364
End Sub02365
Private Sub mnuBorrarNodo_Click ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles mnuBorrarNodo . Click
02366
Dim i As Long02367
Dim total As Long02368
02369
'debe recorrer los arcos02370
If TotalArcos > 0 Then02371
i = 002372
Do While i <= TotalArcos - 102373
02374
If Arcos ( i ) . Nd1 = Nd2S Or Arcos ( i ) . Nd2 = Nd2S Then02375
BorraArco ( i ) 'borrar el que tenga ese nodo seleccionado02376
i = - 1 'vuelve a empezar el recorrido02377
End If02378
i = i + 102379
02380
'así hasta no encontrar más arcos con ese nodo02381
Loop02382
End If02383
'renumera nodos superiores al que se va a borrar02384
'por la traslación de indices hacia abajo que hay02385
'en el proceso de borrar nodo02386
For i = 0 To TotalArcos - 102387
If Arcos ( i ) . Nd1 > Nd2S Then Arcos ( i ) . Nd1 = Arcos ( i ) . Nd1 - 102388
If Arcos ( i ) . Nd2 > Nd2S Then Arcos ( i ) . Nd2 = Arcos ( i ) . Nd2 - 102389
Next02390
02391
total = UBound ( Nodos ) 'ultimo nodo02392
02393
If Nd2S = total Then 'se borra el último02394
'If total = 0 'Then ATENCION se borra el único existente????02395
02396
ReDim Preserve Nodos ( total - 1 )02397
Else02398
For i = Nd2S To total - 102399
Nodos ( i ) = Nodos ( i + 1 )02400
Next i02401
02402
'If total = 0 'Then ATENCION se borra el único existente????02403
02404
ReDim Preserve Nodos ( total - 1 )02405
End If02406
02407
TotalNodos = TotalNodos - 102408
02409
'no selecciona segundo nodo02410
Nd2S = - 102411
StatusBar . Panels ( 4 ) . Text = ""02412
02413
DibujaGrafo ()02414
End Sub02415
Private Sub mnuBorrarArco_Click ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles mnuBorrarArco . Click
02416
'busca en la colección de arcos el que cumple/los que cumplen las02417
'condiciones de origen y destino de nodos seleccionados02418
'una vez localizados los borra uno a uno02419
Dim i As Long02420
02421
i = 002422
Do While i <= TotalArcos - 102423
02424
If Arcos ( i ) . Nd1 = Nd1S And Arcos ( i ) . Nd2 = Nd2S Then02425
BorraArco ( i )02426
i = - 1 'vuelve a empezar el recorrido02427
End If02428
i = i + 102429
02430
'así hasta no encontrar más arcos con esa condición02431
Loop02432
DibujaGrafo ()02433
End Sub02434
Private Sub mnuZoomMas_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuZoomMas . Click
02435
'Va subiendo los valores del zoom hasta 4 = 400%02436
If Grafico . Zoom < 4 Then Grafico . Zoom = Grafico . Zoom + 0.202437
02438
DibujaGrafo ()02439
End Sub02440
Private Sub mnuZoomMenos_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuZoomMenos . Click
02441
'Baja los valores del zoom hasta llegar a un 0.2 = 20%02442
If Grafico . Zoom > 0.4 Then Grafico . Zoom = Grafico . Zoom - 0.202443
02444
DibujaGrafo ()02445
End Sub02446
Private Sub mnuZoomAjustar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuZoomAjustar . Click
02447
If TotalNodos < 2 Then Exit Sub02448
Dim i As Long02449
02450
Dim minX As Single = 100000000002451
Dim minY As Single = 100000000002452
Dim maxX As Single = - 100000000002453
Dim maxY As Single = - 100000000002454
02455
Dim zoomx As Single02456
Dim zoomy As Single02457
02458
For i = 0 To TotalNodos - 102459
02460
minX = Math . Min ( Nodos ( i ) . X - Nodos ( i ) . Radio , minX )02461
minY = Math . Min ( Nodos ( i ) . Y - Nodos ( i ) . Radio , minY )02462
02463
maxX = Math . Max ( Nodos ( i ) . X + Nodos ( i ) . Radio , maxX )02464
maxY = Math . Max ( Nodos ( i ) . Y + Nodos ( i ) . Radio , maxY )02465
Next i02466
02467
zoomx = ( Panel1 . Width - 20 ) / ( maxX - minX )02468
zoomy = ( Panel1 . Height - 20 ) / ( maxY - minY )02469
02470
If zoomx > zoomy Then Grafico . Zoom = zoomy Else Grafico . Zoom = zoomx02471
minX = minX - 2002472
minY = minY - 2002473
02474
DibujaGrafo ()02475
02476
'Panel1.AutoScroll = False02477
Dim p As Point02478
If minX * Grafico . Zoom <= 0 Then02479
p . X = 002480
Else02481
p . X = minX * Grafico . Zoom02482
End If02483
02484
If minY * Grafico . Zoom <= 0 Then02485
p . Y = 002486
Else02487
p . Y = minY * Grafico . Zoom02488
End If02489
02490
PictureBox1 . Left = 002491
PictureBox1 . Top = 002492
02493
Panel1 . AutoScrollPosition = p02494
02495
'Pone la información de zoom en panel02496
StatusBar . Panels ( 5 ) . Text = "Zoom = " & Format ( Grafico . Zoom , "#0.00" )02497
End Sub02498
Sub ActivaMenus ()02499
02500
Me . mnuArchivoGuardar . Enabled = True02501
Me . mnuArchivoGuardarComo . Enabled = True02502
Me . mnuArchivoNuevoAleatorio . Enabled = True02503
Me . mnuArchivoExportarDatos . Enabled = True02504
Me . mnuArchivoImportarDatos . Enabled = True02505
Me . mnuArchivoCopiarImg . Enabled = True02506
Me . mnuArchivoExportarImg . Enabled = True02507
Me . mnuArchivoConfigurarPag . Enabled = True02508
Me . mnuArchivoImprimir . Enabled = True02509
Me . mnuEdicion . Enabled = True02510
Me . mnuFormato . Enabled = True02511
Me . mnuFormatoOpciones . Enabled = True02512
Me . mnuAnalisis . Enabled = True02513
02514
Me . mnuAnalisisBellmanFordCmax . Enabled = False02515
Me . mnuAnalisisBellmanFordCmin . Enabled = False02516
Me . mnuAnalisisDijkstra . Enabled = False02517
Me . mnuAnalisisDijkstraCC . Enabled = False02518
Me . mnuAnalisisDijkstraCM . Enabled = False02519
Me . mnuAnalisisDijkstraMax . Enabled = False02520
Me . mnuAnalisisKruskalmax . Enabled = False02521
Me . mnuAnalisisKruskalmin . Enabled = False02522
Me . mnuAnalisisPrimMax . Enabled = False02523
Me . mnuAnalisisPrimMin . Enabled = False02524
Me . mnuAnalisisFordFulkersonMax . Enabled = False02525
Me . mnuAnalisisFloydWarshallmin . Enabled = False02526
02527
Me . mnuAnalisis_Transbordo . Enabled = False02528
Me . mnuAnalisis_TSP . Enabled = False02529
02530
End Sub02531
Private Sub mnuArchivoNuevo_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuArchivoNuevo . Click
02532
02533
If TotalNodos > 0 Or NodosMatriz > 0 Then02534
Dim respuesta As MsgBoxResult02535
respuesta = MsgBox ( " Si no ha grabado las últimas modificaciones,» perderá los datos actuales." & vbCrLf & " ¿Desea realmente crear
» un nuevo grafo?" , MsgBoxStyle . OKCancel , )
02536
If respuesta = MsgBoxResult . Cancel Then Exit Sub02537
End If02538
'nombre del fichero en estatus bar02539
Me . StatusBar . Panels ( 6 ) . Text = ""02540
02541
'lee las opciones por defecto02542
OpcionesporDefecto ()02543
02544
'inicia la caja de propiedades con las opciones por defecto elegidas02545
CajaPropiedades . LeeOpciones ()02546
02547
'Cambia y posiciona el picturebox02548
PictureBox1 . Top = 002549
PictureBox1 . Left = 002550
PictureBox1 . Width = Grafico . TapizX * Grafico . Zoom02551
PictureBox1 . Height = Grafico . TapizX * Grafico . Zoom02552
02553
TotalNodos = 002554
TotalArcos = 002555
NodosMatriz = 002556
02557
'no selecciona ningún nodo02558
Nd1S = - 102559
Nd2S = - 102560
02561
'Llama al proceso principal de dibujar grafo02562
DibujaGrafo ()02563
Grafico . Fichero = ""02564
Grafico . Extension = ".graphML" 'extensión por defecto .graphML02565
02566
PictureBox1 . Visible = True02567
ActivaMenus ()02568
Me . mnuEdicionGrafica_Click ( Me , e )02569
End Sub02570
Sub CreaGrafoAleatorio ( ByVal n As Long , ByVal a As Long , ByVal r As Boolean )02571
'Crea un grafo aleatorio02572
If n > 200 Then Exit Sub02573
02574
TotalNodos = n02575
ReDim Nodos ( TotalNodos - 1 )02576
02577
Dim i , j , k As Integer02578
'Crea una colección de nodos02579
For i = 0 To TotalNodos - 102580
Nodos ( i ) . Texto = i . ToString02581
Nodos ( i ) . X = Rnd () * Grafico . TapizX02582
Nodos ( i ) . Y = Rnd () * Grafico . TapizY02583
Nodos ( i ) . Col = Grafico . ColNodo02584
02585
Nodos ( i ) . Radio = Grafico . RadioNodo02586
Nodos ( i ) . Grosor = Grafico . TrazoNodo02587
Nodos ( i ) . Valor = 002588
Next i02589
'Crea una colección de arcos02590
02591
TotalArcos = 002592
ReDim Arcos ( 0 )02593
Dim sigue As Boolean02594
For i = 0 To TotalNodos - 102595
For j = 0 To TotalNodos - 102596
If 100 * Rnd () < a And a > 0 Then02597
sigue = True02598
If r = True And i = j Then sigue = True02599
If r = False And i = j Then sigue = False02600
If i <> j Then sigue = True02601
02602
If sigue Then02603
TotalArcos = TotalArcos + 102604
ReDim Preserve Arcos ( TotalArcos - 1 )02605
02606
Arcos ( TotalArcos - 1 ) . Texto = i . ToString02607
Arcos ( TotalArcos - 1 ) . Col = Grafico . ColArco02608
Arcos ( TotalArcos - 1 ) . Grosor = Grafico . TrazoNodo02609
02610
Arcos ( TotalArcos - 1 ) . Min = 002611
Arcos ( TotalArcos - 1 ) . Max = 002612
Arcos ( TotalArcos - 1 ) . Coste = 002613
02614
Arcos ( TotalArcos - 1 ) . Nd1 = i02615
Arcos ( TotalArcos - 1 ) . Nd2 = j02616
End If02617
End If02618
Next j02619
Next i02620
End Sub02621
Private Sub mnuFormatoIman_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuFormatoIman . Click
02622
'Activa o desactiva la opción de redondeo de rejilla02623
If mnuFormatoIman . Checked = True Then02624
mnuFormatoIman . Checked = False02625
Grafico . Iman = False02626
CajaPropiedades . chkIman . Checked = False02627
Else02628
mnuFormatoIman . Checked = True02629
Grafico . Iman = True02630
CajaPropiedades . chkIman . Checked = True02631
End If02632
End Sub02633
Private Sub mnuArchivoSalir_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuArchivoSalir . Click
02634
'Sale del programa pidiendo antes confirmación02635
Dim respuesta As MsgBoxResult02636
respuesta = MsgBox ( "¿Desea realmente finalizar el programa?" ,» MsgBoxStyle . OKCancel , )
02637
If respuesta = MsgBoxResult . OK Then End02638
End Sub02639
Private Sub mnuArchivoGuardar_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuArchivoGuardar . Click
02640
If TotalNodos < 1 Then02641
MsgBox ( "Debe de crear primero algún nodo" , MsgBoxStyle . Information ,» "Grafos - Guardar" )
02642
Exit Sub02643
End If02644
02645
If Grafico . Fichero = "" Then02646
'Debe elegir un nombre para el fichero02647
Me . mnuArchivoGuardarComo_Click ( sender , e ) 'vuelve a 'Guardar» como..'
02648
If Grafico . Fichero = "" Then Exit Sub02649
End If02650
02651
'Diferencia rutinas de guardar en función02652
'del formato de fichero seleccionado (.graphML, .grf )02653
Me . Cursor = Cursors . WaitCursor02654
Me . StatusBar . Panels ( 6 ) . Text = Grafico . Fichero02655
02656
Select Case Grafico . Extension02657
Case ".grf" 'Extensión propietaria .grf02658
GuardaFicheroGRF ()02659
Case ".graphML" 'Extensión por defecto .graphML02660
GuardaFicheroGraphML ( Grafico . Fichero )02661
Case Else02662
GuardaFicheroGRF ()02663
End Select02664
02665
Me . Cursor = Cursors . Default02666
02667
End Sub02668
Private Sub GuardaFicheroGRF ()02669
'Guarda el grafo en formato propietario .grf02670
'Este formato es secuencial, y tal vez se deje de usar en futuras» versiones
02671
'del(programa)02672
'la pequeña ventaja es que generará ficheros de menor tamaño02673
02674
'Abre el fichero para guardar02675
Try02676
FileOpen ( 1 , Grafico . Fichero , OpenMode . Output , OpenAccess . Write )02677
02678
WriteLine ( 1 , "Grafos - (cc) 2003..2005 - Alejandro Rodríguez» Villalobos" )
02679
WriteLine ( 1 , "versión: 1.0.0" )02680
02681
'Opciones generales02682
WriteLine ( 1 , Grafico . Zoom )02683
WriteLine ( 1 , Grafico . Rejilla )02684
02685
WriteLine ( 1 , Grafico . TapizX )02686
WriteLine ( 1 , Grafico . TapizY )02687
02688
WriteLine ( 1 , Grafico . ColorRejilla . A )02689
WriteLine ( 1 , Grafico . ColorRejilla . R )02690
WriteLine ( 1 , Grafico . ColorRejilla . G )02691
WriteLine ( 1 , Grafico . ColorRejilla . B )02692
02693
WriteLine ( 1 , Grafico . ColorTapiz . A )02694
WriteLine ( 1 , Grafico . ColorTapiz . R )02695
WriteLine ( 1 , Grafico . ColorTapiz . G )02696
WriteLine ( 1 , Grafico . ColorTapiz . B )02697
02698
'nodo02699
WriteLine ( 1 , Grafico . Fuente . Name )02700
WriteLine ( 1 , Grafico . Fuente . Size )02701
WriteLine ( 1 , Grafico . Fuente . Style )02702
02703
WriteLine ( 1 , Grafico . TrazoNodo )02704
WriteLine ( 1 , Grafico . RadioNodo )02705
WriteLine ( 1 , Grafico . ColNodo . A )02706
WriteLine ( 1 , Grafico . ColNodo . R )02707
WriteLine ( 1 , Grafico . ColNodo . G )02708
WriteLine ( 1 , Grafico . ColNodo . B )02709
02710
WriteLine ( 1 , Grafico . textoNodo )02711
WriteLine ( 1 , Grafico . costNodo )02712
02713
'arco02714
WriteLine ( 1 , Grafico . minArco )02715
WriteLine ( 1 , Grafico . maxArco )02716
WriteLine ( 1 , Grafico . costArco )02717
WriteLine ( 1 , Grafico . TrazoArco )02718
WriteLine ( 1 , Grafico . BArco )02719
WriteLine ( 1 , Grafico . ColArco . A )02720
WriteLine ( 1 , Grafico . ColArco . R )02721
WriteLine ( 1 , Grafico . ColArco . G )02722
WriteLine ( 1 , Grafico . ColArco . B )02723
02724
'---------02725
WriteLine ( 1 , TotalNodos ) 'número de nodos02726
WriteLine ( 1 , TotalArcos ) 'número de arcos02727
Dim i As Long02728
For i = 0 To TotalNodos - 102729
WriteLine ( 1 , Nodos ( i ) . Texto )02730
WriteLine ( 1 , Nodos ( i ) . X )02731
WriteLine ( 1 , Nodos ( i ) . Y )02732
WriteLine ( 1 , Nodos ( i ) . Valor )02733
WriteLine ( 1 , Nodos ( i ) . Radio )02734
WriteLine ( 1 , Nodos ( i ) . Grosor )02735
WriteLine ( 1 , Nodos ( i ) . Col . A )02736
WriteLine ( 1 , Nodos ( i ) . Col . R )02737
WriteLine ( 1 , Nodos ( i ) . Col . G )02738
WriteLine ( 1 , Nodos ( i ) . Col . B )02739
Next i02740
For i = 0 To TotalArcos - 102741
WriteLine ( 1 , Arcos ( i ) . Min )02742
WriteLine ( 1 , Arcos ( i ) . Max )02743
WriteLine ( 1 , Arcos ( i ) . Coste )02744
WriteLine ( 1 , Arcos ( i ) . Nd1 )02745
WriteLine ( 1 , Arcos ( i ) . Nd2 )02746
WriteLine ( 1 , Arcos ( i ) . B )02747
WriteLine ( 1 , Arcos ( i ) . Texto )02748
WriteLine ( 1 , Arcos ( i ) . Col . A )02749
WriteLine ( 1 , Arcos ( i ) . Col . R )02750
WriteLine ( 1 , Arcos ( i ) . Col . G )02751
WriteLine ( 1 , Arcos ( i ) . Col . B )02752
WriteLine ( 1 , Arcos ( i ) . Grosor )02753
Next i02754
02755
'Intercepción de posibles errores al grabar02756
Catch ex As Exception02757
Me . Cursor = Cursors . Default02758
MsgBox ( "Ha fallado la operación de guardar fichero." & vbCrLf & ex .» Message , MsgBoxStyle . Exclamation , "Grafos - Excepción" )
02759
Exit Sub02760
Finally02761
FileClose ( 1 )02762
End Try02763
End Sub02764
Private Sub GuardaFicheroGraphML ( ByVal fichero As String )02765
'Guarda el grafo en formato de estructura XML02766
'GraphML02767
'http://graphml.graphdrawing.org02768
02769
'variables locales02770
Dim txt As String02771
Dim i As Long02772
Dim version As String02773
version = System . Diagnostics . FileVersionInfo . GetVersionInfo ( System .» Reflection . Assembly . GetExecutingAssembly . Location ) . FileMajorPart
02774
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileMinorPart
02775
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileBuildPart
02776
02777
'------------------------------02778
'Comienza el fichero .graphML02779
'------------------------------02780
'información cabecera .graphML02781
'------------------------------02782
txt = ""02783
txt & = ""02784
txt & = "<?xml version=""1.0"" encoding=""UTF-8""?> " & vbCrLf02785
txt & = "<!-- This file was written by Grafos software. -->" &» vbCrLf
02786
txt & = "<!-- http://ttt.upv.es/~arodrigu/grafos -->" &» vbCrLf
02787
txt & = "<!-- (cc) 2003..2005 - Alejandro Rodriguez Villalobos -->" &» vbCrLf
02788
txt & = "<!-- Fecha: " & Now . ToShortDateString & " -->" & vbCrLf02789
txt & = "<!-- Version: " & version & " -->" & vbCrLf02790
txt & = "<graphml xmlns=""http://graphml.graphdrawing.org/xmlns"" " &» vbCrLf
02791
txt & = " xmlns:xsi="» "http://www.w3.org/2001/XMLSchema-instance"" " & vbCrLf
02792
txt & = " xsi:schemaLocation="» "http://graphml.graphdrawing.org/xmlns " & vbCrLf
02793
txt & = "» http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd"">" & vbCrLf
02794
txt & = "<!-- Declaración de atributos -->" & vbCrLf02795
'------------------------------02796
'Declaración de atributos xml02797
'------------------------------02798
'Atributos para el grafo02799
'------------------------------02800
txt & = "<!-- Atributos del grafo -->" & vbCrLf02801
02802
'Añadir atributo de versión de Grafos??02803
'Atributos del tapiz por defecto02804
'--------------------------------02805
txt & = "<!-- Atributos del tapiz por defecto -->" & vbCrLf02806
'WriteLine(1, Grafico.Zoom)02807
'WriteLine(1, Grafico.Rejilla)02808
'WriteLine(1, Grafico.Iman)02809
'WriteLine(1, Grafico.MostrarRejilla)02810
'WriteLine(1, Grafico.TapizX)02811
'WriteLine(1, Grafico.TapizY)02812
02813
'Atributo zoom02814
txt & = "<key id=""GvZ"" for=""graph"" attr.name=""GZoom"" attr.type="» "float"">" & vbCrLf
02815
txt & = "<default>" & Grafico . Zoom & "</default>" & vbCrLf02816
txt & = "</key>" & vbCrLf02817
'Atributo rejilla02818
txt & = "<key id=""GvR"" for=""graph"" attr.name=""GRejilla"" attr.type="» "float"">" & vbCrLf
02819
txt & = "<default>" & Grafico . Rejilla & "</default>" & vbCrLf02820
txt & = "</key>" & vbCrLf02821
02822
'Atributo mostrar rejilla02823
txt & = "<key id=""GvMR"" for=""graph"" attr.name=""GMostrarRejilla""» attr.type=""boolean"">" & vbCrLf
02824
txt & = "<default>" & Grafico . MostrarRejilla & "</default>" & vbCrLf02825
txt & = "</key>" & vbCrLf02826
'Atributo imán02827
txt & = "<key id=""GvI"" for=""graph"" attr.name=""GIman"" attr.type="» "boolean"">" & vbCrLf
02828
txt & = "<default>" & Grafico . Iman & "</default>" & vbCrLf02829
txt & = "</key>" & vbCrLf02830
02831
'Atributo tapizX02832
txt & = "<key id=""GtX"" for=""graph"" attr.name=""GTapizX"" attr.type="» "float"">" & vbCrLf
02833
txt & = "<default>" & Grafico . TapizX & "</default>" & vbCrLf02834
txt & = "</key>" & vbCrLf02835
'Atributo tapizY02836
txt & = "<key id=""GtY"" for=""graph"" attr.name=""GTapizY"" attr.type="» "float"">" & vbCrLf
02837
txt & = "<default>" & Grafico . TapizY & "</default>" & vbCrLf02838
txt & = "</key>" & vbCrLf02839
02840
txt & = "<!-- Atributos del color rejilla por defecto -->" & vbCrLf02841
'WriteLine(1, Grafico.ColorRejilla.A)02842
'WriteLine(1, Grafico.ColorRejilla.R)02843
'WriteLine(1, Grafico.ColorRejilla.G)02844
'WriteLine(1, Grafico.ColorRejilla.B)02845
02846
'Atributo Color A02847
txt & = "<key id=""GrCA"" for=""graph"" attr.name=""GColorARejilla""» attr.type=""int"">" & vbCrLf
02848
txt & = "<default>" & Grafico . ColorRejilla . A & "</default>" & vbCrLf02849
txt & = "</key>" & vbCrLf02850
'Atributo Color R02851
txt & = "<key id=""GrCR"" for=""graph"" attr.name=""GColorRRejilla""» attr.type=""int"">" & vbCrLf
02852
txt & = "<default>" & Grafico . ColorRejilla . R & "</default>" & vbCrLf02853
txt & = "</key>" & vbCrLf02854
'Atributo Color G02855
txt & = "<key id=""GrCG"" for=""graph"" attr.name=""GColorGRejilla""» attr.type=""int"">" & vbCrLf
02856
txt & = "<default>" & Grafico . ColorRejilla . G & "</default>" & vbCrLf02857
txt & = "</key>" & vbCrLf02858
'Atributo Color B02859
txt & = "<key id=""GrCB"" for=""graph"" attr.name=""GColorBRejilla""» attr.type=""int"">" & vbCrLf
02860
txt & = "<default>" & Grafico . ColorRejilla . B & "</default>" & vbCrLf02861
txt & = "</key>" & vbCrLf02862
02863
02864
txt & = "<!-- Atributos del color tapiz por defecto -->" & vbCrLf02865
'WriteLine(1, Grafico.ColorTapiz.A)02866
'WriteLine(1, Grafico.ColorTapiz.R)02867
'WriteLine(1, Grafico.ColorTapiz.G)02868
'WriteLine(1, Grafico.ColorTapiz.B)02869
'Atributo Color A02870
txt & = "<key id=""GtCA"" for=""graph"" attr.name=""GColorATapiz""» attr.type=""int"">" & vbCrLf
02871
txt & = "<default>" & Grafico . ColorTapiz . A & "</default>" & vbCrLf02872
txt & = "</key>" & vbCrLf02873
'Atributo Color R02874
txt & = "<key id=""GtCR"" for=""graph"" attr.name=""GColorRTapiz""» attr.type=""int"">" & vbCrLf
02875
txt & = "<default>" & Grafico . ColorTapiz . R & "</default>" & vbCrLf02876
txt & = "</key>" & vbCrLf02877
'Atributo Color G02878
txt & = "<key id=""GtCG"" for=""graph"" attr.name=""GColorGTapiz""» attr.type=""int"">" & vbCrLf
02879
txt & = "<default>" & Grafico . ColorTapiz . G & "</default>" & vbCrLf02880
txt & = "</key>" & vbCrLf02881
'Atributo Color B02882
txt & = "<key id=""GtCB"" for=""graph"" attr.name=""GColorBTapiz""» attr.type=""int"">" & vbCrLf
02883
txt & = "<default>" & Grafico . ColorTapiz . B & "</default>" & vbCrLf02884
txt & = "</key>" & vbCrLf02885
02886
02887
txt & = "<!-- Atributos del tipo de letra por defecto -->" & vbCrLf02888
'WriteLine(1, Grafico.Fuente.Name)02889
'WriteLine(1, Grafico.Fuente.Size)02890
'WriteLine(1, Grafico.Fuente.Style)02891
'Atributo Tipo de letra02892
txt & = "<key id=""GfN"" for=""graph"" attr.name=""GFontName""» attr.type=""string"">" & vbCrLf
02893
txt & = "<default>" & Grafico . Fuente . Name & "</default>" & vbCrLf02894
txt & = "</key>" & vbCrLf02895
'Atributo tamaño de letra02896
txt & = "<key id=""GfS"" for=""graph"" attr.name=""GFontSize""» attr.type=""float"">" & vbCrLf
02897
txt & = "<default>" & Grafico . Fuente . Size & "</default>" & vbCrLf02898
txt & = "</key>" & vbCrLf02899
'Atributo estilo de letra02900
txt & = "<key id=""GfSt"" for=""graph"" attr.name=""GFontStyle""» attr.type=""float"">" & vbCrLf
02901
txt & = "<default>" & Grafico . Fuente . Style & "</default>" & vbCrLf02902
txt & = "</key>" & vbCrLf02903
02904
'Atributos del nodo por defecto02905
'--------------------------------02906
txt & = "<!-- Atributos del nodo por defecto -->" & vbCrLf02907
'WriteLine(1, Grafico.TrazoNodo)02908
'WriteLine(1, Grafico.RadioNodo)02909
'WriteLine(1, Grafico.ColNodo.A)02910
'WriteLine(1, Grafico.ColNodo.R)02911
'WriteLine(1, Grafico.ColNodo.G)02912
'WriteLine(1, Grafico.ColNodo.B)02913
'WriteLine(1, Grafico.textoNodo)02914
'WriteLine(1, Grafico.costNodo)02915
02916
'Atributo Texto02917
txt & = "<key id=""GnT"" for=""graph"" attr.name=""GTextoNodo""» attr.type=""boolean"">" & vbCrLf
02918
txt & = "<default>" & Grafico . textoNodo & "</default>" & vbCrLf02919
txt & = "</key>" & vbCrLf02920
'Atributo posX02921
txt & = "<key id=""GnX"" for=""graph"" attr.name=""GposXNodo""» attr.type=""float"">" & vbCrLf
02922
txt & = "<default>0</default>" & vbCrLf02923
txt & = "</key>" & vbCrLf02924
'Atributo posY02925
txt & = "<key id=""GnY"" for=""graph"" attr.name=""GposYNodo""» attr.type=""float"">" & vbCrLf
02926
txt & = "<default>0</default>" & vbCrLf02927
txt & = "</key>" & vbCrLf02928
'Atributo posZ02929
txt & = "<key id=""GnZ"" for=""graph"" attr.name=""GposZNodo""» attr.type=""float"">" & vbCrLf
02930
txt & = "<default>0</default>" & vbCrLf02931
txt & = "</key>" & vbCrLf02932
'Atributo Valor02933
txt & = "<key id=""GnV"" for=""graph"" attr.name=""GValorNodo""» attr.type=""boolean"">" & vbCrLf
02934
txt & = "<default>" & Grafico . costNodo & "</default>" & vbCrLf02935
txt & = "</key>" & vbCrLf02936
'Atributo Radio02937
txt & = "<key id=""GnR"" for=""graph"" attr.name=""GRadioNodo""» attr.type=""float"">" & vbCrLf
02938
txt & = "<default>" & Grafico . RadioNodo & "</default>" & vbCrLf02939
txt & = "</key>" & vbCrLf02940
'Atributo Grosor02941
txt & = "<key id=""GnG"" for=""graph"" attr.name=""GGrosorNodo""» attr.type=""float"">" & vbCrLf
02942
txt & = "<default>" & Grafico . TrazoNodo & "</default>" & vbCrLf02943
txt & = "</key>" & vbCrLf02944
'Atributo Color A02945
txt & = "<key id=""GnCA"" for=""graph"" attr.name=""GColorANodo""» attr.type=""int"">" & vbCrLf
02946
txt & = "<default>" & Grafico . ColNodo . A & "</default>" & vbCrLf02947
txt & = "</key>" & vbCrLf02948
'Atributo Color R02949
txt & = "<key id=""GnCR"" for=""graph"" attr.name=""GColorRNodo""» attr.type=""int"">" & vbCrLf
02950
txt & = "<default>" & Grafico . ColNodo . R & "</default>" & vbCrLf02951
txt & = "</key>" & vbCrLf02952
'Atributo Color G02953
txt & = "<key id=""GnCG"" for=""graph"" attr.name=""GColorGNodo""» attr.type=""int"">" & vbCrLf
02954
txt & = "<default>" & Grafico . ColNodo . G & "</default>" & vbCrLf02955
txt & = "</key>" & vbCrLf02956
'Atributo Color B02957
txt & = "<key id=""GnCB"" for=""graph"" attr.name=""GColorBNodo""» attr.type=""int"">" & vbCrLf
02958
txt & = "<default>" & Grafico . ColNodo . B & "</default>" & vbCrLf02959
txt & = "</key>" & vbCrLf02960
02961
''arco02962
'WriteLine(1, Grafico.minArco)02963
'WriteLine(1, Grafico.maxArco)02964
'WriteLine(1, Grafico.costArco)02965
'WriteLine(1, Grafico.TrazoArco)02966
'WriteLine(1, Grafico.BArco)02967
'WriteLine(1, Grafico.ColArco.A)02968
'WriteLine(1, Grafico.ColArco.R)02969
'WriteLine(1, Grafico.ColArco.G)02970
'WriteLine(1, Grafico.ColArco.B)02971
02972
'Atributos del arco por defecto02973
'--------------------------------02974
txt & = "<!-- Atributos del arco por defecto -->" & vbCrLf02975
'Atributo Min02976
txt & = "<key id=""GaMin"" for=""graph"" attr.name=""GMinArco""» attr.type=""boolean"">" & vbCrLf
02977
txt & = "<default>" & Grafico . minArco & "</default>" & vbCrLf02978
txt & = "</key>" & vbCrLf02979
'Atributo Max02980
txt & = "<key id=""GaMax"" for=""graph"" attr.name=""GMaxArco""» attr.type=""boolean"">" & vbCrLf
02981
txt & = "<default>" & Grafico . maxArco & "</default>" & vbCrLf02982
txt & = "</key>" & vbCrLf02983
'Atributo Coste02984
txt & = "<key id=""GaC"" for=""graph"" attr.name=""GCosteArco""» attr.type=""boolean"">" & vbCrLf
02985
txt & = "<default>" & Grafico . costArco & "</default>" & vbCrLf02986
txt & = "</key>" & vbCrLf02987
'Atributo Bidireccional02988
txt & = "<key id=""GaB"" for=""graph"" attr.name=""GBArco"" attr.type="» "boolean"">" & vbCrLf
02989
txt & = "<default>" & Grafico . BArco & "</default>" & vbCrLf02990
txt & = "</key>" & vbCrLf02991
'Atributo Grosor02992
txt & = "<key id=""GaG"" for=""graph"" attr.name=""GGrosorArco""» attr.type=""float"">" & vbCrLf
02993
txt & = "<default>" & Grafico . TrazoArco & "</default>" & vbCrLf02994
txt & = "</key>" & vbCrLf02995
'Atributo Color A02996
txt & = "<key id=""GaCA"" for=""graph"" attr.name=""GColorAArco""» attr.type=""int"">" & vbCrLf
02997
txt & = "<default>" & Grafico . ColArco . A & "</default>" & vbCrLf02998
txt & = "</key>" & vbCrLf02999
'Atributo Color R03000
txt & = "<key id=""GaCR"" for=""graph"" attr.name=""GColorRArco""» attr.type=""int"">" & vbCrLf
03001
txt & = "<default>" & Grafico . ColArco . R & "</default>" & vbCrLf03002
txt & = "</key>" & vbCrLf03003
'Atributo Color G03004
txt & = "<key id=""GaCG"" for=""graph"" attr.name=""GColorGArco""» attr.type=""int"">" & vbCrLf
03005
txt & = "<default>" & Grafico . ColArco . G & "</default>" & vbCrLf03006
txt & = "</key>" & vbCrLf03007
'Atributo Color B03008
txt & = "<key id=""GaCB"" for=""graph"" attr.name=""GColorBArco""» attr.type=""int"">" & vbCrLf
03009
txt & = "<default>" & Grafico . ColArco . B & "</default>" & vbCrLf03010
txt & = "</key>" & vbCrLf03011
03012
'------------------------------03013
'Atributos para nodos03014
'------------------------------03015
txt & = "<!-- Atributos para los nodos -->" & vbCrLf03016
'Atributo Texto03017
txt & = "<key id=""nT"" for=""node"" attr.name=""TextoNodo"" attr.type="» "string"">" & vbCrLf
03018
txt & = "<default> </default>" & vbCrLf03019
txt & = "</key>" & vbCrLf03020
'Atributo posX03021
txt & = "<key id=""nX"" for=""node"" attr.name=""posXNodo"" attr.type="» "float"">" & vbCrLf
03022
txt & = "<default>0</default>" & vbCrLf03023
txt & = "</key>" & vbCrLf03024
'Atributo posY03025
txt & = "<key id=""nY"" for=""node"" attr.name=""posYNodo"" attr.type="» "float"">" & vbCrLf
03026
txt & = "<default>0</default>" & vbCrLf03027
txt & = "</key>" & vbCrLf03028
'Atributo posZ03029
txt & = "<key id=""nZ"" for=""node"" attr.name=""posZNodo"" attr.type="» "float"">" & vbCrLf
03030
txt & = "<default>0</default>" & vbCrLf03031
txt & = "</key>" & vbCrLf03032
'Atributo Valor03033
txt & = "<key id=""nV"" for=""node"" attr.name=""ValorNodo"" attr.type="» "float"">" & vbCrLf
03034
txt & = "<default>0</default>" & vbCrLf03035
txt & = "</key>" & vbCrLf03036
'Atributo Radio03037
txt & = "<key id=""nR"" for=""node"" attr.name=""RadioNodo"" attr.type="» "float"">" & vbCrLf
03038
txt & = "<default>" & Grafico . RadioNodo & "</default>" & vbCrLf03039
txt & = "</key>" & vbCrLf03040
'Atributo Grosor03041
txt & = "<key id=""nG"" for=""node"" attr.name=""GrosorNodo"" attr.type="» "float"">" & vbCrLf
03042
txt & = "<default>" & Grafico . TrazoNodo & "</default>" & vbCrLf03043
txt & = "</key>" & vbCrLf03044
'Atributo Color A03045
txt & = "<key id=""nCA"" for=""node"" attr.name=""ColorANodo""» attr.type=""int"">" & vbCrLf
03046
txt & = "<default>" & Grafico . ColNodo . A & "</default>" & vbCrLf03047
txt & = "</key>" & vbCrLf03048
'Atributo Color R03049
txt & = "<key id=""nCR"" for=""node"" attr.name=""ColorRNodo""» attr.type=""int"">" & vbCrLf
03050
txt & = "<default>" & Grafico . ColNodo . R & "</default>" & vbCrLf03051
txt & = "</key>" & vbCrLf03052
'Atributo Color G03053
txt & = "<key id=""nCG"" for=""node"" attr.name=""ColorGNodo""» attr.type=""int"">" & vbCrLf
03054
txt & = "<default>" & Grafico . ColNodo . G & "</default>" & vbCrLf03055
txt & = "</key>" & vbCrLf03056
'Atributo Color B03057
txt & = "<key id=""nCB"" for=""node"" attr.name=""ColorBNodo""» attr.type=""int"">" & vbCrLf
03058
txt & = "<default>" & Grafico . ColNodo . B & "</default>" & vbCrLf03059
txt & = "</key>" & vbCrLf03060
03061
03062
'------------------------------03063
'Atributos para arcos03064
'------------------------------03065
txt & = "<!-- Atributos para los arcos -->" & vbCrLf03066
'Atributo Texto03067
txt & = "<key id=""aT"" for=""edge"" attr.name=""TextoArco"" attr.type="» "string"">" & vbCrLf
03068
txt & = "<default> </default>" & vbCrLf03069
txt & = "</key>" & vbCrLf03070
'Atributo Min03071
txt & = "<key id=""aMin"" for=""edge"" attr.name=""MinArco"" attr.type="» "float"">" & vbCrLf
03072
txt & = "<default>0</default>" & vbCrLf03073
txt & = "</key>" & vbCrLf03074
'Atributo Max03075
txt & = "<key id=""aMax"" for=""edge"" attr.name=""MaxArco"" attr.type="» "float"">" & vbCrLf
03076
txt & = "<default>0</default>" & vbCrLf03077
txt & = "</key>" & vbCrLf03078
'Atributo Coste03079
txt & = "<key id=""aC"" for=""edge"" attr.name=""CosteArco"" attr.type="» "float"">" & vbCrLf
03080
txt & = "<default>0</default>" & vbCrLf03081
txt & = "</key>" & vbCrLf03082
'Atributo Bidireccional03083
txt & = "<key id=""aB"" for=""edge"" attr.name=""BArco"" attr.type="» "boolean"">" & vbCrLf
03084
txt & = "<default>" & Grafico . BArco & "</default>" & vbCrLf03085
txt & = "</key>" & vbCrLf03086
'Atributo Grosor03087
txt & = "<key id=""aG"" for=""edge"" attr.name=""GrosorArco"" attr.type="» "float"">" & vbCrLf
03088
txt & = "<default>" & Grafico . TrazoArco & "</default>" & vbCrLf03089
txt & = "</key>" & vbCrLf03090
'Atributo Color A03091
txt & = "<key id=""aCA"" for=""edge"" attr.name=""ColorAArco""» attr.type=""int"">" & vbCrLf
03092
txt & = "<default>" & Grafico . ColArco . A & "</default>" & vbCrLf03093
txt & = "</key>" & vbCrLf03094
'Atributo Color R03095
txt & = "<key id=""aCR"" for=""edge"" attr.name=""ColorRArco""» attr.type=""int"">" & vbCrLf
03096
txt & = "<default>" & Grafico . ColArco . R & "</default>" & vbCrLf03097
txt & = "</key>" & vbCrLf03098
'Atributo Color G03099
txt & = "<key id=""aCG"" for=""edge"" attr.name=""ColorGArco""» attr.type=""int"">" & vbCrLf
03100
txt & = "<default>" & Grafico . ColArco . G & "</default>" & vbCrLf03101
txt & = "</key>" & vbCrLf03102
'Atributo Color B03103
txt & = "<key id=""aCB"" for=""edge"" attr.name=""ColorBArco""» attr.type=""int"">" & vbCrLf
03104
txt & = "<default>" & Grafico . ColArco . B & "</default>" & vbCrLf03105
txt & = "</key>" & vbCrLf03106
03107
'------------------------------03108
'Definición del grafo03109
'------------------------------03110
txt & = "<!-- Definición del grafo -->" & vbCrLf03111
'grafo con arcos dirigidos03112
txt & = "<graph id=""Grafo"" edgedefault=""directed"" " & vbCrLf03113
'total de nodos y arcos para comprobación03114
txt & = " parse.nodes=""" & TotalNodos & """ parse.edges=""" &» TotalArcos & """ " & vbCrLf
03115
'esta línea no se usa03116
'parse.maxindegree="2" parse.maxoutdegree="3"03117
'id de nodo nX, id de arco eX. La alternativa sería "free"03118
txt & = " parse.nodeids=""canonical"" parse.edgeids="» "canonical"" " & vbCrLf
03119
'primero va la definición de TODOS los nodos y luego la de TODOS los» arcos
03120
txt & = " parse.order=""nodesfirst"">" & vbCrLf03121
03122
'------------------------------03123
'información de nodos03124
'------------------------------03125
txt & = "<!-- Definición de los nodos -->" & vbCrLf03126
For i = 0 To TotalNodos - 103127
'definición del nodo en forma canónica03128
txt & = " <node id=""n" & i . ToString & """>" & vbCrLf03129
'atributos del nodo03130
txt & = " <data key=""nT"">" & Nodos ( i ) . Texto & "</data>" & vbCrLf03131
txt & = " <data key=""nX"">" & Nodos ( i ) . X & "</data>" & vbCrLf03132
txt & = " <data key=""nY"">" & Nodos ( i ) . Y & "</data>" & vbCrLf03133
txt & = " <data key=""nZ"">" & Nodos ( i ) . Z & "</data>" & vbCrLf03134
txt & = " <data key=""nV"">" & Nodos ( i ) . Valor & "</data>" & vbCrLf03135
txt & = " <data key=""nR"">" & Nodos ( i ) . Radio & "</data>" & vbCrLf03136
txt & = " <data key=""nG"">" & Nodos ( i ) . Grosor & "</data>" &» vbCrLf
03137
txt & = " <data key=""nCA"">" & Nodos ( i ) . Col . A & "</data>" &» vbCrLf
03138
txt & = " <data key=""nCR"">" & Nodos ( i ) . Col . R & "</data>" &» vbCrLf
03139
txt & = " <data key=""nCG"">" & Nodos ( i ) . Col . G & "</data>" &» vbCrLf
03140
txt & = " <data key=""nCB"">" & Nodos ( i ) . Col . B & "</data>" &» vbCrLf
03141
'fin del nodo03142
txt & = " </node>"03143
Next i03144
03145
'------------------------------03146
'información de arcos03147
'------------------------------03148
txt & = "<!-- Definición de los arcos -->" & vbCrLf03149
For i = 0 To TotalArcos - 103150
'definición del arco en forma canónica03151
txt & = " <edge id=""e" & i . ToString & """ source=""n" & Arcos ( i ) .» Nd1 . ToString & """ target=""n" & Arcos ( i ) . Nd2 . ToString & """>" &
» vbCrLf
03152
'atributos del arco03153
txt & = " <data key=""aT"">" & Arcos ( i ) . Texto & "</data>" & vbCrLf03154
txt & = " <data key=""aMin"">" & Arcos ( i ) . Min & "</data>" & vbCrLf03155
txt & = " <data key=""aMax"">" & Arcos ( i ) . Max & "</data>" & vbCrLf03156
txt & = " <data key=""aC"">" & Arcos ( i ) . Coste & "</data>" & vbCrLf03157
txt & = " <data key=""aB"">" & Arcos ( i ) . B & "</data>" & vbCrLf03158
txt & = " <data key=""aG"">" & Arcos ( i ) . Grosor & "</data>" &» vbCrLf
03159
txt & = " <data key=""aCA"">" & Arcos ( i ) . Col . A & "</data>" &» vbCrLf
03160
txt & = " <data key=""aCR"">" & Arcos ( i ) . Col . R & "</data>" &» vbCrLf
03161
txt & = " <data key=""aCG"">" & Arcos ( i ) . Col . G & "</data>" &» vbCrLf
03162
txt & = " <data key=""aCB"">" & Arcos ( i ) . Col . B & "</data>" &» vbCrLf
03163
'fin del arco03164
txt & = " </edge>"03165
Next i03166
03167
'------------------------------03168
'pie del fichero03169
'------------------------------03170
'fin de la defición del grafo03171
'------------------------------03172
txt & = "</graph>" & vbCrLf03173
'------------------------------03174
'fin del fichero03175
'------------------------------03176
txt & = "</graphml>"03177
03178
'Guarda el fichero .graphML03179
EscribeFicheroTexto ( fichero , txt )03180
End Sub03181
Private Sub mnuArchivoExportarImg_Click ( ByVal sender As System . Object , ByVal» e As System . EventArgs ) Handles mnuArchivoExportarImg . Click
03182
'llama a la función de exportar imagen a la cual le pasa el picturebox103183
03184
Me . Cursor = Cursors . WaitCursor03185
ExportaImagen ( PictureBox1 )03186
Me . Cursor = Cursors . Default03187
03188
End Sub03189
Private Sub mnuArchivoCopiarImg_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuArchivoCopiarImg . Click
03190
CopiaImagenPortapapeles ( PictureBox1 )03191
End Sub03192
Private Sub mnuAyudaAcercade_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuAyudaAcercade . Click
03193
Dim s As Form03194
s = New Splash03195
s . Visible = True03196
End Sub03197
Private Sub mnuEdicionGrafica_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuEdicionGrafica . Click
03198
If mnuEdicionTabular . Checked = True Then03199
03200
'Quita el foco al textbox para que no se03201
'quede grabado su antiguo valor que va a03202
'desaparecer con esta operación03203
TextBox1 . Visible = False03204
hfgTabla . Focus ()03205
03206
hfgTabla . Visible = False03207
03208
'transforma los datos de la matriz a las03209
'colecciones que forman el gráfico03210
Matriz_Grafico ()03211
03212
If mnuFormatoCircular . Checked Then OrdenaenEstrella ()03213
If mnuFormatoAleatorio . Checked Then OrdenaAleatorio ()03214
If mnuFormatoTablero . Checked Then OrdenaenTablero ()03215
If mnuFormatoFlujo . Checked Then OrdenaenFlujo ()03216
If mnuFormatoOrganico . Checked Then OrdenaenForceDirect ()03217
03218
'dibuja de nuevo el grafo03219
DibujaGrafo ()03220
03221
mnuEdicionTabular . Checked = False03222
mnuEdicionGrafica . Checked = True03223
03224
mnuAnalisis . Enabled = True03225
03226
Me . mnuArchivoNuevoAleatorio . Enabled = True03227
mnuArchivoGuardar . Enabled = True03228
mnuArchivoGuardarComo . Enabled = True03229
mnuArchivoExportarDatos . Enabled = True03230
mnuArchivoImportarDatos . Enabled = True03231
mnuArchivoImprimir . Enabled = True03232
mnuArchivoExportarImg . Enabled = True03233
mnuArchivoCopiarImg . Enabled = True03234
mnuFormato . Enabled = True03235
PictureBox1 . Visible = True03236
03237
End If03238
End Sub03239
Sub OrdenaenEstrella ()03240
'redibuja en formato estrella03241
03242
Dim i As Long03243
Dim angulo As Single = 2 * 3.1415 / TotalNodos03244
Dim cx , cy , radio As Single03245
cx = Grafico . TapizX / 203246
cy = Grafico . TapizY / 203247
03248
If cx < cy Then radio = cx Else radio = cy03249
03250
For i = 0 To TotalNodos - 103251
Nodos ( i ) . X = cx + radio * 0.9 * Math . Cos ( angulo * i )03252
Nodos ( i ) . Y = cy + radio * 0.9 * Math . Sin ( angulo * i )03253
Next i03254
End Sub03255
Sub OrdenaAleatorio ()03256
'redibuja en formato aleatorio03257
03258
Dim i As Long03259
Dim cx , cy As Single03260
cx = Grafico . TapizX * 0.903261
cy = Grafico . TapizY * 0.903262
03263
For i = 0 To TotalNodos - 103264
Nodos ( i ) . X = cx * Rnd ()03265
Nodos ( i ) . Y = cy * Rnd ()03266
Next i03267
End Sub03268
Sub OrdenaenForceDirect ()03269
'formato Orgánico03270
'redibuja en formato del algoritmo Force Direct03271
'(spring = muelles)03272
03273
'variables locales03274
Dim it As Long 'contador de iteraciones03275
Dim BordeActivo As Boolean03276
BordeActivo = ExistenNodosSueltos ()03277
03278
Dim u , v As Long 'contador de nodos03279
Dim i , j , k As Long 'contadores03280
03281
Dim total_it As Single 'parámetro tiempo de iteración03282
Dim l As Single 'parámetro de longitud03283
Dim r As Single 'parámetro de repulsion03284
Dim a As Single 'parámetro de atracción03285
Dim g As Single 'parámetro de gravedad al baricentro03286
Dim s As Single 'parámetro de distancia mínima entre nodos03287
Dim temp , gradE As Double 'parámetro de temperatura03288
03289
Dim Fx ( TotalNodos - 1 ) As Single 'Fuerza x resultante sobre el nodo03290
Dim Fy ( TotalNodos - 1 ) As Single 'Fuerza y resultante sobre el nodo03291
03292
Dim E As Single 'energía total del sistema03293
Dim Ea As Single 'energía de los arcos03294
Dim En As Single 'energía de los nodos03295
Dim E1 , E0 As Single 'gradiente de energía03296
03297
Dim f , f2 As Single 'fuerza03298
Dim narcos As Long 'num arcos simetricos03299
Dim dist , dist2 As Single 'distancia03300
Dim gdist As Single 'gradiente de distancia03301
Dim dx As Single 'distancia x03302
Dim dy As Single 'distancia y03303
Dim dx2 As Single 'distancia x03304
Dim dy2 As Single 'distancia y03305
Dim x0 , y0 As Single03306
Dim x1 , x2 , x3 , x4 As Single03307
Dim y1 , y2 , y3 , y4 As Single03308
03309
Dim sumx As Single 'calculo baricentro x03310
Dim sumy As Single 'calculo baricentro y03311
Dim bx As Single 'x baricentro03312
Dim by As Single 'y baricentro03313
03314
Dim mx As Single 'movimiento x03315
Dim my As Single 'movimiento y03316
Dim condicion As Boolean03317
'parámetros03318
total_it = 100003319
'l = Math.Sqrt((Grafico.TapizX * Grafico.TapizY) / TotalNodos)03320
'l = l * 0.803321
l = Grafico . RadioNodo * 503322
03323
r = 403324
a = 1.103325
g = 303326
s = l * 0.703327
03328
temp = 003329
E = 003330
E0 = 003331
'inicio del bucle de iteraciones03332
For it = 1 To total_it03333
k = k + 103334
sumx = 003335
sumy = 003336
03337
'cálculo de fuerzas repulsivas03338
'y energía del sistema03339
En = 003340
For u = 0 To TotalNodos - 103341
Fx ( u ) = 0 'fuerza x inicial del grafo para cada nodo es cero03342
Fy ( u ) = 0 'fuerza y inicial del grafo para cada nodo es cero03343
For v = 0 To TotalNodos - 103344
03345
'cálculo baricentro03346
sumx = sumx + Nodos ( v ) . X03347
sumy = sumy + Nodos ( v ) . Y03348
03349
If u <> v Then 'un nodo no se compara consigo mismo03350
'distancia entre nodos03351
dx = Nodos ( v ) . X - Nodos ( u ) . X03352
dy = Nodos ( v ) . Y - Nodos ( u ) . Y03353
dist = Math . Sqrt ( dx ^ 2 + dy ^ 2 )03354
If dist = 0 Then dist = 0.103355
03356
'permite o no nodos encima de otros o muy próximos03357
If dist < s Then03358
'funcion fuerza repulsión en x03359
f = r * dx / dist ^ 403360
03361
If dist < ( Nodos ( v ) . Radio + Nodos ( u ) . Radio ) Then03362
f = f * TotalNodos ^ 403363
End If03364
03365
Fx ( v ) = Fx ( v ) + f03366
Fx ( u ) = Fx ( u ) - f03367
'funcion fuerza repulsión en y03368
f = r * dy / dist ^ 403369
03370
If dist < ( Nodos ( v ) . Radio + Nodos ( u ) . Radio ) Then03371
f = f * TotalNodos ^ 403372
End If03373
03374
Fy ( v ) = Fy ( v ) + f03375
Fy ( u ) = Fy ( u ) - f03376
'energía entre nodos03377
En = En + r / dist ^ 403378
Else03379
'funcion fuerza repulsión en x03380
f = r * dx / dist ^ 203381
Fx ( v ) = Fx ( v ) + f03382
Fx ( u ) = Fx ( u ) - f03383
'funcion fuerza repulsión en y03384
f = r * dy / dist ^ 203385
Fy ( v ) = Fy ( v ) + f03386
Fy ( u ) = Fy ( u ) - f03387
03388
03389
'energía entre nodos03390
En = En + r / dist ^ 203391
End If03392
End If03393
03394
If BordeActivo Then03395
'Energía respecto a los bordes03396
'distancia entre nodo y bordes03397
dx = Nodos ( v ) . X03398
dist = Math . Sqrt ( dx ^ 2 )03399
If dist = 0 Then dist = 0.103400
f = r / dist ^ 203401
Fx ( v ) = Fx ( v ) + f03402
En = En + r / dist ^ 203403
03404
dy = Nodos ( v ) . Y03405
dist = Math . Sqrt ( dy ^ 2 )03406
If dist = 0 Then dist = 0.103407
f = r / dist ^ 203408
Fy ( v ) = Fy ( v ) + f03409
En = En + r / dist ^ 203410
03411
dx = Nodos ( v ) . X - Grafico . TapizX03412
dist = Math . Sqrt ( dx ^ 2 )03413
If dist = 0 Then dist = 0.103414
f = r / dist ^ 203415
Fx ( v ) = Fx ( v ) - f03416
En = En + r / dist ^ 203417
03418
dy = Nodos ( v ) . Y - Grafico . TapizY03419
dist = Math . Sqrt ( dy ^ 2 )03420
If dist = 0 Then dist = 0.103421
f = r / dist ^ 203422
Fy ( v ) = Fy ( v ) - f03423
En = En + r / dist ^ 203424
End If03425
Next v03426
Next u03427
03428
'cálculo de fuerzas de baricentro03429
'tendencia a agruparse o dispersarse del centro de gravedad03430
'baricentro03431
bx = sumx / TotalNodos03432
by = sumy / TotalNodos03433
03434
For v = 0 To TotalNodos - 103435
'distancia al baricentro03436
dx = ( Nodos ( v ) . X - bx )03437
dy = ( Nodos ( v ) . Y - by )03438
dist = Math . Sqrt ( dx ^ 2 + dy ^ 2 )03439
If dist = 0 Then dist = 0.103440
03441
'funcion fuerza atracción al baricentro en x03442
f = g * dx / dist ^ 203443
Fx ( v ) = Fx ( v ) + f03444
'funcion fuerza atracción al baricentro en y03445
f = g * dy / dist ^ 203446
Fy ( v ) = Fy ( v ) + f03447
03448
'dx2 = (Grafico.TapizX / 2 - bx) - dx03449
'dy2 = (Grafico.TapizY / 2 - by) - dy03450
'dist2 = Math.Sqrt(dx2 ^ 2 + dy2 ^ 2)03451
'If dist2 = 0 Then dist2 = 0.103452
03453
'funcion fuerza atracción al centro tapiz en x03454
'f2 = dx2 / dist203455
'Fx(v) = Fx(v) + f203456
'funcion fuerza atracción al centro tapiz en y03457
'f2 = dy2 / dist203458
'Fy(v) = Fy(v) + f203459
03460
'En = En + dist203461
Next v03462
03463
'cálculo de fuerzas de atracción03464
'cada arco es equivalente a un muelle03465
Ea = 003466
For i = 0 To TotalArcos - 103467
If Arcos ( i ) . Nd1 <> Arcos ( i ) . Nd2 Then03468
'distancia entre nodos03469
dx = Nodos ( Arcos ( i ) . Nd2 ) . X - Nodos ( Arcos ( i ) . Nd1 ) . X03470
dy = Nodos ( Arcos ( i ) . Nd2 ) . Y - Nodos ( Arcos ( i ) . Nd1 ) . Y03471
dist = Math . Sqrt ( dx ^ 2 + dy ^ 2 )03472
If dist = 0 Then dist = 0.103473
03474
narcos = ExisteArcoReves ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 )03475
03476
'gradiente de distancia03477
dist = dist - Nodos ( Arcos ( i ) . Nd1 ) . Radio - Nodos ( Arcos ( i ) .» Nd2 ) . Radio
03478
gdist = ( dist - l ) '## hacer opción contando radios de» nodos
03479
'energía del arco03480
Ea = Ea + Math . Abs ( gdist )03481
03482
'funcion fuerza atracción en x03483
f = a * ( dx / dist ) * gdist / l03484
03485
If narcos > 0 Then f = f / 203486
Fx ( Arcos ( i ) . Nd1 ) = Fx ( Arcos ( i ) . Nd1 ) + f03487
Fx ( Arcos ( i ) . Nd2 ) = Fx ( Arcos ( i ) . Nd2 ) - f03488
'funcion fuerza atracción en y03489
f = a * ( dy / dist ) * gdist / l03490
03491
If narcos > 0 Then f = f / 203492
Fy ( Arcos ( i ) . Nd1 ) = Fy ( Arcos ( i ) . Nd1 ) + f03493
Fy ( Arcos ( i ) . Nd2 ) = Fy ( Arcos ( i ) . Nd2 ) - f03494
03495
condicion = False03496
For j = 0 To TotalArcos - 103497
If Arcos ( i ) . Nd1 = Arcos ( j ) . Nd1 Then condicion = True03498
If Arcos ( i ) . Nd1 = Arcos ( j ) . Nd2 Then condicion = True03499
If Arcos ( i ) . Nd2 = Arcos ( j ) . Nd1 Then condicion = True03500
If Arcos ( i ) . Nd2 = Arcos ( j ) . Nd2 Then condicion = True03501
If Arcos ( j ) . Nd2 = Arcos ( j ) . Nd1 Then condicion = True03502
03503
'entonces son arcos independientes03504
If condicion = False Then03505
x1 = Nodos ( Arcos ( i ) . Nd1 ) . X03506
x2 = Nodos ( Arcos ( i ) . Nd2 ) . X03507
x3 = Nodos ( Arcos ( j ) . Nd1 ) . X03508
x4 = Nodos ( Arcos ( j ) . Nd2 ) . X03509
y1 = Nodos ( Arcos ( i ) . Nd1 ) . Y03510
y2 = Nodos ( Arcos ( i ) . Nd2 ) . Y03511
y3 = Nodos ( Arcos ( j ) . Nd1 ) . Y03512
y4 = Nodos ( Arcos ( j ) . Nd2 ) . Y03513
03514
dx = x2 - x103515
dy = y2 - y103516
dx2 = x4 - x303517
dy2 = y4 - y303518
03519
'comprueba si las rectas se cortan03520
If dx / dy <> dx2 / dy2 Then03521
'busca el punto de corte03522
'solo una solución, no puede ser la misma» recta
03523
x0 = ( dy / dx - dy2 / dx2 ) / ( y3 - y1 )03524
y0 = y1 + x0 * dx / dy03525
03526
'mira si punto de corte esta dentro del» segmento
03527
If x0 >= x1 And x0 <= x2 Then03528
If y0 >= y1 And y0 <= y2 Then03529
'si se cortan arcos suma energía03530
Ea = Ea * 1.203531
03532
'debe impulsar un nodo para dejar de» ser cortante
03533
f = r * dx / - dy03534
Fx ( Arcos ( i ) . Nd1 ) = Fx ( Arcos ( i ) . Nd1 )» + f
03535
Fx ( Arcos ( i ) . Nd2 ) = Fx ( Arcos ( i ) . Nd2 )» - f
03536
Fy ( Arcos ( i ) . Nd1 ) = Fy ( Arcos ( i ) . Nd1 )» + f
03537
Fy ( Arcos ( i ) . Nd2 ) = Fy ( Arcos ( i ) . Nd2 )» - f
03538
'debe impulsar un nodo para dejar de» ser cortante
03539
f = r * dx2 / dy2 + 0.503540
Fx ( Arcos ( j ) . Nd1 ) = Fx ( Arcos ( j ) . Nd1 )» + f
03541
Fx ( Arcos ( j ) . Nd2 ) = Fx ( Arcos ( j ) . Nd2 )» - f
03542
Fy ( Arcos ( j ) . Nd1 ) = Fy ( Arcos ( j ) . Nd1 )» + f
03543
Fy ( Arcos ( j ) . Nd2 ) = Fy ( Arcos ( j ) . Nd2 )» - f
03544
End If03545
End If03546
End If03547
End If03548
condicion = False03549
Next j03550
03551
03552
End If03553
Next i03554
03555
'Función Energía total03556
E = Math . Abs ( Ea ) + Math . Abs ( En )03557
E1 = E03558
'If E1 > 1.0E+20 Then E1 = 1.0E+1903559
03560
'temperatura es función de la energía total del sistema03561
gradE = ( E1 - E0 )03562
temp = temp + gradE03563
If temp <= 0 Then temp = 0.00000000000000103564
E0 = E103565
03566
'desplazamiento en función de la temperatura03567
For v = 0 To TotalNodos - 103568
'vector fuerza03569
f = Math . Sqrt ( Fx ( v ) ^ 2 + Fy ( v ) ^ 2 )03570
If f = 0 Then f = 0.103571
'movimiento de los nodos03572
mx = ( Fx ( v ) / f ) + ( Fx ( v ) / f ) * Math . Abs (( gradE +» 0.000000000000001 ) / temp ) * Nodos ( v ) . Radio
03573
my = ( Fy ( v ) / f ) + ( Fy ( v ) / f ) * Math . Abs (( gradE +» 0.000000000000001 ) / temp ) * Nodos ( v ) . Radio
03574
'cambia posición de los nodos03575
Nodos ( v ) . X = Nodos ( v ) . X + mx03576
Nodos ( v ) . Y = Nodos ( v ) . Y + my03577
03578
'If Grafico.Iman Then03579
'Nodos(v).X = Int((Nodos(v).X + Nodos(v).Radio) /» Grafico.Rejilla) * Grafico.Rejilla
03580
'Nodos(v).Y = Int((Nodos(v).Y + Nodos(v).Radio) /» Grafico.Rejilla) * Grafico.Rejilla
03581
'End If03582
03583
'evita que se salgan del marco03584
If Nodos ( v ) . X - Nodos ( v ) . Radio <= 0 Then Nodos ( v ) . X = Nodos ( v )» . Radio * 2
03585
If Nodos ( v ) . Y - Nodos ( v ) . Radio <= 0 Then Nodos ( v ) . Y = Nodos ( v )» . Radio * 2
03586
03587
If BordeActivo Then03588
If Nodos ( v ) . X + Nodos ( v ) . Radio >= Grafico . TapizX Then» Nodos ( v ) . X = Grafico . TapizX - Nodos ( v ) . Radio * 2
03589
If Nodos ( v ) . Y + Nodos ( v ) . Radio >= Grafico . TapizY Then» Nodos ( v ) . Y = Grafico . TapizY - Nodos ( v ) . Radio * 2
03590
End If03591
Next v03592
03593
'redibuja03594
If k >= 50 Then03595
k = 003596
'dibuja todo03597
If BordeActivo Then03598
FormatoAjustar ( True , True )03599
Else03600
FormatoAjustar ( False , True )03601
End If03602
03603
PictureBox1 . Refresh ()03604
Else03605
'Debug.Write(temp)03606
'Debug.Write(vbCrLf)03607
End If03608
If temp = 0.000000000000001 Then Exit Sub03609
'If Math.Abs((gradE + 0.000000000000001) / temp) <= 0.00001 Then» Exit Sub
03610
Next it03611
'fin de las iteraciones03612
End Sub03613
Sub OrdenaenTablero ()03614
'redibuja en formato tablero03615
03616
Dim i , j As Long03617
Dim n As Long = Int ( Math . Sqrt ( TotalNodos ) + 1 )03618
Dim cx , cy As Single03619
cx = Grafico . TapizX / n03620
cy = Grafico . TapizY / n03621
03622
For i = 0 To TotalNodos - 103623
j = Int ( i / n )03624
03625
Nodos ( i ) . X = cx / 2 + cx * j03626
Nodos ( i ) . Y = cy / 2 + ( i - j * n ) * cy03627
Next i03628
End Sub03629
Sub Matriz_Grafico ()03630
'transforma los valores de matriz a valores de colección03631
'de nodos y arcos03632
Dim i As Long03633
03634
TotalNodos = NodosMatriz03635
ReDim Preserve Nodos ( TotalNodos - 1 )03636
'Dim c As Color03637
For i = 0 To TotalNodos - 103638
Nodos ( i ) . Texto = Cabecera1 ( i )03639
If Cabecera2 ( i ) = "" Then Cabecera2 ( i ) = "0"03640
03641
Nodos ( i ) . Valor = CSng ( Cabecera2 ( i ))03642
'después asigna en ordenar03643
' Nodos(i).X = Grafico.TapizX * Rnd() ' 0 'calcular03644
' Nodos(i).Y = Grafico.TapizY * Rnd() '0 'calcular03645
Nodos ( i ) . Z = 003646
03647
'If Nodos(i).Radio = 0 Then03648
Nodos ( i ) . Radio = Grafico . RadioNodo03649
'End If03650
'If Nodos(i).Grosor = 0 Then03651
Nodos ( i ) . Grosor = Grafico . TrazoNodo03652
'End If03653
03654
'If Nodos(i).Col.ToString = c.Empty.ToString Then03655
Nodos ( i ) . Col = Grafico . ColNodo03656
'End If03657
Next i03658
03659
Dim s1 , s2 As Integer03660
Dim j As Integer03661
Dim min , max , cost As Single03662
Dim p1 , p2 , p3 As String03663
i = 003664
Dim x , y As Long03665
03666
'cuenta arcos03667
'For x = 0 To NodosMatriz - 103668
'For y = 0 To NodosMatriz - 103669
' If Trim(Matriz(x, y)).Length > 0 And x <> y Then03670
''existe arco03671
' i = i + 103672
' End If03673
' Next y03674
' Next x03675
' TotalArcos = i03676
' ReDim Preserve Arcos(TotalArcos - 1)03677
03678
i = 003679
For x = 0 To NodosMatriz - 103680
For y = 0 To NodosMatriz - 103681
If Trim ( Matriz ( x , y )) . Length > 0 Then 'And x <> y Then03682
'existe arco03683
i = i + 103684
TotalArcos = i03685
03686
ReDim Preserve Arcos ( TotalArcos - 1 )03687
03688
'ver si su información es coherente03689
s1 = InStr ( Matriz ( x , y ), ";" , CompareMethod . Text )03690
03691
If s1 > 0 And s1 <= Matriz ( x , y ) . Length Then03692
s2 = InStr ( Microsoft . VisualBasic . Right ( Matriz ( x , y ),» Matriz ( x , y ) . Length - s1 ), ";" , CompareMethod . Text )
03693
End If03694
03695
p1 = ""03696
p2 = ""03697
p3 = ""03698
03699
If s1 > 1 Then03700
p1 = Microsoft . VisualBasic . Left ( Matriz ( x , y ), s1 - 1 )03701
03702
If s2 > 0 Then03703
p2 = Mid ( Matriz ( x , y ), s1 + 1 , s2 - 1 )03704
p3 = Microsoft . VisualBasic . Right ( Matriz ( x , y ),» Matriz ( x , y ) . Length - s1 - s2 )
03705
Else03706
p2 = Microsoft . VisualBasic . Right ( Matriz ( x , y ),» Matriz ( x , y ) . Length - s1 )
03707
p3 = ""03708
End If03709
Else03710
If s1 = 1 Then03711
p1 = ""03712
03713
If s2 > 0 Then03714
p2 = Mid ( Matriz ( x , y ), s1 + 1 , s2 - s1 )03715
p3 = Microsoft . VisualBasic . Right ( Matriz ( x , y )» , Matriz ( x , y ) . Length - s1 - s2 )
03716
Else03717
p2 = Microsoft . VisualBasic . Right ( Matriz ( x , y )» , Matriz ( x , y ) . Length - s1 )
03718
p3 = ""03719
End If03720
Else03721
's1=003722
p1 = Matriz ( x , y )03723
End If03724
End If03725
03726
03727
'evita errores de conversión de cadena vacia a single03728
If p1 = "" Then p1 = "0"03729
If p2 = "" Then p2 = "0"03730
If p3 = "" Then p3 = "0"03731
'ver opciones de gráfico para asignar partes a» min,max,cost
03732
'123 ok03733
If Grafico . minArco And Grafico . maxArco And Grafico . costArco» Then
03734
min = CSng ( p1 )03735
max = CSng ( p2 )03736
cost = CSng ( p3 )03737
End If03738
'1203739
If Grafico . minArco And Grafico . maxArco And Not Grafico .» costArco Then
03740
min = CSng ( p1 )03741
max = CSng ( p2 )03742
cost = 003743
End If03744
'1303745
If Grafico . minArco And Not Grafico . maxArco And Grafico .» costArco Then
03746
min = CSng ( p1 )03747
max = 003748
cost = CSng ( p2 )03749
End If03750
'2303751
If Not Grafico . minArco And Grafico . maxArco And Grafico .» costArco Then
03752
min = 003753
max = CSng ( p1 )03754
cost = CSng ( p2 )03755
End If03756
'203757
If Not Grafico . minArco And Grafico . maxArco And Not Grafico .» costArco Then
03758
min = 003759
max = CSng ( p1 )03760
cost = 003761
End If03762
'303763
If Not Grafico . minArco And Not Grafico . maxArco And Grafico .» costArco Then
03764
min = 003765
max = 003766
cost = CSng ( p1 )03767
End If03768
'103769
If Grafico . minArco And Not Grafico . maxArco And Not Grafico .» costArco Then
03770
min = CSng ( p1 )03771
max = 003772
cost = 003773
End If03774
03775
'pone los datos en el arco03776
Arcos ( i - 1 ) . Min = min03777
Arcos ( i - 1 ) . Max = max03778
Arcos ( i - 1 ) . Coste = cost03779
03780
Arcos ( i - 1 ) . Nd1 = y 'origen= fila =cabecera103781
Arcos ( i - 1 ) . Nd2 = x 'fin= columna03782
Arcos ( i - 1 ) . B = False 'por defecto siempre false, se» trata en DibujaGrafo
03783
Arcos ( i - 1 ) . Texto = ""03784
03785
'If Arcos(i - 1).ToString = c.Empty.ToString Then03786
Arcos ( i - 1 ) . Col = Grafico . ColArco03787
'End If03788
'If Arcos(i - 1).Grosor = 0 Then03789
Arcos ( i - 1 ) . Grosor = Grafico . TrazoArco03790
'End If03791
End If03792
Next y03793
Next x03794
End Sub03795
Private Sub mnuFormatoOpciones_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoOpciones . Click
03796
'Muestra el formulario de opciones del Grafo03797
03798
CajaPropiedades . Visible = True03799
mnuFormatoOpciones . Enabled = False03800
End Sub03801
Private Sub Form1_Load ( ByVal sender As System . Object , ByVal e As System .» EventArgs ) Handles MyBase . Load
03802
Dim f As Form03803
f = New Splash003804
03805
Dim version As String03806
version = System . Diagnostics . FileVersionInfo . GetVersionInfo ( System .» Reflection . Assembly . GetExecutingAssembly . Location ) . FileMajorPart
03807
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileMinorPart
03808
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileBuildPart
03809
03810
Dim nombre As String03811
nombre = System . Diagnostics . FileVersionInfo . GetVersionInfo ( System .» Reflection . Assembly . GetExecutingAssembly . Location ) . ProductName
03812
Dim CopyR As String03813
03814
CopyR = System . Diagnostics . FileVersionInfo . GetVersionInfo ( System .» Reflection . Assembly . GetExecutingAssembly . Location ) . LegalCopyright
03815
03816
Me . Text = nombre & " - v. " & version & " " & CopyR03817
03818
f . Visible = True03819
03820
'valores por defecto03821
OpcionesporDefecto ()03822
End Sub03823
Sub DibujaTabla ()03824
03825
TextBox1 . Visible = False03826
Me . Cursor = Cursors . WaitCursor03827
hfgTabla . Visible = False03828
hfgTabla . Dock = DockStyle . Fill03829
Dim x As Integer03830
Dim y As Integer03831
03832
03833
hfgTabla . Rows = NodosMatriz + 103834
hfgTabla . Cols = NodosMatriz + 203835
hfgTabla . FixedCols = 003836
hfgTabla . FixedRows = 103837
03838
hfgTabla . Row = 003839
hfgTabla . Col = 003840
hfgTabla . Text = "N1\N2"03841
03842
hfgTabla . Row = 003843
hfgTabla . Col = 103844
hfgTabla . Text = "Coste"03845
03846
For x = 0 To NodosMatriz - 103847
hfgTabla . Col = 2 + x03848
hfgTabla . Text = Cabecera1 ( x )03849
hfgTabla . CellBackColor = Color . LightGray03850
Next x03851
03852
For y = 0 To NodosMatriz - 103853
hfgTabla . Row = 1 + y03854
03855
For x = - 2 To NodosMatriz - 103856
03857
hfgTabla . Col = 2 + x03858
03859
If x = - 2 Then03860
hfgTabla . Text = Cabecera1 ( y )03861
hfgTabla . CellBackColor = Color . LightGray03862
End If03863
If x = - 1 Then03864
hfgTabla . Text = Cabecera2 ( y )03865
hfgTabla . CellBackColor = Color . Lavender03866
End If03867
If x >= 0 Then03868
hfgTabla . Text = Matriz ( x , y )03869
hfgTabla . CellBackColor = Color . White03870
End If03871
03872
If x = y Then hfgTabla . CellBackColor = Color . WhiteSmoke» '.LightGray
03873
Next x03874
Next y03875
03876
hfgTabla . Visible = True03877
Me . Cursor = Cursors . Default03878
End Sub03879
Sub RellenaMatrices ()03880
'Esta rutina, lee los datos iniciales del grafo en formato gráfico03881
'y rellena las matrices que se usarán para la tabla03882
'existe otra rutina que hace lo inverso para luego dibujar y grabar03883
'el grafo.03884
03885
NodosMatriz = TotalNodos03886
03887
'define matrices03888
ReDim Matriz ( NodosMatriz - 1 , NodosMatriz - 1 )03889
ReDim Cabecera1 ( NodosMatriz - 1 )03890
ReDim Cabecera2 ( NodosMatriz - 1 )03891
Dim x , y As Long03892
03893
'x e y son coordenadas de la tabla03894
'x=horizontal=columna03895
'y=vertical=fila03896
'no confundir con i,j donde i=fila=y,j=columna=x03897
'toma valores iniciales03898
For x = 0 To NodosMatriz - 103899
Cabecera1 ( x ) = Nodos ( x ) . Texto03900
Cabecera2 ( x ) = Nodos ( x ) . Valor . ToString03901
03902
For y = 0 To NodosMatriz - 103903
'If x <> y Then03904
'relación de arco03905
'nodo origen=y, nodo destino=x03906
'nodo origen=i, nodo destino=j03907
Matriz ( x , y ) = ContenidoCelda ( y , x ) 'pone datos del arco» según opciones
03908
'End If03909
Next y03910
Next x03911
03912
End Sub03913
Function ContenidoCelda ( ByVal n1 As Long , ByVal n2 As Long ) As String03914
'Busca el arco que cumple las condiciones de origen-destino03915
'y coloca la información necesaria en la tabla según las opciones03916
03917
Dim t As String03918
03919
Dim i As Long03920
For i = 0 To TotalArcos - 103921
If Arcos ( i ) . Nd1 = n1 And Arcos ( i ) . Nd2 = n2 Then03922
03923
If Grafico . minArco Or Grafico . maxArco Or Grafico . costArco Then03924
t = ""03925
03926
If Grafico . minArco Then03927
t = t & Arcos ( i ) . Min . ToString03928
End If03929
03930
If Grafico . maxArco Then03931
If Grafico . minArco Then t = t & "; "03932
t = t & Arcos ( i ) . Max . ToString03933
End If03934
03935
If Grafico . costArco Then03936
If ( Grafico . maxArco Or Grafico . minArco ) Then t = t &» "; "
03937
t = t & Arcos ( i ) . Coste . ToString03938
End If03939
03940
t = t & ""03941
03942
End If03943
Return t03944
End If03945
Next i03946
End Function03947
Shared Sub OpcionesporDefecto ()03948
Dim f As Form103949
f = New Form103950
03951
Grafico . Zoom = 103952
Grafico . Rejilla = 4003953
Grafico . Iman = True03954
Grafico . MostrarRejilla = True03955
03956
Grafico . TapizX = 100003957
Grafico . TapizY = 100003958
03959
Grafico . ColorRejilla = Color . LightGray03960
Grafico . ColorTapiz = Color . White03961
03962
Grafico . MostrarImagenTapiz = False03963
Grafico . ImagenTapiz = ""03964
03965
'nodo03966
Grafico . Fuente = f . Panel1 . Font 'configurar en tiempo de diseño03967
Grafico . TrazoNodo = 103968
Grafico . RadioNodo = 1503969
Grafico . ColNodo = Color . LightSteelBlue03970
Grafico . textoNodo = True03971
Grafico . costNodo = True03972
03973
'arco03974
Grafico . minArco = True03975
Grafico . maxArco = True03976
Grafico . costArco = True03977
Grafico . TrazoArco = 103978
Grafico . BArco = False03979
Grafico . ColArco = Color . Black03980
03981
'extensión por defecto del formato de fichero03982
Grafico . Extension = ".grf"03983
End Sub03984
Function ExistenNodosSueltos () As Boolean03985
'Busca en el grafo nodos que estén sueltos y no tengan arcos asociados03986
03987
Dim i , k As Long03988
Dim encontrado As Boolean03989
03990
For i = 0 To TotalNodos - 103991
encontrado = False03992
03993
For k = 0 To TotalArcos - 103994
If Arcos ( k ) . Nd1 = i Or Arcos ( k ) . Nd2 = i And ( Arcos ( k ) . Nd1 <>» Arcos ( k ) . Nd2 ) Then
03995
'además no es un arco de entrada y salida en el mismo nodo03996
encontrado = True03997
Exit For03998
End If03999
Next k04000
04001
If encontrado = False Then 'este nodo está suelto04002
Return True 'si que existen notos sueltos04003
End If04004
Next i04005
Return False 'no existen nodos sueltos04006
End Function04007
Function ExisteArco ( ByVal n1 As Long , ByVal n2 As Long ) As Long04008
'Cuenta cuantos arcos cumplen la condición de origen - destino04009
Dim i As Long04010
Dim contador As Long04011
contador = 004012
For i = 0 To TotalArcos - 104013
If ( Arcos ( i ) . Nd1 = n1 And Arcos ( i ) . Nd2 = n2 ) Then04014
contador = contador + 104015
04016
End If04017
Next i04018
Return contador04019
End Function04020
Function ExisteArcoReves ( ByVal n1 As Long , ByVal n2 As Long ) As Long04021
'Cuenta cuantos arcos cumplen la condición de origen - destino04022
Dim i As Long04023
Dim contador As Long04024
contador = 004025
For i = 0 To TotalArcos - 104026
If ( Arcos ( i ) . Nd1 = n2 And Arcos ( i ) . Nd2 = n1 ) Then 'aunque el» usuario lo tome al revés
04027
contador = contador + 104028
04029
End If04030
Next i04031
Return contador04032
End Function04033
Private Sub mnuEditarNodo_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuEditarNodo . Click
04034
'Accede en modo diálogo al formulario de04035
'edición de nodos04036
Dim f As Form304037
f = New Form304038
04039
f . ShowDialog ()04040
04041
DibujaGrafo ()04042
04043
End Sub04044
Private Sub mnuEditarArco_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuEditarArco . Click
04045
'Accede en modo diálogo al formulario de04046
'edición de arcos04047
Dim f As Form404048
f = New Form404049
04050
f . ShowDialog ()04051
04052
DibujaGrafo ()04053
End Sub04054
Private Sub mnuArchivoGuardarComo_Click ( ByVal sender As System . Object , ByVal» e As System . EventArgs ) Handles mnuArchivoGuardarComo . Click
04055
04056
'Esta opción de menú muestra el cuadro de diálogo04057
'de grabar fichero de datos del gráfico04058
'luego llama al procedimiento de mnuArchivoGuardar04059
04060
Dim saveFileDialog1 As New SaveFileDialog04061
saveFileDialog1 . AddExtension = True04062
saveFileDialog1 . DefaultExt = ".grf" 'en caso de no especificar, se toma» el formato propietario
04063
saveFileDialog1 . Filter = "GraphML format (*.graphml)|*.graphml|Fichero» de Grafos (*.grf)|*.grf|Todos los archivos (*.*)|*.*"
04064
04065
'El cuadro de diálogo se personaliza en función del formato por defecto04066
04067
Select Case Grafico . Extension04068
Case ".graphML"04069
'formato por defecto04070
saveFileDialog1 . FilterIndex = 1 'formato .graphML04071
Grafico . Extension = ".graphML"04072
Case ".grf"04073
saveFileDialog1 . FilterIndex = 2 'formato .grf04074
Grafico . Extension = ".grf"04075
Case Else04076
saveFileDialog1 . FilterIndex = 2 'formato .grf04077
Grafico . Extension = ".grf"04078
End Select04079
04080
saveFileDialog1 . Title = "Guardar Archivo de Grafo"04081
saveFileDialog1 . RestoreDirectory = True04082
04083
Try04084
If saveFileDialog1 . ShowDialog () = DialogResult . OK Then04085
04086
Grafico . Fichero = saveFileDialog1 . FileName04087
04088
'llama al menu de guardar fichero04089
'en función de la respuesta del usuario04090
'respecto a la extensión (formato fichero)04091
'seleccionado.04092
04093
'Guarda con formato XML04094
'Extensión .graphML04095
If saveFileDialog1 . FilterIndex = 1 Then04096
Grafico . Extension = ".graphML"04097
Me . mnuArchivoGuardar_Click ( sender , e )04098
End If04099
'Guarda con formato propietario Grafos04100
'Extensión .grf04101
If saveFileDialog1 . FilterIndex = 2 Then04102
Grafico . Extension = ".grf"04103
Me . mnuArchivoGuardar_Click ( sender , e )04104
End If04105
'Cualquier otra extensión .???04106
'Guarda con formato propietario Grafos04107
'Extensión .grf04108
If saveFileDialog1 . FilterIndex = 3 Then04109
Grafico . Extension = ".grf"04110
Me . mnuArchivoGuardar_Click ( sender , e )04111
End If04112
End If04113
04114
Catch04115
Exit Sub04116
End Try04117
End Sub04118
Private Sub mnuArchivoAbrir_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuArchivoAbrir . Click
04119
If TotalNodos > 0 Or NodosMatriz > 0 Then04120
Dim respuesta As MsgBoxResult04121
respuesta = MsgBox ( " Si abre un fichero, perderá los datos» actuales." & vbCrLf & "¿Desea realmente abrir un fichero?" ,
» MsgBoxStyle . OKCancel , )
04122
If respuesta = MsgBoxResult . Cancel Then Exit Sub04123
End If04124
04125
'Esta opción de menú muestra el cuadro de diálogo04126
'de abrir fichero de datos del gráfico04127
'luego lee el fichero04128
04129
Dim openFileDialog1 As New OpenFileDialog04130
openFileDialog1 . AddExtension = True04131
openFileDialog1 . DefaultExt = ".grf" 'en caso de no especificar, se toma» el formato propietario
04132
openFileDialog1 . Filter = "GraphML format (*.graphml)|*.graphml|Fichero» de Grafos (*.grf)|*.grf|Todos los archivos (*.*)|*.*"
04133
openFileDialog1 . FilterIndex = 2 'formato por defecto .grf04134
openFileDialog1 . Title = "Abrir Archivo de Grafo"04135
openFileDialog1 . RestoreDirectory = True04136
04137
'personaliza el formato de lectura en función del último fichero leído04138
Select Case Grafico . Extension04139
Case ".graphML"04140
'formato por defecto04141
openFileDialog1 . FilterIndex = 1 'formato .graphML04142
Grafico . Extension = ".graphML"04143
Case ".grf"04144
openFileDialog1 . FilterIndex = 2 'formato .grf04145
Grafico . Extension = ".grf"04146
Case Else04147
openFileDialog1 . FilterIndex = 2 'formato .grf04148
Grafico . Extension = ".grf"04149
End Select04150
04151
If openFileDialog1 . ShowDialog () = DialogResult . OK Then04152
Grafico . Fichero = openFileDialog1 . FileName04153
Else04154
Exit Sub04155
End If04156
04157
Me . Cursor = Cursors . WaitCursor04158
04159
'proceso de lectura según el tipo de extensión elegido04160
Select Case openFileDialog1 . FilterIndex04161
Case 104162
'formato por defecto04163
'openFileDialog1.FilterIndex = 1 'formato .graphML04164
Grafico . Extension = ".graphML"04165
LeeFicheroGraphML ( Grafico . Fichero )04166
Case 204167
'openFileDialog1.FilterIndex = 2 'formato .grf04168
Grafico . Extension = ".grf"04169
LeeFicheroGRF ( Grafico . Fichero )04170
Case Else04171
'openFileDialog1.FilterIndex = 3 '*.* = formato .grf04172
Grafico . Extension = ".grf"04173
LeeFicheroGRF ( Grafico . Fichero )04174
End Select04175
04176
Grafico . ImagenTapiz = ""04177
Grafico . MostrarImagenTapiz = False04178
'inicia la caja de propiedades con las opciones por defecto elegidas04179
CajaPropiedades . LeeOpciones ()04180
04181
'Cambia y posiciona el picturebox04182
PictureBox1 . Top = 004183
PictureBox1 . Left = 004184
PictureBox1 . Width = Grafico . TapizX * Grafico . Zoom04185
PictureBox1 . Height = Grafico . TapizX * Grafico . Zoom04186
04187
'no selecciona ningún nodo04188
Nd1S = - 104189
Nd2S = - 104190
DibujaGrafo ()04191
04192
Me . StatusBar . Panels ( 6 ) . Text = Grafico . Fichero04193
04194
PictureBox1 . Visible = True04195
ActivaMenus ()04196
Me . mnuEdicionGrafica_Click ( Me , e )04197
Me . Cursor = Cursors . Default04198
End Sub04199
Private Sub mnuEdicionTabular_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuEdicionTabular . Click
04200
If mnuEdicionGrafica . Checked = True Then04201
04202
If CajaImportar . Visible = True Then CajaImportar . Visible = False04203
If CajaExportar . Visible = True Then CajaExportar . Visible = False04204
If CajaNuevoAleatorio . Visible = True Then CajaNuevoAleatorio . Visible» = False
04205
04206
If TotalNodos = 0 Then 'CREA TABLA NUEVA04207
04208
NuevoNodosMatriz = 104209
'muestra cuadro de diálogo de total nodos04210
Dim midialogo As New Form504211
midialogo . ShowDialog ()04212
04213
If midialogo . DialogResult = DialogResult . OK Then04214
04215
NodosMatriz = NuevoNodosMatriz04216
ReDim Matriz ( NodosMatriz - 1 , NodosMatriz - 1 )04217
ReDim Cabecera1 ( NodosMatriz - 1 )04218
ReDim Cabecera2 ( NodosMatriz - 1 )04219
04220
'Opción de renumerado automático04221
Dim RenumNodos As Boolean04222
RenumNodos = False04223
Dim respuesta2 As MsgBoxResult04224
respuesta2 = MsgBox ( "¿Desea renumerar automáticamente los» nodos?" , MsgBoxStyle . OKCancel , )
04225
If respuesta2 = MsgBoxResult . OK Then RenumNodos = True04226
Dim x As Long04227
'Renumeración automática de nodos04228
If RenumNodos Then04229
For x = 0 To NodosMatriz - 104230
Cabecera1 ( x ) = x04231
Next x04232
End If04233
04234
Else04235
Exit Sub04236
End If04237
Else04238
'Sale del programa pidiendo antes confirmación04239
Dim respuesta As MsgBoxResult04240
respuesta = MsgBox ( "La edición tabular del grafo actual» supondrá la pérdida de los estilos gráficos del mismo." &
» vbCrLf & "¿Desea realmente editar en formato tabular?" ,
» MsgBoxStyle . OKCancel , )
04241
If respuesta = MsgBoxResult . Cancel Then Exit Sub04242
04243
'toma valores iniciales del gráfico04244
RellenaMatrices ()04245
End If04246
'pasa al formato tabla04247
DibujaTabla ()04248
04249
mnuEdicionTabular . Checked = True04250
mnuEdicionGrafica . Checked = False04251
04252
mnuAnalisis . Enabled = False04253
04254
Me . mnuArchivoNuevoAleatorio . Enabled = False04255
mnuArchivoGuardar . Enabled = False04256
mnuArchivoGuardarComo . Enabled = False04257
mnuArchivoExportarDatos . Enabled = False04258
mnuArchivoImportarDatos . Enabled = False04259
mnuArchivoImprimir . Enabled = False04260
mnuArchivoExportarImg . Enabled = False04261
mnuArchivoCopiarImg . Enabled = False04262
mnuFormato . Enabled = False04263
PictureBox1 . Visible = False04264
End If04265
End Sub04266
Private Sub mnuTablaBorrarNodo_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuTablaBorrarNodo . Click
04267
'Opción del menú popup de la celda que se ocupa de borrar04268
'la fila y columna del nodo seleccionado04269
04270
'Quita el foco al textbox para que no se04271
'quede grabado su antiguo valor que va a04272
'desaparecer con esta operación04273
TextBox1 . Visible = False04274
hfgTabla . Focus ()04275
04276
'Opción de renumerado automático04277
Dim RenumNodos As Boolean04278
RenumNodos = False04279
Dim respuesta2 As MsgBoxResult04280
respuesta2 = MsgBox ( "¿Desea renumerar automáticamente los nodos?" ,» MsgBoxStyle . OKCancel , )
04281
If respuesta2 = MsgBoxResult . OK Then RenumNodos = True04282
04283
04284
04285
'Para ello deberá correr los datos hacia abajo de la matriz04286
'y la cabeceras y redimensionar todos los arrays a uno menos04287
If CeldaY >= 0 And NodosMatriz > 0 Then04288
04289
Dim x , y As Long04290
04291
If CeldaY < NodosMatriz - 1 Then04292
'se corren los datos hacia abajo para guardar04293
For y = CeldaY To NodosMatriz - 1 - 104294
Cabecera1 ( y ) = Cabecera1 ( y + 1 )04295
Cabecera2 ( y ) = Cabecera2 ( y + 1 )04296
Next y04297
For x = 0 To NodosMatriz - 104298
For y = CeldaY To NodosMatriz - 1 - 104299
Matriz ( x , y ) = Matriz ( x , y + 1 )04300
Next y04301
Next x04302
For x = CeldaY To NodosMatriz - 1 - 104303
For y = 0 To NodosMatriz - 104304
Matriz ( x , y ) = Matriz ( x + 1 , y )04305
Next y04306
Next x04307
Else04308
'no es necesario correr datos04309
'se perderá la última fila y04310
'columna04311
End If04312
'ahora hay uno menos04313
NodosMatriz = NodosMatriz - 104314
04315
'define matrices04316
Dim MatTemp ( NodosMatriz - 1 , NodosMatriz - 1 ) As String04317
'pasa los datos a una matriz temporal04318
For x = 0 To NodosMatriz - 104319
For y = 0 To NodosMatriz - 104320
MatTemp ( x , y ) = Matriz ( x , y )04321
Next y04322
Next x04323
04324
'redimensiona las dos dimensiones sin preservar04325
'con preserve sólo puede cambiar la última dimensión04326
ReDim Matriz ( NodosMatriz - 1 , NodosMatriz - 1 )04327
04328
'devuelve los datos desde la matriz temporal04329
For x = 0 To NodosMatriz - 104330
For y = 0 To NodosMatriz - 104331
Matriz ( x , y ) = MatTemp ( x , y )04332
Next y04333
Next x04334
'como tiene una sola dimensión si se puede redimensionar04335
ReDim Preserve Cabecera1 ( NodosMatriz - 1 )04336
ReDim Preserve Cabecera2 ( NodosMatriz - 1 )04337
04338
'Renumeración automática de nodos04339
If RenumNodos Then04340
For x = 0 To NodosMatriz - 104341
Cabecera1 ( x ) = x04342
Next x04343
End If04344
04345
'manda redibujar la tabla04346
'con una fila y columna menos04347
DibujaTabla ()04348
End If04349
End Sub04350
Private Sub mnuTablaAñadirNodo_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuTablaAñadirNodo . Click
04351
04352
04353
'Quita el foco al textbox para que no se04354
'quede grabado su antiguo valor que va a04355
'desaparecer con esta operación04356
TextBox1 . Visible = False04357
hfgTabla . Focus ()04358
04359
'Añade una única fila más a la tabla04360
Dim x , y As Long04361
04362
'define matrices04363
Dim MatTemp ( NodosMatriz - 1 , NodosMatriz - 1 ) As String04364
'pasa los datos a una matriz temporal04365
For x = 0 To NodosMatriz - 104366
For y = 0 To NodosMatriz - 104367
MatTemp ( x , y ) = Matriz ( x , y )04368
Next y04369
Next x04370
04371
'ahora hay uno más04372
NodosMatriz = NodosMatriz + 104373
04374
'redimensiona las dos dimensiones sin preservar04375
'con preserve sólo puede cambiar la última dimensión04376
ReDim Matriz ( NodosMatriz - 1 , NodosMatriz - 1 )04377
04378
'devuelve los datos desde la matriz temporal04379
'la nueva fila columna no tendrá datos heredados04380
For x = 0 To NodosMatriz - 1 - 104381
For y = 0 To NodosMatriz - 1 - 104382
Matriz ( x , y ) = MatTemp ( x , y )04383
Next y04384
Next x04385
'como tiene una sola dimensión si se puede redimensionar04386
ReDim Preserve Cabecera1 ( NodosMatriz - 1 )04387
ReDim Preserve Cabecera2 ( NodosMatriz - 1 )04388
04389
Cabecera1 ( NodosMatriz - 1 ) = "Nuevo Nodo"04390
Cabecera2 ( NodosMatriz - 1 ) = 004391
04392
04393
'manda redibujar la tabla04394
'con una fila y columna menos04395
DibujaTabla ()04396
04397
04398
End Sub04399
Private Sub mnuTablaTotalNodos_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuTablaTotalNodos . Click
04400
'Cambia el total de nodos de la matriz04401
04402
'Quita el foco al textbox para que no se04403
'quede grabado su antiguo valor que va a04404
'desaparecer con esta operación04405
TextBox1 . Visible = False04406
hfgTabla . Focus ()04407
04408
NuevoNodosMatriz = NodosMatriz04409
'muestra cuadro de diálogo de total nodos04410
Dim midialogo As New Form504411
midialogo . ShowDialog ()04412
04413
Dim RenumNodos As Boolean04414
RenumNodos = False04415
04416
04417
If midialogo . DialogResult = DialogResult . OK Then04418
'en caso de reducción avisar al usuario que perderá las últimas» filas columnas
04419
If NuevoNodosMatriz < NodosMatriz Then04420
Dim respuesta As MsgBoxResult04421
respuesta = MsgBox ( " El nuevo tamaño de matriz es más pequeño» que antes." & vbCrLf & " Se perderán las últimas filas y
» columnas." & vbCrLf & " ¿Desea continuar con el
» redimensionamiento de la matriz?" , MsgBoxStyle . OKCancel , )
04422
If respuesta = MsgBoxResult . Cancel Then Exit Sub04423
End If04424
If NuevoNodosMatriz = NodosMatriz Then04425
Exit Sub04426
End If04427
Dim respuesta2 As MsgBoxResult04428
respuesta2 = MsgBox ( "¿Desea renumerar automáticamente los nodos?" ,» MsgBoxStyle . OKCancel , )
04429
If respuesta2 = MsgBoxResult . OK Then RenumNodos = True04430
Else04431
Exit Sub04432
End If04433
04434
'comprobar si es una operación de ampliación04435
'o de reducción de la matriz04436
04437
Dim x , y As Long04438
04439
'diferencia el orden de las operaciones según se amplie04440
'o reduzca el tamaño de la matriz04441
04442
'define matrices04443
Dim MatTemp ( NodosMatriz - 1 , NodosMatriz - 1 ) As String04444
'pasa los datos a una matriz temporal04445
For x = 0 To NodosMatriz - 104446
For y = 0 To NodosMatriz - 104447
MatTemp ( x , y ) = Matriz ( x , y )04448
Next y04449
Next x04450
04451
'redimensiona las dos dimensiones sin preservar04452
'con preserve sólo puede cambiar la última dimensión04453
ReDim Matriz ( NuevoNodosMatriz - 1 , NuevoNodosMatriz - 1 )04454
04455
'devuelve los datos desde la matriz temporal04456
For x = 0 To NuevoNodosMatriz - 104457
For y = 0 To NuevoNodosMatriz - 104458
If NodosMatriz > NuevoNodosMatriz Then04459
'pasa todos los datos antiguos04460
'se perderán las ultimas filas y columnas04461
Matriz ( x , y ) = MatTemp ( x , y )04462
Else04463
'pasa los datos que tiene04464
'pero las nuevas filas y columnas04465
'estarán vacias04466
If x <= NodosMatriz - 1 And y <= NodosMatriz - 1 Then04467
Matriz ( x , y ) = MatTemp ( x , y )04468
End If04469
04470
End If04471
Next y04472
Next x04473
04474
'cambia total04475
NodosMatriz = NuevoNodosMatriz04476
'como tiene una sola dimensión si se puede redimensionar04477
ReDim Preserve Cabecera1 ( NodosMatriz - 1 )04478
ReDim Preserve Cabecera2 ( NodosMatriz - 1 )04479
04480
'Renumeración automática de nodos04481
If RenumNodos Then04482
For x = 0 To NodosMatriz - 104483
Cabecera1 ( x ) = x04484
Next x04485
End If04486
04487
'manda redibujar la tabla04488
'con una fila y columna menos04489
DibujaTabla ()04490
End Sub04491
Sub EditaCelda ()04492
'guarda posición de celda04493
CeldaX = hfgTabla . Col - 204494
CeldaY = hfgTabla . Row - 104495
04496
'un nodo no puede tener un arco con si mismo04497
'If CeldaX >= 0 And CeldaY >= 0 And CeldaX = CeldaY Then Exit Sub04498
04499
'configura el textbox04500
TextBox1 . Visible = False04501
TextBox1 . AutoSize = False04502
TextBox1 . BorderStyle = BorderStyle . None04503
'posiciona el textbox04504
TextBox1 . Top = hfgTabla . CellTop / 1504505
TextBox1 . Left = hfgTabla . CellLeft / 1504506
TextBox1 . Width = hfgTabla . CellWidth / 1504507
TextBox1 . Height = hfgTabla . CellHeight / 1504508
TextBox1 . Font = hfgTabla . Font04509
TextBox1 . BackColor = Color . LightBlue 'un azul muy molón!04510
TextBox1 . TextAlign = HorizontalAlignment . Right04511
'toma el texto a editar04512
TextBox1 . Text = hfgTabla . Text04513
'selecciona automáticamente su contenido04514
TextBox1 . SelectionStart = 004515
TextBox1 . SelectionLength = TextBox1 . Text . Length04516
'Muestra el textbox de edición de celda04517
TextBox1 . Visible = True04518
TextBox1 . Focus () 'le pasa el foco!!04519
End Sub04520
Private Sub hfgTabla_KeyPressEvent ( ByVal sender As Object , ByVal e As» AxMSFlexGridLib . DMSFlexGridEvents_KeyPressEvent ) Handles hfgTabla .
» KeyPressEvent
04521
'Activa la edición de la celda actual04522
'al pulsar la tecla enter sobre la tabla04523
If e . keyAscii = 13 Then04524
EditaCelda ()04525
End If04526
End Sub04527
Private Sub TextBox1_Leave ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles TextBox1 . Leave
04528
'Guarda los nuevos datos tanto en la matriz como en la tabla04529
'así no es necesario redibujar toda la tabla cada vez04530
If CeldaX > - 2 And CeldaY >= 0 Then04531
FiltraTexto ( sender )04532
End If04533
04534
Dim x , y As Long04535
If CeldaX >= 0 And CeldaY >= 0 And NodosMatriz > 0 Then04536
Matriz ( CeldaX , CeldaY ) = TextBox1 . Text04537
04538
x = CeldaX + 204539
y = CeldaY + 104540
04541
hfgTabla . Row = y04542
hfgTabla . Col = x04543
hfgTabla . Text = TextBox1 . Text04544
End If04545
If CeldaX = - 2 And CeldaY >= 0 And NodosMatriz > 0 Then04546
Cabecera1 ( CeldaY ) = TextBox1 . Text04547
04548
x = 004549
y = CeldaY + 204550
04551
hfgTabla . Col = y04552
hfgTabla . Row = x04553
hfgTabla . Text = TextBox1 . Text04554
04555
hfgTabla . Col = 004556
hfgTabla . Row = y - 104557
hfgTabla . Text = TextBox1 . Text04558
04559
End If04560
If CeldaX = - 1 And CeldaY >= 0 And NodosMatriz > 0 Then04561
Cabecera2 ( CeldaY ) = TextBox1 . Text04562
04563
x = CeldaX + 204564
y = CeldaY + 104565
04566
hfgTabla . Row = y04567
hfgTabla . Col = x04568
hfgTabla . Text = TextBox1 . Text04569
End If04570
04571
End Sub04572
Private Sub TextBox1_KeyPress ( ByVal sender As Object , ByVal e As System .» Windows . Forms . KeyPressEventArgs ) Handles TextBox1 . KeyPress
04573
'Si se pulsa enter finaliza la edición de la celda04574
If Asc ( e . KeyChar ) = 13 Then04575
TextBox1_Leave ( sender , e )04576
TextBox1 . Visible = False04577
End If04578
'Interior de la matriz04579
If CeldaX > - 2 And CeldaY >= 0 Then04580
'excepción separador ; a la función interceptateclas04581
If e . KeyChar = ";" Then04582
'caracter permitido04583
Else04584
InterceptaTeclas ( e )04585
End If04586
End If04587
'Cabecera 204588
If CeldaX = - 1 And CeldaY >= 0 Then04589
InterceptaTeclas ( e )04590
End If04591
End Sub04592
Private Sub hfgTabla_EnterCell ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles hfgTabla . EnterCell
04593
'marca la celda que está en edición e informa al usuario04594
'en el statusbar04595
04596
CeldaX = hfgTabla . Col - 204597
CeldaY = hfgTabla . Row - 104598
'status bar panel04599
If CeldaY >= 0 Then04600
StatusBar . Panels ( 0 ) . Text = "N1=" & Cabecera1 ( CeldaY )04601
Else04602
StatusBar . Panels ( 0 ) . Text = ""04603
End If04604
If CeldaX >= 0 Then04605
StatusBar . Panels ( 1 ) . Text = "N2=" & Cabecera1 ( CeldaX )04606
Else04607
StatusBar . Panels ( 1 ) . Text = ""04608
End If04609
'Opciones del menú popup04610
If CeldaX = - 2 And CeldaY >= 0 And NodosMatriz > 1 Then04611
mnuTablaBorrarNodo . Enabled = True04612
Else04613
mnuTablaBorrarNodo . Enabled = False04614
End If04615
04616
End Sub04617
Private Sub hfgTabla_ClickEvent ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles hfgTabla . ClickEvent
04618
'Se activa la edición de la celda04619
'al hacer clic sobre la tabla04620
TextBox1 . Visible = False04621
EditaCelda ()04622
04623
End Sub04624
Private Sub mnuFormatoCircular_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoCircular . Click
04625
mnuFormatoAleatorio . Checked = False04626
mnuFormatoTablero . Checked = False04627
mnuFormatoCircular . Checked = True04628
mnuFormatoFlujo . Checked = False04629
mnuFormatoOrganico . Checked = False04630
04631
If TotalNodos = 0 Then Exit Sub04632
04633
'pide antes confirmación04634
Dim respuesta As MsgBoxResult04635
respuesta = MsgBox ( "Esta opción cambiará la ubicación de los nodos en» forma de estrella." & vbCrLf & "¿Desea realmente reordenar los
» nodos?" , MsgBoxStyle . OKCancel , )
04636
If respuesta = MsgBoxResult . Cancel Then Exit Sub04637
04638
Me . Cursor = Cursors . WaitCursor04639
OrdenaenEstrella ()04640
04641
If Grafico . Iman Then Imantar ()04642
DibujaGrafo ()04643
Me . Cursor = Cursors . Default04644
End Sub04645
Private Sub mnuFormatoAleatorio_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoAleatorio . Click
04646
04647
mnuFormatoAleatorio . Checked = True04648
mnuFormatoTablero . Checked = False04649
mnuFormatoCircular . Checked = False04650
mnuFormatoFlujo . Checked = False04651
mnuFormatoOrganico . Checked = False04652
04653
If TotalNodos = 0 Then Exit Sub04654
04655
04656
'pide antes confirmación04657
Dim respuesta As MsgBoxResult04658
respuesta = MsgBox ( "Esta opción cambiará la ubicación de los nodos de» manera aleatoria." & vbCrLf & "¿Desea realmente reordenar los nodos?"
» , MsgBoxStyle . OKCancel , )
04659
If respuesta = MsgBoxResult . Cancel Then Exit Sub04660
Me . Cursor = Cursors . WaitCursor04661
OrdenaAleatorio ()04662
04663
If Grafico . Iman Then Imantar ()04664
DibujaGrafo ()04665
Me . Cursor = Cursors . Default04666
End Sub04667
Private Sub mnuFormatoTablero_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoTablero . Click
04668
04669
mnuFormatoAleatorio . Checked = False04670
mnuFormatoTablero . Checked = True04671
mnuFormatoCircular . Checked = False04672
mnuFormatoFlujo . Checked = False04673
mnuFormatoOrganico . Checked = False04674
If TotalNodos = 0 Then Exit Sub04675
04676
'pide antes confirmación04677
Dim respuesta As MsgBoxResult04678
respuesta = MsgBox ( "Esta opción cambiará la ubicación de los nodos en» forma de cuadrícula." & vbCrLf & " ¿Desea realmente reordenar los
» nodos?" , MsgBoxStyle . OKCancel , )
04679
If respuesta = MsgBoxResult . Cancel Then Exit Sub04680
Me . Cursor = Cursors . WaitCursor04681
OrdenaenTablero ()04682
04683
If Grafico . Iman Then Imantar ()04684
DibujaGrafo ()04685
Me . Cursor = Cursors . Default04686
End Sub04687
Private Sub mnuFormato_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuFormato . Click
04688
04689
End Sub04690
Private Sub mnuTablaCopiarTabla_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuTablaCopiarTabla . Click
04691
'copia el contenido de toda la tabla al portapapeles04692
04693
'Quita el foco al textbox para que no se04694
'quede grabado su antiguo valor que va a04695
'desaparecer con esta operación04696
TextBox1 . Visible = False04697
hfgTabla . Focus ()04698
04699
Dim cadena As String04700
Dim campo As String04701
Dim x , y As Long04702
04703
cadena = ""04704
For y = - 1 To NodosMatriz - 104705
campo = ""04706
For x = - 2 To NodosMatriz - 104707
If y = - 1 Then04708
If x = - 2 Then04709
campo = campo & "N1\N2" & vbTab04710
End If04711
If x = - 1 Then04712
campo = campo & "Coste" & vbTab04713
End If04714
If x > - 1 Then04715
campo = campo & Cabecera1 ( x ) & vbTab04716
End If04717
End If04718
If y > - 1 Then04719
If x = - 2 Then04720
campo = campo & Cabecera1 ( y ) & vbTab04721
End If04722
If x = - 1 Then04723
campo = campo & Cabecera2 ( y ) & vbTab04724
End If04725
If x > - 1 Then04726
campo = campo & Matriz ( x , y ) & vbTab04727
End If04728
End If04729
Next x04730
cadena = cadena + campo & vbCrLf04731
Next y04732
04733
Clipboard . SetDataObject ( cadena )04734
End Sub04735
Private Sub mnuAlinearNodosH_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuAlinearNodosH . Click
04736
'Iguala la coordenada Y de los dos nodos seleccionados04737
If Nodos ( Nd1S ) . Y < Nodos ( Nd2S ) . Y Then04738
Nodos ( Nd2S ) . Y = Nodos ( Nd1S ) . Y04739
Else04740
Nodos ( Nd1S ) . Y = Nodos ( Nd2S ) . Y04741
End If04742
04743
If Grafico . Iman Then04744
Nodos ( Nd1S ) . X = Int ( Nodos ( Nd1S ) . X / Grafico . Rejilla ) * Grafico .» Rejilla
04745
Nodos ( Nd1S ) . Y = Int ( Nodos ( Nd1S ) . Y / Grafico . Rejilla ) * Grafico .» Rejilla
04746
04747
Nodos ( Nd2S ) . X = Int ( Nodos ( Nd2S ) . X / Grafico . Rejilla ) * Grafico .» Rejilla
04748
Nodos ( Nd2S ) . Y = Int ( Nodos ( Nd2S ) . Y / Grafico . Rejilla ) * Grafico .» Rejilla
04749
End If04750
04751
DibujaGrafo ()04752
04753
End Sub04754
Private Sub mnuAlinearNodosV_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuAlinearNodosV . Click
04755
'Iguala la coordenada X de los dos nodos seleccionados04756
If Nodos ( Nd1S ) . X < Nodos ( Nd2S ) . X Then04757
Nodos ( Nd2S ) . X = Nodos ( Nd1S ) . X04758
Else04759
Nodos ( Nd1S ) . X = Nodos ( Nd2S ) . X04760
End If04761
04762
If Grafico . Iman Then04763
Nodos ( Nd1S ) . X = Int ( Nodos ( Nd1S ) . X / Grafico . Rejilla ) * Grafico .» Rejilla
04764
Nodos ( Nd1S ) . Y = Int ( Nodos ( Nd1S ) . Y / Grafico . Rejilla ) * Grafico .» Rejilla
04765
04766
Nodos ( Nd2S ) . X = Int ( Nodos ( Nd2S ) . X / Grafico . Rejilla ) * Grafico .» Rejilla
04767
Nodos ( Nd2S ) . Y = Int ( Nodos ( Nd2S ) . Y / Grafico . Rejilla ) * Grafico .» Rejilla
04768
End If04769
04770
DibujaGrafo ()04771
End Sub04772
Private Sub mnuAlinearNodos_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuAlinearNodos . Click
04773
04774
End Sub04775
Private Sub Dijkstra1_Fallo ( ByVal TextoError As String ) Handles Dijkstra1 .» Fallo
04776
'Este evento salta en caso de un error en el proceso de Dijstra04777
MsgBox ( TextoError , MsgBoxStyle . Exclamation , "Error en el proceso» Dijkstra" )
04778
End Sub04779
Private Sub mnuAnalisisDijkstra_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuAnalisisDijkstra . Click
04780
04781
If Nd1S = - 1 Then04782
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Árbol mínimo) debe» seleccionar" & vbCrLf & "un nodo con el botón izquierdo del
» ratón." , MsgBoxStyle . Information , "Algoritmo de Dijkstra" )
04783
Exit Sub04784
End If04785
04786
If Grafico . costArco = False Then04787
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Árbol mínimo) debe» activar la opción Coste" & vbCrLf & "de los arcos del grafo en el
» menú Formato/Opciones/Arcos." , MsgBoxStyle . Information ,
» "Algoritmo de Dijkstra" )
04788
Exit Sub04789
End If04790
04791
'----------------------------------------------------04792
'A la dll se le debe pasar un array de strings04793
'de dimensión totalnodos-1 ya que empieza en 004794
'con el nombre o etiqueta de los nodos04795
'----------------------------------------------------04796
04797
'Dim prueba() As String04798
'ReDim prueba(4)04799
'prueba(0) = "Nodo 0"04800
'prueba(1) = "Nodo 1"04801
'prueba(2) = "Nodo 2"04802
'prueba(3) = "Nodo 3"04803
'prueba(4) = "Nodo 4"04804
04805
04806
Dim i , j As Long04807
Dim MatrizNodos ( TotalNodos - 1 ) As String04808
For i = 0 To TotalNodos - 104809
MatrizNodos ( i ) = Nodos ( i ) . Texto04810
Next i04811
04812
'----------------------------------------------------04813
'a la dll se le debe pasar las relaciones de arco en04814
'matriz(i,j) donde i=nodo origen, j=nodo destino04815
'de dimensiones de 0 a totalnodos-1 para i y para j04816
'contendrá un single >=004817
'recuerda que después del proceso RellenaMatrices04818
'se dispone de un array de relación de arco que es04819
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)04820
'----------------------------------------------------04821
04822
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single04823
'pone toda la matriz a -104824
For i = 0 To TotalNodos - 104825
For j = 0 To TotalNodos - 104826
MatrizArcos ( i , j ) = - 104827
Next j04828
Next i04829
'marca los arcos existentes, pero no los de un mismo nodo04830
For i = 0 To TotalArcos - 104831
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then04832
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = - 104833
Else04834
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste04835
End If04836
Next i04837
04838
'si no existe relación marcar como -104839
' Dim prueba2(0, 0) As Single04840
' ReDim prueba2(4, 4)04841
' prueba2(0, 0) = -104842
' prueba2(0, 1) = 1004843
' prueba2(0, 2) = -104844
' prueba2(0, 3) = 504845
' prueba2(0, 4) = -104846
'04847
' prueba2(1, 0) = -104848
' prueba2(1, 1) = -104849
' prueba2(1, 2) = 104850
' prueba2(1, 3) = 204851
' prueba2(1, 4) = -104852
'04853
' prueba2(2, 0) = -104854
' prueba2(2, 1) = -104855
' prueba2(2, 2) = -104856
' prueba2(2, 3) = -104857
' prueba2(2, 4) = 404858
'04859
' prueba2(3, 0) = -104860
' prueba2(3, 1) = 304861
' prueba2(3, 2) = 904862
' prueba2(3, 3) = -104863
' prueba2(3, 4) = 204864
04865
'prueba2(4, 0) = 704866
'prueba2(4, 1) = -104867
'prueba2(4, 2) = 604868
'prueba2(4, 3) = -104869
'prueba2(4, 4) = -104870
04871
'Establece propiedades de la DLL04872
'con los datos del problema04873
'Dijkstra1.MatrizNodos = prueba04874
'Dijkstra1.MatrizArcos = prueba204875
04876
Dijkstra1 . MatrizNodos = MatrizNodos04877
Dijkstra1 . MatrizArcos = MatrizArcos04878
04879
'Comienza el uso de la DLL04880
'indicándole el nodo seleccionado como parámetro nodo inicial04881
'y no a árbol máximo04882
Dijkstra1 . Inicio ( Nd1S , , )04883
End Sub04884
Private Sub Dijkstra1_Fin ( ByVal TextoRespuesta As String , ByVal» MatrizArcosMinimos As System . Array ) Handles Dijkstra1 . Fin
04885
'El proceso ha finalizado al parecer correctamente04886
'lee los parámetros de vuelta con la solución los muestra04887
04888
txtResultadosAlgoritmo = ""04889
txtResultadosAlgoritmo = TextoRespuesta04890
AlgoritmoMILP = False04891
04892
CopiaGrafoPrevio ()04893
04894
'Dibuja la solución y construye texto04895
'------------------------------------04896
Dim i , j As Integer04897
Dim arc As Integer04898
04899
For arc = 0 To TotalArcos - 104900
Arcos ( arc ) . Col = Color . Black04901
Arcos ( arc ) . Grosor = Grafico . TrazoArco04902
Next arc04903
'para mostrar el detalle de los arcos04904
Grafico . BArco = False04905
04906
For i = 0 To UBound ( MatrizArcosMinimos , 1 )04907
For j = 0 To UBound ( MatrizArcosMinimos , 2 )04908
If MatrizArcosMinimos ( i , j ) = 1 Then04909
For arc = 0 To TotalArcos - 104910
If Arcos ( arc ) . Nd1 = i And Arcos ( arc ) . Nd2 = j Then04911
Arcos ( arc ) . Col = Color . Green04912
Arcos ( arc ) . Grosor = Grafico . TrazoArco + 104913
Exit For04914
End If04915
Next arc04916
End If04917
Next j04918
Next i04919
04920
DibujaGrafo ()04921
'------------------------------------04922
CopiaGrafoSolucion ()04923
MuestraCajaSolucion ()04924
End Sub04925
Private Sub mnuAnalisis_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuAnalisis . Click
04926
04927
End Sub04928
Private Sub mnuAnalisisDijkstraMax_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuAnalisisDijkstraMax . Click
04929
If Nd1S = - 1 Then04930
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Árbol máximo) debe» seleccionar" & vbCrLf & "un nodo con el botón izquierdo del
» ratón." , MsgBoxStyle . Information , "Algoritmo de Dijkstra" )
04931
Exit Sub04932
End If04933
04934
If Grafico . costArco = False Then04935
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Árbol máximo) debe» activar la opción Coste" & vbCrLf & "de los arcos del grafo en el
» menú Formato/Opciones/Arcos." , MsgBoxStyle . Information ,
» "Algoritmo de Dijkstra" )
04936
Exit Sub04937
End If04938
04939
'----------------------------------------------------04940
'A la dll se le debe pasar un array de strings04941
'de dimensión totalnodos-1 ya que empieza en 004942
'con el nombre o etiqueta de los nodos04943
'----------------------------------------------------04944
04945
Dim i , j As Long04946
Dim MatrizNodos ( TotalNodos - 1 ) As String04947
For i = 0 To TotalNodos - 104948
MatrizNodos ( i ) = Nodos ( i ) . Texto04949
Next i04950
04951
'----------------------------------------------------04952
'a la dll se le debe pasar las relaciones de arco en04953
'matriz(i,j) donde i=nodo origen, j=nodo destino04954
'de dimensiones de 0 a totalnodos-1 para i y para j04955
'contendrá un single >=004956
'recuerda que después del proceso RellenaMatrices04957
'se dispone de un array de relación de arco que es04958
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)04959
'----------------------------------------------------04960
04961
'si no existe relación marcar como -104962
04963
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single04964
'pone toda la matriz a -104965
For i = 0 To TotalNodos - 104966
For j = 0 To TotalNodos - 104967
MatrizArcos ( i , j ) = - 104968
Next j04969
Next i04970
'marca los arcos existentes, pero no los de un mismo nodo04971
For i = 0 To TotalArcos - 104972
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then04973
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = - 104974
Else04975
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste04976
End If04977
Next i04978
04979
'Establece propiedades de la DLL04980
'con los datos del problema04981
Dijkstra1 . MatrizNodos = MatrizNodos04982
Dijkstra1 . MatrizArcos = MatrizArcos04983
04984
'Comienza el uso de la DLL04985
'indicándole el nodo seleccionado como parámetro nodo inicial04986
'y sí a árbol máximo04987
Dijkstra1 . Inicio ( Nd1S , , True )04988
End Sub04989
Private Sub mnuAnalisisDijkstraCC_Click ( ByVal sender As System . Object , ByVal» e As System . EventArgs ) Handles mnuAnalisisDijkstraCC . Click
04990
If Nd1S = - 1 Then04991
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Camino crítico -» máximo) debe seleccionar" & vbCrLf & "un nodo inicio con el botón
» izquierdo del ratón." , MsgBoxStyle . Information , "Algoritmo de
» Dijkstra" )
04992
Exit Sub04993
End If04994
If Nd2S = - 1 Then04995
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Camino crítico -» máximo) debe seleccionar" & vbCrLf & "un nodo fin con el botón
» derecho del ratón." , MsgBoxStyle . Information , "Algoritmo de
» Dijkstra" )
04996
Exit Sub04997
End If04998
If Grafico . costArco = False Then04999
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Camino crítico -» máximo) debe activar la opción Coste" & vbCrLf & "de los arcos
» del grafo en el menú Formato/Opciones/Arcos." , MsgBoxStyle .
» Information , "Algoritmo de Dijkstra" )
05000
Exit Sub05001
End If05002
05003
'----------------------------------------------------05004
'A la dll se le debe pasar un array de strings05005
'de dimensión totalnodos-1 ya que empieza en 005006
'con el nombre o etiqueta de los nodos05007
'----------------------------------------------------05008
05009
Dim i , j As Long05010
Dim MatrizNodos ( TotalNodos - 1 ) As String05011
For i = 0 To TotalNodos - 105012
MatrizNodos ( i ) = Nodos ( i ) . Texto05013
Next i05014
05015
'----------------------------------------------------05016
'a la dll se le debe pasar las relaciones de arco en05017
'matriz(i,j) donde i=nodo origen, j=nodo destino05018
'de dimensiones de 0 a totalnodos-1 para i y para j05019
'contendrá un single >=005020
'recuerda que después del proceso RellenaMatrices05021
'se dispone de un array de relación de arco que es05022
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)05023
'----------------------------------------------------05024
05025
'si no existe relación marcar como -105026
05027
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single05028
'pone toda la matriz a -105029
For i = 0 To TotalNodos - 105030
For j = 0 To TotalNodos - 105031
MatrizArcos ( i , j ) = - 105032
Next j05033
Next i05034
'marca los arcos existentes, pero no los de un mismo nodo05035
For i = 0 To TotalArcos - 105036
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then05037
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = - 105038
Else05039
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste05040
End If05041
Next i05042
05043
'Establece propiedades de la DLL05044
'con los datos del problema05045
Dijkstra1 . MatrizNodos = MatrizNodos05046
Dijkstra1 . MatrizArcos = MatrizArcos05047
05048
'Comienza el uso de la DLL05049
'indicándole el nodo seleccionado como parámetro nodo inicial05050
'nodo final y sí a camino crítico05051
Dijkstra1 . Inicio ( Nd1S , Nd2S , True )05052
05053
End Sub05054
Private Sub mnuAnalisisDijkstraCM_Click ( ByVal sender As System . Object , ByVal» e As System . EventArgs ) Handles mnuAnalisisDijkstraCM . Click
05055
If Nd1S = - 1 Then05056
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Camino mínimo) debe» seleccionar" & vbCrLf & "un nodo inicio con el botón izquierdo
» del ratón." , MsgBoxStyle . Information , "Algoritmo de Dijkstra" )
05057
Exit Sub05058
End If05059
If Nd2S = - 1 Then05060
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Camino mínimo) debe» seleccionar" & vbCrLf & "un nodo fin con el botón derecho del
» ratón." , MsgBoxStyle . Information , "Algoritmo de Dijkstra" )
05061
Exit Sub05062
End If05063
If Grafico . costArco = False Then05064
MsgBox ( "Para ejecutar el Algoritmo de Dijkstra (Camino mínimo) debe» activar la opción Coste" & vbCrLf & "de los arcos del grafo en el
» menú Formato/Opciones/Arcos." , MsgBoxStyle . Information ,
» "Algoritmo de Dijkstra" )
05065
Exit Sub05066
End If05067
05068
'----------------------------------------------------05069
'A la dll se le debe pasar un array de strings05070
'de dimensión totalnodos-1 ya que empieza en 005071
'con el nombre o etiqueta de los nodos05072
'----------------------------------------------------05073
05074
Dim i , j As Long05075
Dim MatrizNodos ( TotalNodos - 1 ) As String05076
For i = 0 To TotalNodos - 105077
MatrizNodos ( i ) = Nodos ( i ) . Texto05078
Next i05079
05080
05081
'----------------------------------------------------05082
'a la dll se le debe pasar las relaciones de arco en05083
'matriz(i,j) donde i=nodo origen, j=nodo destino05084
'de dimensiones de 0 a totalnodos-1 para i y para j05085
'contendrá un single >=005086
'recuerda que después del proceso RellenaMatrices05087
'se dispone de un array de relación de arco que es05088
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)05089
'----------------------------------------------------05090
05091
'si no existe relación marcar como -105092
05093
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single05094
'pone toda la matriz a -105095
For i = 0 To TotalNodos - 105096
For j = 0 To TotalNodos - 105097
MatrizArcos ( i , j ) = - 105098
Next j05099
Next i05100
'marca los arcos existentes, pero no los de un mismo nodo05101
For i = 0 To TotalArcos - 105102
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then05103
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = - 105104
Else05105
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste05106
End If05107
Next i05108
05109
'Establece propiedades de la DLL05110
'con los datos del problema05111
Dijkstra1 . MatrizNodos = MatrizNodos05112
Dijkstra1 . MatrizArcos = MatrizArcos05113
05114
'Comienza el uso de la DLL05115
'indicándole el nodo seleccionado como parámetro05116
'nodo inicial,nodo final y no a camino crítico05117
Dijkstra1 . Inicio ( Nd1S , Nd2S , False )05118
End Sub05119
Private Sub mnuAnalisisBellmanFordCmin_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuAnalisisBellmanFordCmin . Click
05120
05121
If Nd1S = - 1 Then05122
MsgBox ( "Para ejecutar el Algoritmo de BellmanFord (camino mínimo)» debe seleccionar" & vbCrLf & "un nodo inicial con el botón
» izquierdo del ratón." , MsgBoxStyle . Information , "Algoritmo de
» BellmanFord" )
05123
Exit Sub05124
End If05125
05126
If Nd2S = - 1 Then05127
MsgBox ( "Para ejecutar el Algoritmo de BellmanFord (camino mínimo)» debe seleccionar" & vbCrLf & "un nodo final con el botón derecho
» del ratón." , MsgBoxStyle . Information , "Algoritmo de BellmanFord" )
05128
Exit Sub05129
End If05130
05131
If Grafico . costArco = False Then05132
MsgBox ( "Para ejecutar el Algoritmo de BellmanFord (camino mínimo)» debe activar la opción Coste" & vbCrLf & "de los arcos del grafo
» en el menú Formato/Opciones/Arcos." , MsgBoxStyle . Information ,
» "Algoritmo de BellmanFord" )
05133
Exit Sub05134
End If05135
05136
'----------------------------------------------------05137
'A la dll se le debe pasar un array de strings05138
'de dimensión totalnodos-1 ya que empieza en 005139
'con el nombre o etiqueta de los nodos05140
'----------------------------------------------------05141
Dim i , j As Long05142
Dim MatrizNodos ( TotalNodos - 1 ) As String05143
For i = 0 To TotalNodos - 105144
MatrizNodos ( i ) = Nodos ( i ) . Texto05145
Next i05146
05147
'----------------------------------------------------05148
'a la dll se le debe pasar las relaciones de arco en05149
'matriz(i,j) donde i=nodo origen, j=nodo destino05150
'de dimensiones de 0 a totalnodos-1 para i y para j05151
'contendrá un single >=005152
'recuerda que después del proceso RellenaMatrices05153
'se dispone de un array de relación de arco que es05154
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)05155
'----------------------------------------------------05156
Const cMaximo As Single = 99999999999999999905157
Const cMinimo As Single = - 99999999999999999905158
05159
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single05160
'pone toda la matriz sin relación de arcos05161
For i = 0 To TotalNodos - 105162
For j = 0 To TotalNodos - 105163
MatrizArcos ( i , j ) = cMaximo05164
Next j05165
Next i05166
'marca los arcos existentes, pero no los de un mismo nodo05167
For i = 0 To TotalArcos - 105168
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then05169
'05170
Else05171
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste05172
End If05173
Next i05174
05175
'Establece propiedades de la DLL05176
'con los datos del problema05177
BellmanFord1 . MatrizNodos = MatrizNodos05178
BellmanFord1 . MatrizArcos = MatrizArcos05179
05180
'Comienza el uso de la DLL05181
'indicándole el nodo seleccionado como parámetro nodo inicial05182
'nodo final y no al cálculo de camino máximo05183
BellmanFord1 . Inicio ( Nd1S , Nd2S , )05184
05185
End Sub05186
Private Sub BellmanFord1_Fallo ( ByVal TextoError As String ) Handles» BellmanFord1 . Fallo
05187
'Este evento salta en caso de un error en el proceso de BellmanFord05188
MsgBox ( TextoError , MsgBoxStyle . Exclamation , "Error en el proceso» BellmanFord" )
05189
End Sub05190
Private Sub BellmanFord1_Fin ( ByVal TextoRespuesta As String , ByVal» MatrizArcosMinimos As System . Array ) Handles BellmanFord1 . Fin
05191
05192
'El proceso ha finalizado al parecer correctamente05193
'lee los parámetros de vuelta con la solución los muestra05194
txtResultadosAlgoritmo = ""05195
txtResultadosAlgoritmo = TextoRespuesta05196
AlgoritmoMILP = False05197
05198
CopiaGrafoPrevio ()05199
05200
05201
'Dibuja la solución05202
'------------------------------------05203
Dim i , j As Integer05204
Dim arc As Integer05205
05206
For arc = 0 To TotalArcos - 105207
Arcos ( arc ) . Col = Color . Black05208
Arcos ( arc ) . Grosor = Grafico . TrazoArco05209
Next arc05210
'para mostrar el detalle de los arcos05211
Grafico . BArco = False05212
05213
For i = 0 To UBound ( MatrizArcosMinimos , 1 )05214
For j = 0 To UBound ( MatrizArcosMinimos , 2 )05215
If MatrizArcosMinimos ( i , j ) = 1 Then05216
For arc = 0 To TotalArcos - 105217
If Arcos ( arc ) . Nd1 = i And Arcos ( arc ) . Nd2 = j Then05218
Arcos ( arc ) . Col = Color . Green05219
Arcos ( arc ) . Grosor = Grafico . TrazoArco + 105220
Exit For05221
End If05222
Next arc05223
End If05224
Next j05225
Next i05226
05227
DibujaGrafo ()05228
'------------------------------------05229
05230
CopiaGrafoSolucion ()05231
MuestraCajaSolucion ()05232
End Sub05233
05234
Public Sub CopiaGrafoSolucion ()05235
'hace copia del estado posterior del grafo05236
ReDim NodosSol ( TotalNodos - 1 )05237
ReDim ArcosSol ( TotalArcos - 1 )05238
05239
Dim i , j As Long05240
For i = 0 To TotalNodos - 105241
NodosSol ( i ) = Nodos ( i )05242
Next i05243
For j = 0 To TotalArcos - 105244
ArcosSol ( j ) = Arcos ( j )05245
Next j05246
End Sub05247
Public Sub CopiaGrafoPrevio ()05248
'hace copia del estado posterior del grafo05249
ReDim NodosPrev ( TotalNodos - 1 )05250
ReDim ArcosPrev ( TotalArcos - 1 )05251
05252
Dim i , j As Long05253
For i = 0 To TotalNodos - 105254
NodosPrev ( i ) = Nodos ( i )05255
Next i05256
For j = 0 To TotalArcos - 105257
ArcosPrev ( j ) = Arcos ( j )05258
Next j05259
End Sub05260
05261
Private Sub mnuAnalisisBellmanFordCmax_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuAnalisisBellmanFordCmax . Click
05262
05263
If Nd1S = - 1 Then05264
MsgBox ( "Para ejecutar el Algoritmo de BellmanFord (camino máximo)» debe seleccionar" & vbCrLf & "un nodo inicial con el botón
» izquierdo del ratón." , MsgBoxStyle . Information , "Algoritmo de
» BellmanFord" )
05265
Exit Sub05266
End If05267
05268
If Nd2S = - 1 Then05269
MsgBox ( "Para ejecutar el Algoritmo de BellmanFord (camino máximo)» debe seleccionar" & vbCrLf & "un nodo final con el botón derecho
» del ratón." , MsgBoxStyle . Information , "Algoritmo de BellmanFord" )
05270
Exit Sub05271
End If05272
05273
If Grafico . costArco = False Then05274
MsgBox ( "Para ejecutar el Algoritmo de BellmanFord (camino máximo)» debe activar la opción Coste" & vbCrLf & "de los arcos del grafo
» en el menú Formato/Opciones/Arcos." , MsgBoxStyle . Information ,
» "Algoritmo de BellmanFord" )
05275
Exit Sub05276
End If05277
05278
'----------------------------------------------------05279
'A la dll se le debe pasar un array de strings05280
'de dimensión totalnodos-1 ya que empieza en 005281
'con el nombre o etiqueta de los nodos05282
'----------------------------------------------------05283
Dim i , j As Long05284
Dim MatrizNodos ( TotalNodos - 1 ) As String05285
For i = 0 To TotalNodos - 105286
MatrizNodos ( i ) = Nodos ( i ) . Texto05287
Next i05288
05289
'----------------------------------------------------05290
'a la dll se le debe pasar las relaciones de arco en05291
'matriz(i,j) donde i=nodo origen, j=nodo destino05292
'de dimensiones de 0 a totalnodos-1 para i y para j05293
'contendrá un single >=005294
'recuerda que después del proceso RellenaMatrices05295
'se dispone de un array de relación de arco que es05296
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)05297
'----------------------------------------------------05298
Const cMaximo As Single = 99999999999999999905299
Const cMinimo As Single = - 99999999999999999905300
05301
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single05302
'pone toda la matriz sin relación de arcos05303
For i = 0 To TotalNodos - 105304
For j = 0 To TotalNodos - 105305
MatrizArcos ( i , j ) = cMinimo05306
Next j05307
Next i05308
'marca los arcos existentes, pero no los de un mismo nodo05309
For i = 0 To TotalArcos - 105310
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then05311
'05312
Else05313
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste05314
End If05315
Next i05316
05317
'Establece propiedades de la DLL05318
'con los datos del problema05319
BellmanFord1 . MatrizNodos = MatrizNodos05320
BellmanFord1 . MatrizArcos = MatrizArcos05321
05322
'Comienza el uso de la DLL05323
'indicándole el nodo seleccionado como parámetro nodo inicial05324
'nodo final y si al cálculo de camino máximo05325
BellmanFord1 . Inicio ( Nd1S , Nd2S , True )05326
End Sub05327
Private Sub Kruskal1_Fallo ( ByVal TextoError As String ) Handles Kruskal1 .» Fallo
05328
'Este evento salta en caso de un error en el proceso de Kruskal05329
MsgBox ( TextoError , MsgBoxStyle . Exclamation , "Error en el proceso» Kruskal" )
05330
End Sub05331
Private Sub mnuAnalisisKruskalmin_Click ( ByVal sender As System . Object , ByVal» e As System . EventArgs ) Handles mnuAnalisisKruskalmin . Click
05332
05333
If Grafico . costArco = False Then05334
MsgBox ( "Para ejecutar el Algoritmo de Kruskal (árbol de coste total» mínimo) debe activar la opción Coste" & vbCrLf & "de los arcos
» del grafo en el menú Formato/Opciones/Arcos." , MsgBoxStyle .
» Information , "Algoritmo de Kruskal" )
05335
Exit Sub05336
End If05337
05338
'----------------------------------------------------05339
'A la dll se le debe pasar un array de strings05340
'de dimensión totalnodos-1 ya que empieza en 005341
'con el nombre o etiqueta de los nodos05342
'----------------------------------------------------05343
Dim i , j As Long05344
Dim MatrizNodos ( TotalNodos - 1 ) As String05345
For i = 0 To TotalNodos - 105346
MatrizNodos ( i ) = Nodos ( i ) . Texto05347
Next i05348
05349
'----------------------------------------------------05350
'a la dll se le debe pasar las relaciones de arco en05351
'matriz(i,j) donde i=nodo origen, j=nodo destino05352
'de dimensiones de 0 a totalnodos-1 para i y para j05353
'contendrá un single >=005354
'recuerda que después del proceso RellenaMatrices05355
'se dispone de un array de relación de arco que es05356
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)05357
'----------------------------------------------------05358
Const cMaximo As Single = 99999999999999999905359
Const cMinimo As Single = - 99999999999999999905360
05361
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single05362
'pone toda la matriz sin relación de arcos05363
For i = 0 To TotalNodos - 105364
For j = 0 To TotalNodos - 105365
MatrizArcos ( i , j ) = cMaximo05366
Next j05367
Next i05368
'marca los arcos existentes, pero no los de un mismo nodo05369
For i = 0 To TotalArcos - 105370
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then05371
'05372
Else05373
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste05374
End If05375
Next i05376
05377
'Establece propiedades de la DLL05378
'con los datos del problema05379
Kruskal1 . MatrizNodos = MatrizNodos05380
Kruskal1 . MatrizArcos = MatrizArcos05381
05382
'Comienza el uso de la DLL05383
'busca el mínimo05384
Kruskal1 . Inicio ( False )05385
05386
05387
End Sub05388
Private Sub Kruskal1_Fin ( ByVal TextoRespuesta As String , ByVal» MatrizArcosMinimos As System . Array ) Handles Kruskal1 . Fin
05389
'El proceso ha finalizado al parecer correctamente05390
'lee los parámetros de vuelta con la solución los muestra05391
05392
txtResultadosAlgoritmo = ""05393
txtResultadosAlgoritmo = TextoRespuesta05394
AlgoritmoMILP = False05395
05396
CopiaGrafoPrevio ()05397
05398
'Dibuja la solución y construye texto05399
'------------------------------------05400
Dim i , j , k As Integer05401
Dim arc As Integer05402
05403
For arc = 0 To TotalArcos - 105404
Arcos ( arc ) . Col = Color . Black05405
Arcos ( arc ) . Grosor = Grafico . TrazoArco05406
Next arc05407
'para mostrar el detalle de los arcos05408
Grafico . BArco = True05409
05410
For i = 0 To UBound ( MatrizArcosMinimos , 1 )05411
For j = 0 To UBound ( MatrizArcosMinimos , 2 )05412
If MatrizArcosMinimos ( i , j ) = 1 Then05413
For arc = 0 To TotalArcos - 105414
If Arcos ( arc ) . Nd1 = i And Arcos ( arc ) . Nd2 = j Then05415
Arcos ( arc ) . Col = Color . Green05416
Arcos ( arc ) . Grosor = Grafico . TrazoArco + 105417
05418
05419
k = BuscaArcoSimetrico ( arc )05420
If k > 0 Then05421
Arcos ( k ) . Col = Color . Green05422
Arcos ( k ) . Grosor = Grafico . TrazoArco + 105423
End If05424
05425
Exit For05426
End If05427
Next arc05428
End If05429
Next j05430
Next i05431
05432
DibujaGrafo ()05433
'------------------------------------05434
05435
CopiaGrafoSolucion ()05436
MuestraCajaSolucion ()05437
05438
End Sub05439
Private Sub mnuAnalisisKruskalmax_Click ( ByVal sender As System . Object , ByVal» e As System . EventArgs ) Handles mnuAnalisisKruskalmax . Click
05440
05441
If Grafico . costArco = False Then05442
MsgBox ( "Para ejecutar el Algoritmo de Kruskal (árbol de coste total» máximo) debe activar la opción Coste" & vbCrLf & "de los arcos
» del grafo en el menú Formato/Opciones/Arcos." , MsgBoxStyle .
» Information , "Algoritmo de Kruskal" )
05443
Exit Sub05444
End If05445
05446
'----------------------------------------------------05447
'A la dll se le debe pasar un array de strings05448
'de dimensión totalnodos-1 ya que empieza en 005449
'con el nombre o etiqueta de los nodos05450
'----------------------------------------------------05451
Dim i , j As Long05452
Dim MatrizNodos ( TotalNodos - 1 ) As String05453
For i = 0 To TotalNodos - 105454
MatrizNodos ( i ) = Nodos ( i ) . Texto05455
Next i05456
05457
'----------------------------------------------------05458
'a la dll se le debe pasar las relaciones de arco en05459
'matriz(i,j) donde i=nodo origen, j=nodo destino05460
'de dimensiones de 0 a totalnodos-1 para i y para j05461
'contendrá un single >=005462
'recuerda que después del proceso RellenaMatrices05463
'se dispone de un array de relación de arco que es05464
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)05465
'----------------------------------------------------05466
Const cMaximo As Single = 99999999999999999905467
Const cMinimo As Single = - 99999999999999999905468
05469
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single05470
'pone toda la matriz sin relación de arcos05471
For i = 0 To TotalNodos - 105472
For j = 0 To TotalNodos - 105473
MatrizArcos ( i , j ) = cMaximo05474
Next j05475
Next i05476
'marca los arcos existentes, pero no los de un mismo nodo05477
For i = 0 To TotalArcos - 105478
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then05479
'05480
Else05481
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste05482
End If05483
Next i05484
05485
'Establece propiedades de la DLL05486
'con los datos del problema05487
Kruskal1 . MatrizNodos = MatrizNodos05488
Kruskal1 . MatrizArcos = MatrizArcos05489
05490
'Comienza el uso de la DLL05491
'busca el mínimo05492
Kruskal1 . Inicio ( True )05493
End Sub05494
Private Sub mnuFormatoFlujo_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuFormatoFlujo . Click
05495
'ordena el grafo en formato flujo05496
05497
mnuFormatoAleatorio . Checked = False05498
mnuFormatoTablero . Checked = False05499
mnuFormatoCircular . Checked = False05500
mnuFormatoFlujo . Checked = True05501
mnuFormatoOrganico . Checked = False05502
05503
If TotalNodos = 0 Then Exit Sub05504
05505
'pide antes confirmación05506
Dim respuesta As MsgBoxResult05507
respuesta = MsgBox ( "Esta opción cambiará la ubicación de los nodos en» forma de flujo." & vbCrLf & "¿Desea realmente reordenar los nodos?" ,
» MsgBoxStyle . OKCancel , )
05508
If respuesta = MsgBoxResult . Cancel Then Exit Sub05509
05510
Me . Cursor = Cursors . WaitCursor05511
OrdenaenFlujo ()05512
If Grafico . Iman Then Imantar ()05513
DibujaGrafo ()05514
Me . Cursor = Cursors . Default05515
End Sub05516
Sub OrdenaenFlujo ()05517
'Esta rutina intenta ordenar la posición de los nodos de modo que el05518
'nodo con más arcos salientes quede a la izqda de la pantalla, mientras05519
'que el nodo con más arcos entrantes, quede a la derecha.05520
05521
'si no hay suficientes nodos va a otra ordenación05522
05523
If TotalNodos < 3 Or TotalArcos < 1 Then05524
OrdenaenEstrella ()05525
Exit Sub05526
End If05527
05528
Dim VArcos ( TotalNodos - 1 ) As Integer05529
Dim i , j As Integer05530
Dim n1 , n2 As Integer05531
05532
Dim MArcos ( TotalArcos - 1 ) As Boolean05533
Dim MNodos ( TotalNodos - 1 ) As Boolean05534
Dim explorados , capas As Long05535
Dim CNodos ( TotalNodos - 1 ) As Integer05536
Dim TotalCapa ( TotalArcos + 1 ) As Long05537
05538
'valora todos los nodos según arcos entrantes y salientes05539
For i = 0 To TotalArcos - 105540
n1 = Arcos ( i ) . Nd105541
n2 = Arcos ( i ) . Nd205542
'el positivo es el saliente05543
VArcos ( n1 ) = VArcos ( n1 ) + 10005544
'el negativo es el entrante05545
VArcos ( n2 ) = VArcos ( n2 ) - 5005546
05547
Next i05548
05549
Dim Col As Integer05550
05551
05552
'Ordena los nodos y busca el de más arcos salientes (max)05553
Dim Nmax As Integer05554
Dim VAmax As Long05555
05556
VAmax = - 99999999999999999905557
Nmax = - 105558
05559
'cuenta nodos con arcos susceptibles de ser ordenados en capas05560
Dim TotNodosconArco As Long = 005561
05562
For j = 0 To TotalArcos - 105563
n1 = Arcos ( j ) . Nd105564
n2 = Arcos ( j ) . Nd205565
05566
If MNodos ( n1 ) = False Then05567
MNodos ( n1 ) = True05568
TotNodosconArco = TotNodosconArco + 105569
End If05570
If MNodos ( n2 ) = False Then05571
MNodos ( n2 ) = True05572
TotNodosconArco = TotNodosconArco + 105573
End If05574
Next j05575
05576
For i = 0 To TotalNodos - 105577
If VArcos ( i ) > VAmax Then05578
Nmax = i05579
VAmax = VArcos ( i )05580
End If05581
MNodos ( i ) = False05582
Next i05583
05584
explorados = 105585
capas = 105586
TotalCapa ( capas ) = 105587
CNodos ( Nmax ) = capas05588
MNodos ( Nmax ) = True05589
Dim alguno As Long05590
05591
Do While ( explorados < TotNodosconArco )05592
alguno = 005593
For i = 0 To TotalArcos - 105594
n1 = Arcos ( i ) . Nd105595
n2 = Arcos ( i ) . Nd205596
If MArcos ( i ) = False Then05597
If CNodos ( n1 ) = capas Then05598
05599
If CNodos ( n2 ) = 0 Then05600
CNodos ( n2 ) = capas + 105601
MNodos ( n2 ) = True05602
05603
TotalCapa ( capas + 1 ) = TotalCapa ( capas + 1 ) + 105604
explorados = explorados + 105605
MArcos ( i ) = True05606
alguno = 105607
End If05608
End If05609
End If05610
Next i05611
If alguno = 0 Then Exit Do05612
capas = capas + 105613
Loop05614
05615
'ahora opera con los nodos que no tienen arco05616
'los que no tienen arcos al final05617
For i = 0 To TotalNodos - 105618
If MNodos ( i ) = False Then05619
CNodos ( i ) = capas05620
MNodos ( i ) = True05621
TotalCapa ( capas ) = TotalCapa ( capas ) + 105622
End If05623
Next i05624
05625
'Recorre la estructura de capas y determina sus coordenadas05626
Dim c As Long05627
Dim NodosEnCapa As Long05628
Dim cx , cy As Single05629
05630
cx = Grafico . TapizX / capas05631
05632
For c = 1 To capas05633
NodosEnCapa = 005634
05635
If TotalCapa ( c ) > 0 Then05636
cy = Grafico . TapizY / ( TotalCapa ( c ))05637
05638
For i = 0 To TotalNodos - 105639
If CNodos ( i ) = c Then05640
Nodos ( i ) . X = cx / 2 + cx * ( c - 1 )05641
Nodos ( i ) . Y = cy / 2 + cy * ( NodosEnCapa )05642
NodosEnCapa = NodosEnCapa + 105643
End If05644
Next i05645
End If05646
Next c05647
End Sub05648
Private Sub mnuAnalisisPrimMin_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuAnalisisPrimMin . Click
05649
If Grafico . costArco = False Then05650
MsgBox ( "Para ejecutar el Algoritmo de Prim (árbol de coste total» mínimo) debe activar la opción Coste" & vbCrLf & "de los arcos
» del grafo en el menú Formato/Opciones/Arcos." , MsgBoxStyle .
» Information , "Algoritmo de Prim" )
05651
Exit Sub05652
End If05653
05654
'----------------------------------------------------05655
'A la dll se le debe pasar un array de strings05656
'de dimensión totalnodos-1 ya que empieza en 005657
'con el nombre o etiqueta de los nodos05658
'----------------------------------------------------05659
Dim i , j As Long05660
Dim MatrizNodos ( TotalNodos - 1 ) As String05661
For i = 0 To TotalNodos - 105662
MatrizNodos ( i ) = Nodos ( i ) . Texto05663
Next i05664
05665
'----------------------------------------------------05666
'a la dll se le debe pasar las relaciones de arco en05667
'matriz(i,j) donde i=nodo origen, j=nodo destino05668
'de dimensiones de 0 a totalnodos-1 para i y para j05669
'contendrá un single >=005670
'recuerda que después del proceso RellenaMatrices05671
'se dispone de un array de relación de arco que es05672
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)05673
'----------------------------------------------------05674
Const cMaximo As Single = 99999999999999999905675
Const cMinimo As Single = - 99999999999999999905676
05677
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single05678
'pone toda la matriz sin relación de arcos05679
For i = 0 To TotalNodos - 105680
For j = 0 To TotalNodos - 105681
MatrizArcos ( i , j ) = cMaximo05682
Next j05683
Next i05684
'marca los arcos existentes, pero no los de un mismo nodo05685
For i = 0 To TotalArcos - 105686
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then05687
'05688
Else05689
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste05690
End If05691
Next i05692
05693
'Establece propiedades de la DLL05694
'con los datos del problema05695
Prim1 . MatrizNodos = MatrizNodos05696
Prim1 . MatrizArcos = MatrizArcos05697
05698
'Comienza el uso de la DLL05699
'busca el mínimo05700
Prim1 . Inicio ( False )05701
End Sub05702
Private Sub Prim1_Fallo ( ByVal TextoError As String ) Handles Prim1 . Fallo05703
'Este evento salta en caso de un error en el proceso de Prim05704
MsgBox ( TextoError , MsgBoxStyle . Exclamation , "Error en el proceso Prim" )05705
End Sub05706
Private Sub Prim1_Fin ( ByVal TextoRespuesta As String , ByVal» MatrizArcosMinimos As System . Array ) Handles Prim1 . Fin
05707
'El proceso ha finalizado al parecer correctamente05708
'lee los parámetros de vuelta con la solución los muestra05709
05710
txtResultadosAlgoritmo = ""05711
txtResultadosAlgoritmo = TextoRespuesta05712
AlgoritmoMILP = False05713
05714
CopiaGrafoPrevio ()05715
05716
05717
'Dibuja la solución y construye texto05718
'------------------------------------05719
Dim i , j , k As Integer05720
Dim arc As Integer05721
05722
For arc = 0 To TotalArcos - 105723
Arcos ( arc ) . Col = Color . Black05724
Arcos ( arc ) . Grosor = Grafico . TrazoArco05725
Next arc05726
'para mostrar el detalle de los arcos05727
Grafico . BArco = True05728
05729
For i = 0 To UBound ( MatrizArcosMinimos , 1 )05730
For j = 0 To UBound ( MatrizArcosMinimos , 2 )05731
If MatrizArcosMinimos ( i , j ) = 1 Then05732
For arc = 0 To TotalArcos - 105733
If Arcos ( arc ) . Nd1 = i And Arcos ( arc ) . Nd2 = j Then05734
Arcos ( arc ) . Col = Color . Green05735
Arcos ( arc ) . Grosor = Grafico . TrazoArco + 105736
05737
05738
k = BuscaArcoSimetrico ( arc )05739
If k > 0 Then05740
Arcos ( k ) . Col = Color . Green05741
Arcos ( k ) . Grosor = Grafico . TrazoArco + 105742
End If05743
05744
Exit For05745
End If05746
Next arc05747
End If05748
Next j05749
Next i05750
05751
DibujaGrafo ()05752
'------------------------------------05753
05754
CopiaGrafoSolucion ()05755
MuestraCajaSolucion ()05756
05757
End Sub05758
Private Sub mnuAnalisisPrimMax_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuAnalisisPrimMax . Click
05759
If Grafico . costArco = False Then05760
MsgBox ( "Para ejecutar el Algoritmo de Prim (árbol de coste total» máximo) debe activar la opción Coste" & vbCrLf & "de los arcos
» del grafo en el menú Formato/Opciones/Arcos." , MsgBoxStyle .
» Information , "Algoritmo de Prim" )
05761
Exit Sub05762
End If05763
05764
'----------------------------------------------------05765
'A la dll se le debe pasar un array de strings05766
'de dimensión totalnodos-1 ya que empieza en 005767
'con el nombre o etiqueta de los nodos05768
'----------------------------------------------------05769
Dim i , j As Long05770
Dim MatrizNodos ( TotalNodos - 1 ) As String05771
For i = 0 To TotalNodos - 105772
MatrizNodos ( i ) = Nodos ( i ) . Texto05773
Next i05774
05775
'----------------------------------------------------05776
'a la dll se le debe pasar las relaciones de arco en05777
'matriz(i,j) donde i=nodo origen, j=nodo destino05778
'de dimensiones de 0 a totalnodos-1 para i y para j05779
'contendrá un single >=005780
'recuerda que después del proceso RellenaMatrices05781
'se dispone de un array de relación de arco que es05782
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)05783
'----------------------------------------------------05784
Const cMaximo As Single = 99999999999999999905785
Const cMinimo As Single = - 99999999999999999905786
05787
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single05788
'pone toda la matriz sin relación de arcos05789
For i = 0 To TotalNodos - 105790
For j = 0 To TotalNodos - 105791
MatrizArcos ( i , j ) = cMinimo05792
Next j05793
Next i05794
'marca los arcos existentes, pero no los de un mismo nodo05795
For i = 0 To TotalArcos - 105796
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then05797
'05798
Else05799
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste05800
End If05801
Next i05802
05803
'Establece propiedades de la DLL05804
'con los datos del problema05805
Prim1 . MatrizNodos = MatrizNodos05806
Prim1 . MatrizArcos = MatrizArcos05807
05808
'Comienza el uso de la DLL05809
'busca el máximo05810
Prim1 . Inicio ( True )05811
End Sub05812
Private Sub mnuFormatoCentrar_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoCentrar . Click
05813
Me . Cursor = Cursors . WaitCursor05814
FormatoAjustar ( True , True )05815
Me . Cursor = Cursors . Default05816
End Sub05817
Private Sub mnuFormatoAjustar_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoAjustar . Click
05818
Me . Cursor = Cursors . WaitCursor05819
FormatoAjustar ( False , True )05820
Me . Cursor = Cursors . Default05821
End Sub05822
Sub FormatoAjustar ( ByVal Centrado As Boolean , ByVal Redibuja As Boolean )05823
If TotalNodos < 2 Then Exit Sub05824
05825
Dim i As Integer05826
05827
Dim Xmin , Ymin , Xmax , Ymax As Single05828
Const cMaximo As Single = 99999999999999999905829
Const cMinimo As Single = - 99999999999999999905830
05831
'busca contorno05832
05833
Xmin = cMaximo05834
Ymin = cMaximo05835
Xmax = cMinimo05836
Ymax = cMinimo05837
05838
For i = 0 To TotalNodos - 105839
If Nodos ( i ) . X - Nodos ( i ) . Radio < Xmin Then05840
Xmin = Nodos ( i ) . X - Nodos ( i ) . Radio05841
End If05842
If Nodos ( i ) . Y - Nodos ( i ) . Radio < Ymin Then05843
Ymin = Nodos ( i ) . Y - Nodos ( i ) . Radio05844
End If05845
If Nodos ( i ) . X + Nodos ( i ) . Radio > Xmax Then05846
Xmax = Nodos ( i ) . X + Nodos ( i ) . Radio05847
End If05848
If Nodos ( i ) . Y + Nodos ( i ) . Radio > Ymax Then05849
Ymax = Nodos ( i ) . Y + Nodos ( i ) . Radio05850
End If05851
Next i05852
05853
05854
Dim MargenX , MargenY As Single05855
05856
Dim Ax , Ay , Ax2 , Ay2 As Single05857
MargenX = 5005858
MargenY = 5005859
'Recorta contorno05860
Ax = Xmin - MargenX05861
Ay = Ymin - MargenY05862
05863
05864
05865
If Centrado Then05866
Ax2 = ( Grafico . TapizX - ( Xmax - Xmin + 2 * MargenX )) / 205867
Ay2 = ( Grafico . TapizY - ( Ymax - Ymin + 2 * MargenY )) / 205868
05869
Ax = Ax - Ax205870
Ay = Ay - Ay205871
End If05872
05873
'Desplaza nodos05874
For i = 0 To TotalNodos - 105875
Nodos ( i ) . X = Nodos ( i ) . X - Ax05876
Nodos ( i ) . Y = Nodos ( i ) . Y - Ay05877
Next i05878
05879
'Recorta tapiz05880
If Centrado = False Then05881
If ( Xmax - Xmin ) + 2 * MargenX >= 100 Then05882
Grafico . TapizX = ( Xmax - Xmin ) + 2 * MargenX05883
Else05884
Grafico . TapizX = 10005885
End If05886
05887
If ( Ymax - Ymin ) + 2 * MargenY >= 100 Then05888
Grafico . TapizY = ( Ymax - Ymin ) + 2 * MargenY05889
Else05890
Grafico . TapizY = 10005891
End If05892
End If05893
If Redibuja Then DibujaGrafo ()05894
05895
05896
05897
End Sub05898
Private Sub mnuAnalisisFordFulkersonMax_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuAnalisisFordFulkersonMax . Click
05899
05900
If Nd1S = - 1 Then05901
MsgBox ( "Para ejecutar el Algoritmo de FordFulkerson (flujo máximo)» debe seleccionar" & vbCrLf & "un nodo inicial con el botón
» izquierdo del ratón." , MsgBoxStyle . Information , "Algoritmo de
» FordFulkerson" )
05902
Exit Sub05903
End If05904
05905
If Nd2S = - 1 Then05906
MsgBox ( "Para ejecutar el Algoritmo de FordFulkerson (flujo máximo)» debe seleccionar" & vbCrLf & "un nodo final con el botón derecho
» del ratón." , MsgBoxStyle . Information , "Algoritmo de
» FordFulkerson" )
05907
Exit Sub05908
End If05909
05910
If Grafico . maxArco = False Then05911
MsgBox ( "Para ejecutar el Algoritmo de FordFulkerson (flujo máximo)» debe activar la opción Máximo" & vbCrLf & "de los arcos del grafo
» en el menú Formato/Opciones/Arcos." , MsgBoxStyle . Information ,
» "Algoritmo de FordFulkerson" )
05912
Exit Sub05913
End If05914
05915
'----------------------------------------------------05916
'A la dll se le debe pasar un array de strings05917
'de dimensión totalnodos-1 ya que empieza en 005918
'con el nombre o etiqueta de los nodos05919
'----------------------------------------------------05920
Dim i , j As Long05921
Dim MatrizNodos ( TotalNodos - 1 ) As String05922
For i = 0 To TotalNodos - 105923
MatrizNodos ( i ) = Nodos ( i ) . Texto05924
Next i05925
05926
'----------------------------------------------------05927
'a la dll se le debe pasar las relaciones de arco en05928
'matriz(i,j) donde i=nodo origen, j=nodo destino05929
'de dimensiones de 0 a totalnodos-1 para i y para j05930
'contendrá un single >=005931
'recuerda que después del proceso RellenaMatrices05932
'se dispone de un array de relación de arco que es05933
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)05934
'----------------------------------------------------05935
Const cMaximo As Single = 99999999999999999905936
Const cMinimo As Single = - 99999999999999999905937
05938
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single05939
'pone toda la matriz sin relación de arcos05940
For i = 0 To TotalNodos - 105941
For j = 0 To TotalNodos - 105942
MatrizArcos ( i , j ) = cMinimo05943
Next j05944
Next i05945
'marca los arcos existentes, pero no los de un mismo nodo05946
For i = 0 To TotalArcos - 105947
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then05948
'05949
Else 'le pasa el valor de flujo máximo o capacidad del arco05950
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Max05951
End If05952
Next i05953
05954
'Establece propiedades de la DLL05955
'con los datos del problema05956
FordFulkerson1 . MatrizNodos = MatrizNodos05957
FordFulkerson1 . MatrizArcos = MatrizArcos05958
05959
'Comienza el uso de la DLL05960
'indicándole el nodo seleccionado como parámetro nodo inicial05961
'nodo final y si al cálculo de flujo máximo05962
FordFulkerson1 . Inicio ( Nd1S , Nd2S , True )05963
End Sub05964
Private Sub FordFulkerson1_Fallo ( ByVal TextoError As String ) Handles» FordFulkerson1 . Fallo
05965
'Este evento salta en caso de un error en el proceso de FordFulkerson05966
MsgBox ( TextoError , MsgBoxStyle . Exclamation , "Error en el proceso» FordFulkerson" )
05967
End Sub05968
Private Sub FordFulkerson1_Fin ( ByVal TextoRespuesta As String , ByVal» MatrizArcosMinimos As System . Array ) Handles FordFulkerson1 . Fin
05969
'El proceso ha finalizado al parecer correctamente05970
'lee los parámetros de vuelta con la solución los muestra05971
05972
txtResultadosAlgoritmo = ""05973
txtResultadosAlgoritmo = TextoRespuesta05974
AlgoritmoMILP = False05975
05976
CopiaGrafoPrevio ()05977
05978
'Dibuja la solución y construye texto05979
'------------------------------------05980
Dim i , j As Integer05981
Dim arc As Integer05982
05983
For arc = 0 To TotalArcos - 105984
Arcos ( arc ) . Col = Color . Black05985
Arcos ( arc ) . Grosor = Grafico . TrazoArco05986
Next arc05987
'para mostrar el detalle de los arcos05988
Grafico . BArco = False05989
Grafico . minArco = True05990
Grafico . costArco = False05991
05992
For i = 0 To UBound ( MatrizArcosMinimos , 1 )05993
For j = 0 To UBound ( MatrizArcosMinimos , 2 )05994
'If MatrizArcosMinimos(i, j) = 1 Then05995
For arc = 0 To TotalArcos - 105996
If Arcos ( arc ) . Nd1 = i And Arcos ( arc ) . Nd2 = j Then05997
05998
Arcos ( arc ) . Min = MatrizArcosMinimos ( i , j )05999
'un trazo claro para arcos con flujo y capacidad» residual
06000
If Arcos ( arc ) . Min > 0 Then06001
Arcos ( arc ) . Col = Color . LightGreen06002
Arcos ( arc ) . Grosor = Grafico . TrazoArco + 106003
End If06004
'un trazo oscuro para arcos con flujo y sin capacidad» residual
06005
If Arcos ( arc ) . Min = Arcos ( arc ) . Max Then06006
Arcos ( arc ) . Col = Color . Green06007
End If06008
06009
Exit For06010
End If06011
Next arc06012
'End If06013
Next j06014
Next i06015
06016
DibujaGrafo ()06017
'------------------------------------06018
06019
CopiaGrafoSolucion ()06020
MuestraCajaSolucion ()06021
End Sub06022
Private Sub mnuAnalisisFloydWarshallmin_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuAnalisisFloydWarshallmin . Click
06023
06024
If Grafico . costArco = False Then06025
MsgBox ( "Para ejecutar el Algoritmo de FloydWarshall (todos los» camino mínimos) debe activar la opción Coste" & vbCrLf & "de los
» arcos del grafo en el menú Formato/Opciones/Arcos." , MsgBoxStyle .
» Information , "Algoritmo de FloydWarshall" )
06026
Exit Sub06027
End If06028
06029
'----------------------------------------------------06030
'A la dll se le debe pasar un array de strings06031
'de dimensión totalnodos-1 ya que empieza en 006032
'con el nombre o etiqueta de los nodos06033
'----------------------------------------------------06034
Dim i , j As Long06035
Dim MatrizNodos ( TotalNodos - 1 ) As String06036
For i = 0 To TotalNodos - 106037
MatrizNodos ( i ) = Nodos ( i ) . Texto06038
Next i06039
06040
'----------------------------------------------------06041
'a la dll se le debe pasar las relaciones de arco en06042
'matriz(i,j) donde i=nodo origen, j=nodo destino06043
'de dimensiones de 0 a totalnodos-1 para i y para j06044
'contendrá un single >=006045
'recuerda que después del proceso RellenaMatrices06046
'se dispone de un array de relación de arco que es06047
'Matriz(x,y) donde x=columna=j,y=fila=i (traspuesta)06048
'----------------------------------------------------06049
Const cMaximo As Single = 99999999999999999906050
Const cMinimo As Single = - 99999999999999999906051
06052
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Single06053
'pone toda la matriz sin relación de arcos06054
For i = 0 To TotalNodos - 106055
For j = 0 To TotalNodos - 106056
MatrizArcos ( i , j ) = cMaximo06057
Next j06058
Next i06059
'marca los arcos existentes, pero no los de un mismo nodo06060
For i = 0 To TotalArcos - 106061
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then06062
'06063
Else06064
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = Arcos ( i ) . Coste06065
End If06066
Next i06067
06068
'Establece propiedades de la DLL06069
'con los datos del problema06070
FloydWarshall1 . MatrizNodos = MatrizNodos06071
FloydWarshall1 . MatrizArcos = MatrizArcos06072
06073
'Comienza el uso de la DLL06074
'indicándole como parámetro06075
'camino máximo = false --> camino mínimo06076
FloydWarshall1 . Inicio ( False )06077
End Sub06078
Private Sub FloydWarshall1_Fallo ( ByVal TextoError As String ) Handles» FloydWarshall1 . Fallo
06079
'Este evento salta en caso de un error en el proceso de FloydWarshall06080
MsgBox ( TextoError , MsgBoxStyle . Exclamation , "Error en el proceso» FloydWarshall" )
06081
End Sub06082
Private Sub FloydWarshall1_Fin ( ByVal TextoRespuesta As String , ByVal» MatrizArcosMinimos As System . Array ) Handles FloydWarshall1 . Fin
06083
'El proceso ha finalizado al parecer correctamente06084
'lee los parámetros de vuelta con la solución los muestra06085
06086
txtResultadosAlgoritmo = ""06087
txtResultadosAlgoritmo = TextoRespuesta06088
AlgoritmoMILP = False06089
06090
CopiaGrafoPrevio ()06091
06092
06093
'Dibuja la solución y construye texto06094
'------------------------------------06095
Dim i , j As Integer06096
Dim arc As Integer06097
06098
For arc = 0 To TotalArcos - 106099
Arcos ( arc ) . Col = Color . Black06100
Arcos ( arc ) . Grosor = Grafico . TrazoArco06101
Next arc06102
'para mostrar el detalle de los arcos06103
Grafico . BArco = False06104
Grafico . costArco = True06105
06106
For i = 0 To UBound ( MatrizArcosMinimos , 1 )06107
For j = 0 To UBound ( MatrizArcosMinimos , 2 )06108
If MatrizArcosMinimos ( i , j ) = 1 Then06109
For arc = 0 To TotalArcos - 106110
If Arcos ( arc ) . Nd1 = i And Arcos ( arc ) . Nd2 = j Then06111
06112
Arcos ( arc ) . Grosor = Grafico . TrazoArco + 106113
Arcos ( arc ) . Col = Color . Green06114
06115
Exit For06116
End If06117
Next arc06118
End If06119
Next j06120
Next i06121
06122
DibujaGrafo ()06123
'------------------------------------06124
06125
CopiaGrafoSolucion ()06126
MuestraCajaSolucion ()06127
End Sub06128
Private Sub mnuAnalisis_Transbordo_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuAnalisis_Transbordo . Click
06129
'Lanza rutina para el Problema de Transbordo06130
Transbordo ()06131
End Sub06132
Sub Transbordo ()06133
06134
'PROBLEMA DEL TRANSBORDO CAPACITADO06135
'Modelado LP del Problema del Transbordo Capacitado06136
06137
'El modelo en formato .lp se resolverá mediante la libreria06138
'lp_solve 5.0.0.0 bajo licencia LGPL06139
06140
06141
Dim i , j , k As Integer06142
06143
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Long06144
Dim SumSal ( TotalNodos - 1 ) As Long06145
Dim SumEnt ( TotalNodos - 1 ) As Long06146
Dim ContadorArcosReales As Long06147
ContadorArcosReales = 006148
06149
'pone toda la matriz sin relación de arcos06150
For i = 0 To TotalNodos - 106151
SumSal ( i ) = 006152
SumEnt ( i ) = 006153
For j = 0 To TotalNodos - 106154
MatrizArcos ( i , j ) = - 106155
Next j06156
Next i06157
'marca los arcos existentes, pero no los de un mismo nodo06158
For i = 0 To TotalArcos - 106159
'If Arcos(i).Nd1 = Arcos(i).Nd2 Then06160
'06161
'Else 'le pasa el valor del indice del array de arcos06162
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = i06163
SumSal ( Arcos ( i ) . Nd1 ) += 106164
SumEnt ( Arcos ( i ) . Nd2 ) += 106165
'End If06166
Next i06167
06168
06169
'------------------------------------06170
'FASE 0: CONDICIONES DE INTEGRIDAD06171
'------------------------------------06172
'no permitir nodos sueltos sin arcos06173
'If ExistenNodosSueltos() Then06174
For i = 0 To TotalNodos - 106175
ContadorArcosReales += SumSal ( i )06176
06177
If SumSal ( i ) = 0 And SumEnt ( i ) = 0 Then06178
MsgBox ( "En este grafo existen nodos no conectados." & vbCrLf &» "Elimine los nodos sueltos o conéctelos." , MsgBoxStyle .
» Information , "Problema de Transbordo" )
06179
Me . Cursor = Cursors . Arrow06180
Exit Sub06181
End If06182
Next i06183
06184
06185
'### no permitir arcos que entren y salgan de un mismo nodo???06186
'de momento se tienen en cuenta!!06187
06188
06189
'comprobar las opciones de coste nodo, coste arco, min arco y max arco» activadas
06190
If Grafico . costArco = False Then06191
MsgBox ( "Para resolver el problema de Transbordo (coste mínimo)» mediante LP" & vbCrLf & "debe activar las opciones de Coste, de
» los arcos del grafo en " & vbCrLf & "el menú
» Formato/Opciones/Arcos." , MsgBoxStyle . Information , "Transbordo -
» LP" )
06192
Exit Sub06193
End If06194
If Grafico . costNodo = False Then06195
MsgBox ( "Para resolver el problema de Transbordo (coste mínimo)» mediante LP" & vbCrLf & "debe activar la opción Valor de los
» nodos del grafo en el menú " & vbCrLf & "Formato/Opciones/Nodos."
» , MsgBoxStyle . Information , "Transbordo - LP" )
06196
Exit Sub06197
End If06198
06199
'### arcos con costes negativos?06200
06201
06202
'--------------------------------------06203
'FASE 0B: ALTERNATIVAS DE PROBLEMA06204
'--------------------------------------06205
Me . Cursor = Cursors . WaitCursor06206
06207
'Comprueba si se trata de un problema equilibrado06208
'que es aquel cuyo suministro total es igual a la demanda total06209
Dim suministro As Single06210
Dim demanda As Single06211
For i = 0 To TotalNodos - 106212
If Nodos ( i ) . Valor < 0 Then06213
suministro = suministro - Nodos ( i ) . Valor06214
End If06215
If Nodos ( i ) . Valor > 0 Then06216
demanda = demanda + Nodos ( i ) . Valor06217
End If06218
Next i06219
'no equilibrado06220
If suministro < demanda Then06221
MsgBox ( "Parece que este problema de Transbordo no está equilibrado.» Recuerde que:" & vbCrLf & "El suministro total debe ser >=
» demanda total." & vbCrLf & "El suministro se indica como valor
» del nodo con signo menos (-)." & vbCrLf & "La demanda se indica
» como valor del nodo con signo más (+)." & vbCrLf & "El transbordo
» se indica como valor del nodo con un cero (0)." , MsgBoxStyle .
» Information , "Transbordo - LP" )
06222
Me . Cursor = Cursors . Arrow06223
Exit Sub06224
End If06225
06226
'equilibrado06227
06228
'capacitado06229
'no capacitado06230
'Opciones de capacidad para determinar las restricciones06231
If Grafico . minArco = False Then06232
MsgBox ( "En este problema de Transbordo (coste mínimo) mediante LP" &» vbCrLf & "no se considerará la restricción de flujo mínimo en
» los arcos." , MsgBoxStyle . Information , "Transbordo - LP" )
06233
End If06234
If Grafico . maxArco = False Then06235
MsgBox ( "En este problema de Transbordo (coste mínimo) mediante LP" &» vbCrLf & "no se considerará la restricción de flujo máximo en
» los arcos." , MsgBoxStyle . Information , "Transbordo - LP" )
06236
End If06237
06238
'------------------06239
'FASE 1: MODELADO06240
'------------------06241
'Inicio tiempo06242
Dim TInicio As Date = Now06243
06244
Dim TextoModelo As String06245
06246
06247
'Función Objetivo (a minimizar)06248
'--------------------------------------------06249
'El sumatorio para todos los arcos de los costes por los flujos06250
'minimiza costes totales de Transbordo06251
'Variables de decisión (flujos de los arcos)06252
Dim operador As String06253
06254
TextoModelo = "min: "06255
For k = 0 To TotalArcos - 106256
If Arcos ( k ) . Coste >= 0 Then06257
'el operador >= 0 indica que se incluye el flujo de06258
'arcos con coste cero como variables de decisión06259
operador = " +" & Arcos ( k ) . Coste . ToString06260
End If06261
If Arcos ( k ) . Coste < 0 Then06262
'no es necesario anteponer el signo menos06263
operador = Arcos ( k ) . Coste . ToString06264
'operador = "- " & Arcos(k).Coste.ToString06265
End If06266
06267
TextoModelo & = operador & DaNombreArco ( k )06268
Next k06269
TextoModelo & = ";" & vbCrLf 'fin línea y salto de línea06270
TextoModelo & = vbCrLf 'salto de línea06271
06272
Dim nr As Long 'contador de restricciones06273
nr = 006274
06275
06276
'Restricciones de Continuidad06277
'--------------------------------------------06278
'tantas restricciones como nodos06279
'el total de flujo de entrada - el total de salida06280
'debe ser mayor o igual06281
'-capacidad o +demanda06282
06283
'la demanda y capacidad mantienen su signo06284
'(convención de signos en ayuda: demanda positiva y capacidad negativa)06285
06286
06287
For i = 0 To TotalNodos - 106288
nr = nr + 106289
TextoModelo & = "r" & nr . ToString & ": " 'indicador de restricción06290
06291
'###(falta pensar!!!)) con nodos de transbordo sin residuo??????06292
06293
'Para todos los arcos de ese nodo06294
For j = 0 To TotalNodos - 106295
'arcos de entrada06296
If MatrizArcos ( j , i ) > - 1 Then06297
TextoModelo & = " +" & DaNombreArco ( MatrizArcos ( j , i ))06298
End If06299
'arcos de salida06300
If MatrizArcos ( i , j ) > - 1 Then06301
TextoModelo & = " -" & DaNombreArco ( MatrizArcos ( i , j ))06302
End If06303
Next j06304
06305
06306
'condición06307
TextoModelo & = " >= " & Nodos ( i ) . Valor . ToString06308
06309
'###Ver capacidad residual y su condición (=?)06310
'If Nodos(i).Valor >= 0 Then06311
' 'si es una capacidad, se resta la capacidad_sobrante06312
' TextoModelo &= " +CS_" & Nodos(i).Texto06313
'End If06314
'If Nodos(i).Valor < 0 Then06315
' 'si es una demanda, se suma la demanda_insatisfecha06316
' TextoModelo &= " -DI_" & Nodos(i).Texto06317
'End If06318
06319
TextoModelo & = ";" & vbCrLf 'fin línea y salto de línea06320
06321
Next i06322
TextoModelo & = vbCrLf 'salto de línea06323
06324
06325
'Restricciones de Flujo06326
'--------------------------------------------06327
'para todos los arcos del modelo06328
06329
For k = 0 To TotalArcos - 106330
06331
'comprobar que flujo mínimo es menor que flujo máximo06332
If Arcos ( k ) . Min > Arcos ( k ) . Max Then06333
MsgBox ( "Asegúrese de que para todos los arcos del grafo, las "» & vbCrLf & "capacidades mínimas sean <= capacidades máximas."
» , MsgBoxStyle . Information , "Problema de Transbordo" )
06334
Exit Sub06335
End If06336
06337
If Arcos ( k ) . Min = Arcos ( k ) . Max Then06338
'Entonces es una restricción de igualdad, obligatoriedad de» flujo
06339
'nr = nr + 106340
'TextoModelo &= "r" & nr.ToString & ": " 'indicador de» restricción
06341
TextoModelo & = DaNombreArco ( k ) & " =" & Arcos ( k ) . Min . ToString06342
TextoModelo & = ";" & vbCrLf 'fin línea y salto de línea06343
Else06344
06345
If Grafico . minArco = True Then06346
'Flujo >= mínimo06347
'nr = nr + 106348
'TextoModelo &= "r" & nr.ToString & ": " 'indicador de» restricción
06349
TextoModelo & = DaNombreArco ( k ) & " >=" & Arcos ( k ) . Min .» ToString
06350
TextoModelo & = ";" & vbCrLf 'fin línea y salto de línea06351
End If06352
06353
If Grafico . maxArco = True Then06354
'Flujo <= máximo06355
'nr = nr + 106356
'TextoModelo &= "r" & nr.ToString & ": " 'indicador de» restricción
06357
TextoModelo & = DaNombreArco ( k ) & " <=" & Arcos ( k ) . Max .» ToString
06358
TextoModelo & = ";" & vbCrLf 'fin línea y salto de línea06359
End If06360
End If06361
Next k06362
TextoModelo & = vbCrLf 'salto de línea06363
06364
06365
'Restricciones de no negatividad06366
'--------------------------------------------06367
'tantas restricciones como arcos06368
'el flujo de cada arco es mayor o igual a cero06369
'ya que sigue el sentido del arco (flecha)06370
For k = 0 To TotalArcos - 106371
'nr = nr + 106372
'TextoModelo &= "r" & nr.ToString & ": " 'indicador de restricción06373
TextoModelo & = DaNombreArco ( k ) & " >=0;" & vbCrLf 'fin línea y» salto
06374
Next k06375
06376
06377
'El punto decimal se expresa como un punto en el fichero .lp06378
'Por ello cambia las comas de Grafos por puntos.06379
TextoModelo = TextoModelo . Replace ( "," , "." )06380
06381
'Enseña el modelo para debugging06382
'MsgBox(TextoModelo, MsgBoxStyle.Information, "Modelo .LP")06383
06384
'fin tiempo06385
Dim Tiempo As System . TimeSpan = Now . Subtract ( TInicio )06386
TiempoModelado = Tiempo . Milliseconds06387
06388
'-------------------------------06389
'FASE 2: GRABA FICHERO .LP06390
'-------------------------------06391
EscribeFicheroTexto ( CurDir () & "\GrafosLP~.lp" , "" )06392
EscribeFicheroTexto ( CurDir () & "\GrafosLP~.lp" , TextoModelo )06393
06394
'FASE 2_ALT: MODELO EN MEMORIA06395
' - de momento descartado -06396
06397
'---------------------------06398
'FASE 3: RESOLVER06399
'FASE 4: GUARDAR SOLUCIÓN06400
'FASE 4B: TRADUCIR SOLUCIÓN06401
'---------------------------06402
ResuelveFichero_GrafosLP ( CurDir () & "\GrafosLP~.lp" , "PROBLEMA DEL» TRANSBORDO" )
06403
06404
'---------------------------------------06405
'FASE 5:MOSTRAR AL USUARIO SOLUCIÓN06406
'---------------------------------------06407
'### pensar en posible representación gráfica06408
'Representación gráfica del recorrido solución06409
AlgoritmoMILP = True06410
06411
CopiaGrafoPrevio ()06412
06413
Dim vd As Long06414
vd = 006415
For k = 0 To TotalArcos - 106416
Arcos ( k ) . Col = Color . Black06417
Arcos ( k ) . Grosor = Grafico . TrazoArco06418
06419
'Se ignoran arcos que entren y salgan de un mismo nodo06420
'If Arcos(k).Nd1 <> Arcos(k).Nd2 Then06421
vd = vd + 106422
If SolucionModeloLP ( vd ) > 0 Then06423
Arcos ( k ) . Col = Color . Green06424
Arcos ( k ) . Grosor = Arcos ( k ) . Grosor + 106425
End If06426
'End If06427
Next k06428
DibujaGrafo ()06429
06430
CopiaGrafoSolucion ()06431
MuestraCajaSolucion ()06432
Me . Cursor = Cursors . Default06433
End Sub06434
Function DaNombreArco ( ByVal k As Long ) As String06435
'Crea una etiqueta para el arco en función de las etiquetas06436
'del arco origen y destino06437
' Return "x_" & Nodos(Arcos(k).Nd1).Texto & "_" &» Nodos(Arcos(k).Nd2).Texto
06438
06439
'no se utiliza los nombres de los nodos en la nomenclatura de las» variables
06440
'ya que sino, se genera un error en el lp_solve si existen caracteres» extraños
06441
Return "x_" & Arcos ( k ) . Nd1 & "_" & Arcos ( k ) . Nd206442
End Function06443
Private Function abortfunc ( ByVal lp As Integer , ByVal aborthandle As Integer» ) As Integer
06444
'En esta rutina se podría controlar el proceso de resolución» periódicamente
06445
'y detenerlo en caso de necesidad, controlando por ejemplo una» pulsación de tecla
06446
06447
'con valor = 1 se detiene el proceso06448
abortfunc = 006449
06450
End Function06451
Private Sub Traduce ( ByVal FicheroOriginal As String , ByVal FicheroTraducido» As String )
06452
06453
Dim TextoCompleto As String06454
'Lee un fichero plano y lo pone en una variable06455
LeeFicheroTexto ( FicheroOriginal , TextoCompleto )06456
06457
'Proceso de Traducción06458
Dim Buscar As String06459
Dim Reemplazar As String06460
06461
Buscar = "Model name"06462
Reemplazar = "Nombre del modelo"06463
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06464
06465
Buscar = "Value of objective function:"06466
Reemplazar = "Valor de la función objetivo ="06467
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06468
06469
Buscar = "Actual values of the variables:"06470
Reemplazar = "Valor actual de las variables:" & vbCrLf06471
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06472
06473
Buscar = "Actual values of the constraints:"06474
Reemplazar = "Valor actual de las restricciones:" & vbCrLf06475
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06476
06477
Buscar = "Objective function limits:"06478
Reemplazar = "Sensibilidad de los coeficientes de la función objetivo:"» & vbCrLf
06479
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06480
06481
Buscar = "Dual values with from - till limits:"06482
Reemplazar = "Sensibilidad RHS de las restricciones:" & vbCrLf06483
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06484
06485
Buscar = "Infinite"06486
Reemplazar = "Infinito"06487
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06488
06489
Buscar = "Type"06490
Reemplazar = "Tipo"06491
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06492
06493
Buscar = "upbo "06494
Reemplazar = "lim_Sup"06495
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06496
06497
Buscar = "lowbo "06498
Reemplazar = "lim_Inf"06499
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06500
06501
Buscar = "Minimize "06502
Reemplazar = "Minimizar"06503
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06504
06505
Buscar = "Maximize "06506
Reemplazar = "Maximizar"06507
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06508
06509
Buscar = "From "06510
Reemplazar = " Desde"06511
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06512
06513
Buscar = "Till"06514
Reemplazar = "Hasta"06515
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06516
06517
Buscar = " FromValue"06518
Reemplazar = "Coste reducido"06519
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06520
06521
Buscar = " Dual value"06522
Reemplazar = "Precio sombra"06523
TextoCompleto = TextoCompleto . Replace ( Buscar , Reemplazar )06524
06525
06526
'Guarda el resultado de la traducción06527
'--------------------------------------06528
'Escribe en un fichero plano un texto06529
EscribeFicheroTexto ( FicheroTraducido , TextoCompleto )06530
FileClose ()06531
'Guarda la solución en la variable para mostrar en pantalla06532
Form1 . txtResultadosAlgoritmo = ""06533
Form1 . txtResultadosAlgoritmo = TextoCompleto06534
06535
End Sub06536
Public Sub ResuelveFichero_GrafosLP ( ByVal TrayectoriaFichero As String ,» ByVal TituloProblema As String )
06537
06538
'declaración para lp_solve 506539
Dim lpsolve As lpsolve5106540
'Inicialización del Solver lp_solver 506541
lpsolve = New lpsolve5106542
lpsolve . Init ( "." )06543
06544
'---------------------------------------06545
'Declaración de variables para lp_solve06546
'---------------------------------------06547
Dim lp1 As Integer06548
Dim lp2 As Integer06549
Dim Row () As Double06550
Dim Lower () As Double06551
Dim Upper () As Double06552
Dim Col () As Double06553
Dim Arry () As Double06554
Dim Buf As String06555
06556
06557
'prueba QSopt06558
' lp1 = QSopt1.QSopt.QSread_prob("c:\GrafosLP.mps", "MPS")06559
' lp1 = QSopt1.QSopt.QSopt_primal(lp1, 1)06560
' qssolver -O problema.mps >sol.txt06561
06562
06563
'---------------------------------------06564
'Fichero de entrada en formato .lp06565
lp1 = lpsolve . read_LP ( TrayectoriaFichero , False , TituloProblema )06566
If lp1 = 0 Then06567
Beep ()06568
End If06569
'---------------------------------------06570
'Ficheros de salida (log, resultados y modelo en formato .mps)06571
'Indica nombre y trayectoria del fichero log06572
'lpsolve.log_file(CurDir() & "\log.txt")06573
06574
'Indica nombre y trayectoria del fichero de resultados06575
'versión 506576
06577
EscribeFicheroTexto ( CurDir () & "\GrafosLP_results.txt" , "" )06578
EscribeFicheroTexto ( CurDir () & "\GrafosLP_results_es.txt" , "" )06579
06580
lpsolve . set_outputfile ( lp1 , CurDir () & "\GrafosLP_results.txt" )06581
06582
'escribe el problema en formato mps06583
lpsolve . write_mps ( lp1 , CurDir () & "\GrafosLP~.mps" )06584
06585
'escribe el problema también en formato CPLEX06586
lpsolve . write_lp ( lp1 , CurDir () & "\GrafosLP~.lp" )06587
06588
06589
06590
'---------------------------------------06591
'Crea una referencia a la rutina de abortar06592
'desde dicha rutina 'abortfunc' se puede controlar el proceso06593
'de resolución y parar controlando pulsaciones de tecla por ejemplo.06594
'lpsolve.put_abortfunc(lp1, AddressOf abortfunc, 0)06595
06596
'Establece el tiempo de timeout (en segundos) para parar el proceso06597
'en caso de no encontrar solución factible06598
'con valor = 0 no hay tiempo límite06599
lpsolve . set_timeout ( lp1 , 0 )06600
06601
06602
lpsolve . print_str ( lp1 , TituloProblema & vbLf )06603
lpsolve . print_str ( lp1 , "---------------------------------------" & vbLf )06604
lpsolve . print_str ( lp1 , vbLf )06605
06606
'Inicio tiempo06607
Dim TInicio As Date = Now06608
06609
'Cálculo propiamente dicho06610
Dim optimo As Integer06611
'opción de selección de rama en branch & bound06612
'automatic por defecto06613
'lpsolve.set_bb_floorfirst(lp1, lpsolve_branch.BRANCH_AUTOMATIC)06614
'opción de regla de branch & bound06615
lpsolve . set_bb_rule ( lp1 , lpsolve_BBstrategies . NODE_PSEUDORATIOSELECT ) '» lpsolve_BBstrategies.NODE_PSEUDONONINTSELECT)
06616
'opción de descomposición LU06617
optimo = lpsolve . set_BFP ( lp1 , "bfp_LUSOL" ) '"bfp_GLPK")06618
'opción de escalado06619
lpsolve . set_scaling ( lp1 , lpsolve_scales . SCALE_CURTISREID Or» lpsolve_scales . SCALE_INTEGERS )
06620
'opción de selección de pivote en simplex (devex por defecto)06621
lpsolve . set_pivoting ( lp1 , lpsolve_piv_rules . PRICER_DEVEX )06622
'soluciona06623
optimo = lpsolve . solve ( lp1 )06624
06625
'fin tiempo06626
Dim tiempoproceso As Long06627
tiempoproceso = DateDiff ( DateInterval . Second , TInicio , Now )06628
06629
'Escribe el tiempo de proceso06630
lpsolve . print_str ( lp1 , " Tiempo de modelado = " & TiempoModelado .» ToString & " segundos" & vbLf )
06631
lpsolve . print_str ( lp1 , " Tiempo de proceso = " & tiempoproceso . ToString» & " segundos" & vbLf )
06632
lpsolve . print_str ( lp1 , vbLf )06633
06634
'comprueba si la solución encontrada es óptima06635
06636
Select Case optimo06637
06638
Case 0 'Solución óptima06639
lpsolve . print_str ( lp1 , " SOLUCIÓN ÓPTIMA " & vbLf )06640
'Escribe valor devuelto por solver06641
lpsolve . print_str ( lp1 , " lp_solve -> " & optimo & vbLf )06642
lpsolve . print_str ( lp1 , vbLf )06643
Case 1 'Solución subóptima06644
lpsolve . print_str ( lp1 , " SOLUCIÓN SUB-ÓPTIMA " & vbLf )06645
'Escribe valor devuelto por solver06646
lpsolve . print_str ( lp1 , " lp_solve -> " & optimo & vbLf )06647
lpsolve . print_str ( lp1 , vbLf )06648
06649
Case Is >= 2 'infactible, ilimitado06650
06651
lpsolve . print_str ( lp1 , " PROBLEMA NO FACTIBLE " & vbLf )06652
'Escribe valor devuelto por solver06653
lpsolve . print_str ( lp1 , " lp_solve -> " & optimo & vbLf )06654
lpsolve . print_str ( lp1 , vbLf )06655
06656
MsgBox ( "LP Solver ha detectado un problema no factible." ,» MsgBoxStyle . Exclamation , "LP Solver" )
06657
06658
End Select06659
06660
06661
'Escribe el modelo06662
lpsolve . print_lp ( lp1 )06663
lpsolve . print_str ( lp1 , vbLf )06664
06665
'Incluye el modelo en formato lp06666
lpsolve . print_str ( lp1 , "Modelo en formato (.LP):" & vbLf )06667
lpsolve . print_str ( lp1 , vbLf )06668
Dim modelo As String06669
LeeFicheroTexto ( CurDir () & "\GrafosLP~.lp" , modelo )06670
lpsolve . print_str ( lp1 , modelo )06671
06672
'Toma datos06673
ReDim Col ( lpsolve . get_Ncolumns ( lp1 ))06674
lpsolve . get_variables ( lp1 , Col ( 1 ))06675
06676
06677
'------------06678
'Recorre la solución y la guarda en este array para su posible06679
'representación gráfica06680
ReDim SolucionModeloLP ( lpsolve . get_Ncolumns ( lp1 ))06681
Dim s As Long06682
For s = 1 To lpsolve . get_Ncolumns ( lp1 )06683
SolucionModeloLP ( s ) = Col ( s )06684
'Debug.Write(s & "...." & SolucionModeloLP(s))06685
'Debug.Write(vbCrLf)06686
Next s06687
'------------06688
06689
06690
ReDim Row ( lpsolve . get_Nrows ( lp1 ))06691
lpsolve . get_constraints ( lp1 , Row ( 1 ))06692
06693
ReDim Arry ( lpsolve . get_Ncolumns ( lp1 ) + lpsolve . get_Nrows ( lp1 ))06694
lpsolve . get_dual_solution ( lp1 , Arry ( 0 ))06695
06696
ReDim Arry ( lpsolve . get_Ncolumns ( lp1 ) + lpsolve . get_Nrows ( lp1 ))06697
ReDim Lower ( lpsolve . get_Ncolumns ( lp1 ) + lpsolve . get_Nrows ( lp1 ))06698
ReDim Upper ( lpsolve . get_Ncolumns ( lp1 ) + lpsolve . get_Nrows ( lp1 ))06699
lpsolve . get_sensitivity_rhs ( lp1 , Arry ( 1 ), Lower ( 1 ), Upper ( 1 ))06700
06701
ReDim Lower ( lpsolve . get_Ncolumns ( lp1 ))06702
ReDim Upper ( lpsolve . get_Ncolumns ( lp1 ))06703
lpsolve . get_sensitivity_obj ( lp1 , Lower ( 0 ), Upper ( 0 ))06704
06705
'Escribe la función objetivo06706
lpsolve . print_objective ( lp1 )06707
'Escribe la solución para las variables de decisión06708
lpsolve . print_solution ( lp1 , 1 )06709
'Escribe el resultado de las restricciones06710
lpsolve . print_constraints ( lp1 , 1 )06711
06712
06713
'Escribe el análisis de sensibilidad06714
lpsolve . print_duals ( lp1 )06715
06716
'Borra el problema en memoria06717
lpsolve . delete_lp ( lp1 )06718
06719
'Cierra y guarda ficheros06720
'lpsolve.print_file(vbNullString)06721
'lpsolve.log_file(vbNullString)06722
lpsolve . set_outputfile ( lp1 , CurDir () & "\fin.txt" )06723
06724
06725
06726
lpsolve = Nothing06727
06728
'Llama a la función de traducción del fichero de resultados06729
Traduce ( CurDir () & "\GrafosLP_results.txt" , CurDir () &» "\GrafosLP_results_es.txt" )
06730
06731
06732
End Sub06733
Private Sub mnuAnalisis_TSP_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles mnuAnalisis_TSP . Click
06734
'Lanza rutina de Viajante de Comercio06735
TSP ()06736
06737
End Sub06738
Sub TSP ()06739
'PROBLEMA DEL VIAJANTE DE COMERCIO06740
'Modelado MILP del Problema del Viajante de Comercio06741
06742
'El modelo en formato .lp se resolverá mediante la libreria06743
'lp_solve 5.0.0.0 bajo licencia LGPL06744
06745
Me . Cursor = Cursors . WaitCursor06746
Dim i , j , k As Integer06747
06748
Dim MatrizArcos ( TotalNodos - 1 , TotalNodos - 1 ) As Long06749
Dim SumSal ( TotalNodos - 1 ) As Long06750
Dim SumEnt ( TotalNodos - 1 ) As Long06751
Dim ContadorArcosReales As Long06752
ContadorArcosReales = 006753
06754
'pone toda la matriz sin relación de arcos06755
For i = 0 To TotalNodos - 106756
SumSal ( i ) = 006757
SumEnt ( i ) = 006758
For j = 0 To TotalNodos - 106759
MatrizArcos ( i , j ) = - 106760
Next j06761
Next i06762
'marca los arcos existentes, pero no los de un mismo nodo06763
For i = 0 To TotalArcos - 106764
If Arcos ( i ) . Nd1 = Arcos ( i ) . Nd2 Then06765
'06766
Else 'le pasa el valor del indice del array de arcos06767
MatrizArcos ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = i06768
SumSal ( Arcos ( i ) . Nd1 ) += 106769
SumEnt ( Arcos ( i ) . Nd2 ) += 106770
End If06771
Next i06772
06773
06774
06775
'------------------------------------06776
'FASE 0: CONDICIONES DE INTEGRIDAD06777
'------------------------------------06778
'no permitir nodos sueltos sin arcos06779
'If ExistenNodosSueltos() Then06780
For i = 0 To TotalNodos - 106781
ContadorArcosReales += SumSal ( i )06782
06783
If SumSal ( i ) = 0 And SumEnt ( i ) = 0 Then06784
MsgBox ( "En este grafo existen nodos no conectados." & vbCrLf &» "Elimine los nodos sueltos o conéctelos." , MsgBoxStyle .
» Information , "Problema del Viajante de Comercio" )
06785
Me . Cursor = Cursors . Arrow06786
Exit Sub06787
End If06788
Next i06789
06790
'### no permitir arcos que entren y salgan de un mismo nodo???06791
'Se ignoran más abajo06792
06793
'comprobar las opciones de coste nodo, coste arco, min arco y max arco» activadas
06794
If Grafico . costArco = False Then06795
MsgBox ( "Para resolver el Problema del Viajante de Comercio» (distancia mínima) mediante" & vbCrLf & "MILP debe activar las
» opciones de Coste, de los arcos del grafo en el menú" & vbCrLf &
» " Formato/Opciones/Arcos." , MsgBoxStyle . Information , "Problema
» del Viajante de Comercio" )
06796
Exit Sub06797
End If06798
06799
06800
'### arcos con costes negativos?06801
06802
06803
'--------------------------------------06804
'FASE 0B: ALTERNATIVAS DE PROBLEMA06805
'--------------------------------------06806
06807
06808
06809
'capacitado06810
06811
'Opciones de capacidad para determinar las restricciones06812
'If Grafico.minArco = False Then06813
'MsgBox("En este problema de Transbordo (coste mínimo) mediante LP" &» vbCrLf & "no se considerará la restricción de flujo mínimo en los
» arcos.", MsgBoxStyle.Information, "Transbordo - LP")
06814
'End If06815
'If Grafico.maxArco = False Then06816
'MsgBox("En este problema de Transbordo (coste mínimo) mediante LP" &» vbCrLf & "no se considerará la restricción de flujo máximo en los
» arcos.", MsgBoxStyle.Information, "Transbordo - LP")
06817
'End If06818
06819
'no capacitado06820
06821
'------------------06822
'FASE 1: MODELADO06823
'------------------06824
'Inicio tiempo06825
Dim TInicio As Date = Now06826
06827
Dim TextoModelo As String06828
06829
06830
'Función Objetivo (a minimizar)06831
'--------------------------------------------06832
'El sumatorio para todos los arcos de las distancias entre nodos06833
'minimiza distancia total de Recorrido06834
'Variables de decisión (arco seleccionado 1 , 0)06835
Dim operador As String06836
06837
TextoModelo = "min: "06838
For k = 0 To TotalArcos - 106839
'Se ignoran arcos que entren y salgan de un mismo nodo06840
If Arcos ( k ) . Nd1 <> Arcos ( k ) . Nd2 Then06841
'ContadorArcosReales = ContadorArcosReales + 106842
06843
If Arcos ( k ) . Coste >= 0 Then06844
'el operador >= 0 indica que se incluye el flujo de06845
'arcos con coste cero como variables de decisión06846
operador = " +" & Arcos ( k ) . Coste . ToString06847
End If06848
If Arcos ( k ) . Coste < 0 Then06849
'no es necesario anteponer el signo menos06850
operador = Arcos ( k ) . Coste . ToString06851
'operador = "- " & Arcos(k).Coste.ToString06852
End If06853
06854
TextoModelo & = operador & DaNombreArco ( k )06855
End If06856
Next k06857
TextoModelo & = ";" & vbCrLf 'fin línea y salto de línea06858
TextoModelo & = vbCrLf 'salto de línea06859
06860
Dim nr As Long 'contador de restricciones06861
nr = 006862
06863
06864
'Restricciones de Ruta06865
'--------------------------------------------06866
'tantas restricciones como nodos06867
'el total de arcos de entrada debe ser igual a 106868
'el total de arcos de salida debe ser igual a 106869
'se garantiza un que el nodo sólo aparece una vez en el recorrido06870
06871
For i = 0 To TotalNodos - 106872
'Para todos los arcos ENTRANTES de ese nodo06873
If SumEnt ( i ) > 0 Then06874
nr = nr + 106875
TextoModelo & = "r" & nr . ToString & ": "06876
For j = 0 To TotalNodos - 106877
If MatrizArcos ( j , i ) > - 1 Then06878
TextoModelo & = " +" & DaNombreArco ( MatrizArcos ( j , i ))» 'siempre suma
06879
End If06880
Next j06881
'condición06882
TextoModelo & = " = 1"06883
TextoModelo & = ";" & vbCrLf 'fin línea y salto de línea06884
End If06885
06886
'Para todos los arcos SALIENTES de ese nodo06887
If SumSal ( i ) > 0 Then06888
nr = nr + 106889
TextoModelo & = "r" & nr . ToString & ": "06890
For j = 0 To TotalNodos - 106891
If MatrizArcos ( i , j ) > - 1 Then06892
TextoModelo & = " +" & DaNombreArco ( MatrizArcos ( i , j ))» 'siempre suma
06893
End If06894
Next j06895
'condición06896
TextoModelo & = " = 1"06897
TextoModelo & = ";" & vbCrLf 'fin línea y salto de línea06898
End If06899
Next i06900
TextoModelo & = vbCrLf 'salto de línea06901
06902
06903
'Condiciones de Tucker06904
'--------------------------------------------06905
'para todos los nodos (2...n) del modelo, el primero no06906
'Garantizan que no existen subrutas06907
'(hace uso del número real de arcos, no aquellos de un mismo nodo)06908
06909
For i = 1 To TotalNodos - 106910
'Se ignoran arcos que entren y salgan de un mismo nodo06911
'arcos de salida pertenece al nodo06912
06913
If SumSal ( i ) > 0 Then06914
For j = 0 To TotalNodos - 106915
If MatrizArcos ( i , j ) > - 1 Then06916
k = MatrizArcos ( i , j )06917
nr = nr + 106918
TextoModelo & = "r" & nr . ToString & ": " 'indicador de» restricción
06919
06920
TextoModelo & = "u" & Arcos ( k ) . Nd1 . ToString06921
TextoModelo & = " -u" & Arcos ( k ) . Nd2 . ToString06922
TextoModelo & = " +" & ContadorArcosReales . ToString &» DaNombreArco ( k )
06923
TextoModelo & = " <= "06924
TextoModelo & = ContadorArcosReales - 106925
TextoModelo & = ";" & vbCrLf 'fin línea y salto de» línea
06926
End If06927
Next j06928
End If06929
06930
Next i06931
TextoModelo & = vbCrLf 'salto de línea06932
06933
'El punto decimal se expresa como un punto en el fichero .lp06934
'Por ello cambia las comas de Grafos por puntos.06935
'Además en este caso se sustituye antes de declarar con comas06936
'la lista de variables enteras06937
TextoModelo = TextoModelo . Replace ( "," , "." )06938
06939
'Restricciones de variables enteras06940
'--------------------------------------------06941
'tantas restricciones como arcos06942
TextoModelo & = "int "06943
Dim cont As Long06944
cont = 006945
For k = 0 To TotalArcos - 106946
'Se ignoran arcos que entren y salgan de un mismo nodo06947
If Arcos ( k ) . Nd1 <> Arcos ( k ) . Nd2 Then06948
cont = cont + 106949
TextoModelo & = DaNombreArco ( k )06950
06951
If cont < ContadorArcosReales Then06952
TextoModelo & = ", "06953
Else06954
'llegó al último y no necesita coma separadora06955
End If06956
06957
End If06958
Next k06959
TextoModelo & = ";" & vbCrLf 'fin línea y salto de línea06960
06961
'Enseña el modelo para debugging06962
'MsgBox(TextoModelo, MsgBoxStyle.Information, "Modelo .LP")06963
06964
'fin tiempo06965
Dim Tiempo As System . TimeSpan = Now . Subtract ( TInicio )06966
'TiempoModelado = Tiempo.Milliseconds06967
06968
TiempoModelado = DateDiff ( DateInterval . Second , TInicio , Now )06969
06970
'-------------------------------06971
'FASE 2: GRABA FICHERO .LP06972
'-------------------------------06973
06974
EscribeFicheroTexto ( CurDir () & "\GrafosLP~.lp" , "" )06975
EscribeFicheroTexto ( CurDir () & "\GrafosLP~.lp" , TextoModelo )06976
06977
'FASE 2_ALT: MODELO EN MEMORIA06978
' - de momento descartado -06979
06980
'---------------------------06981
'FASE 3: RESOLVER06982
'FASE 4: GUARDAR SOLUCIÓN06983
'FASE 4B: TRADUCIR SOLUCIÓN06984
'---------------------------06985
ResuelveFichero_GrafosLP ( CurDir () & "\GrafosLP~.lp" , "PROBLEMA DEL» VIAJANTE DE COMERCIO" )
06986
06987
06988
'---------------------------------------06989
'FASE 5:MOSTRAR AL USUARIO SOLUCIÓN06990
'---------------------------------------06991
'Representación gráfica del recorrido solución06992
AlgoritmoMILP = True06993
06994
CopiaGrafoPrevio ()06995
06996
Dim vd As Long06997
vd = 006998
For k = 0 To TotalArcos - 106999
Arcos ( k ) . Col = Color . Black07000
Arcos ( k ) . Grosor = Grafico . TrazoArco07001
07002
'Se ignoran arcos que entren y salgan de un mismo nodo07003
If Arcos ( k ) . Nd1 <> Arcos ( k ) . Nd2 Then07004
vd = vd + 107005
If SolucionModeloLP ( vd ) = 1 Then07006
Arcos ( k ) . Col = Color . Green07007
Arcos ( k ) . Grosor = Arcos ( k ) . Grosor + 107008
End If07009
End If07010
Next k07011
DibujaGrafo ()07012
07013
CopiaGrafoSolucion ()07014
MuestraCajaSolucion ()07015
Me . Cursor = Cursors . Default07016
End Sub07017
Protected Overrides Sub Finalize ()07018
' lpsolve = Nothing07019
MyBase . Finalize ()07020
End Sub07021
07022
07023
Sub MuestraCajaSolucion ()07024
'variable que será leída por form607025
txtResultadosAlgoritmo = txtResultadosAlgoritmo & vbCrLf & "(cc)» 2003..2005 - Alejandro Rodríguez Villalobos"
07026
'Muestra el formulario de respuesta07027
CajaSolucion . txtResultados . Text = txtResultadosAlgoritmo07028
CajaSolucion . txtResultados . SelectionLength = 007029
CajaSolucion . WindowState = FormWindowState . Normal07030
CajaSolucion . StartPosition = FormStartPosition . CenterParent07031
'Pulsador de mostrar solución gráfica por defecto activado07032
CajaSolucion . btnSolucionGrafo . Pushed = True07033
'Pulsador de resultados07034
CajaSolucion . btnVerResultados . Pushed = True07035
CajaSolucion . btnVerLP . Pushed = False07036
CajaSolucion . btnVerMPS . Pushed = False07037
07038
'habilita o deshabilita ver los modelos LP07039
If AlgoritmoMILP = True Then07040
CajaSolucion . btnVerLP . Enabled = True07041
CajaSolucion . btnVerMPS . Enabled = True07042
Else07043
CajaSolucion . btnVerLP . Enabled = False07044
CajaSolucion . btnVerMPS . Enabled = False07045
End If07046
07047
'la caja solución está por encima del resto de controles07048
CajaSolucion . TopMost = True07049
CajaSolucion . Visible = True07050
End Sub07051
07052
Private Sub mnuFormatoOrganico_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoOrganico . Click
07053
07054
mnuFormatoAleatorio . Checked = False07055
mnuFormatoTablero . Checked = False07056
mnuFormatoCircular . Checked = False07057
mnuFormatoFlujo . Checked = False07058
mnuFormatoOrganico . Checked = True07059
If TotalNodos < 2 Or TotalArcos < 1 Then Exit Sub07060
07061
'pide antes confirmación07062
Dim respuesta As MsgBoxResult07063
respuesta = MsgBox ( "Esta opción cambiará la ubicación de los nodos hacia» una representación orgánica." & vbCrLf & "¿Desea realmente reordenar
» los nodos?" , MsgBoxStyle . OKCancel , )
07064
If respuesta = MsgBoxResult . Cancel Then Exit Sub07065
Me . Cursor = Cursors . WaitCursor07066
OrdenaenForceDirect ()07067
If Grafico . Iman Then Imantar ()07068
DibujaGrafo ()07069
Me . Cursor = Cursors . Default07070
End Sub07071
Private Sub CajaPropiedades_ActualizaGrafo ( ByVal valor As Boolean ) Handles» CajaPropiedades . ActualizaGrafo
07072
'si se aplican cambios en las opciones de formato gráfico07073
'se debe redibujar el grafo07074
If valor = True Then DibujaGrafo ()07075
End Sub07076
Private Sub CajaPropiedades_ActualizaMenu () Handles CajaPropiedades .» ActualizaMenu
07077
'cuando se 'cierra' = invisible la caja de propiedades07078
'se debe actualizar su menú07079
If CajaPropiedades . Visible = False Then07080
mnuFormatoOpciones . Enabled = True07081
Else07082
mnuFormatoOpciones . Enabled = False07083
End If07084
07085
mnuFormatoIman . Checked = Grafico . Iman07086
mnuFormatoRejilla . Checked = Grafico . MostrarRejilla07087
07088
End Sub07089
Private Sub mnuFormatoImantar_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoImantar . Click
07090
'Ajusta la distribución de los nodos del grafo07091
'a la configuración de la rejilla07092
'moviendo en x e y cada nodo para que coincida07093
'con la rejilla07094
Imantar ()07095
DibujaGrafo ()07096
End Sub07097
Sub Imantar ()07098
'Ajusta la distribución de los nodos del grafo07099
'a la configuración de la rejilla07100
'moviendo en x e y cada nodo para que coincida07101
'con la rejilla07102
Dim u As Long07103
For u = 0 To TotalNodos - 107104
Nodos ( u ) . X = Int (( Nodos ( u ) . X + Nodos ( u ) . Radio ) / Grafico . Rejilla )» * Grafico . Rejilla
07105
Nodos ( u ) . Y = Int (( Nodos ( u ) . Y + Nodos ( u ) . Radio ) / Grafico . Rejilla )» * Grafico . Rejilla
07106
Next u07107
End Sub07108
Private Sub mnuArchivoExportarDatos_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuArchivoExportarDatos . Click
07109
'Muestra el formulario de opciones de Exportar datos07110
If mnuEdicionTabular . Checked = False Then07111
'si hay datos para exportar07112
If TotalNodos = 0 Then07113
'no podemos exportar nada si no hay nodos07114
MsgBox ( "No existen datos del grafo para exportar. Primero debe» crear al menos un nodo del grafo." , MsgBoxStyle . Exclamation ,
» "Grafos - Información" )
07115
Exit Sub07116
End If07117
07118
CajaExportar . Visible = True07119
End If07120
End Sub07121
Private Sub mnuArchivoImportarDatos_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuArchivoImportarDatos . Click
07122
'menu archivo exportar datos07123
If mnuEdicionTabular . Checked = False Then07124
CajaImportar . Visible = True07125
End If07126
End Sub07127
Private Sub CajaImportar_ActualizaGrafo ( ByVal valor As Boolean ) Handles» CajaImportar . ActualizaGrafo
07128
'si se importan datos07129
'se debe redibujar el grafo07130
If valor = True Then DibujaGrafo ()07131
End Sub07132
Private Sub mnuArchivoNuevoAleatorio_Click ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles mnuArchivoNuevoAleatorio . Click
07133
If TotalNodos > 0 Or NodosMatriz > 0 Then07134
Dim respuesta As MsgBoxResult07135
respuesta = MsgBox ( " Si no ha grabado las últimas modificaciones,» perderá los datos actuales." & vbCrLf & " ¿Desea realmente crear
» un nuevo grafo?" , MsgBoxStyle . OKCancel , )
07136
If respuesta = MsgBoxResult . Cancel Then Exit Sub07137
End If07138
07139
07140
CajaNuevoAleatorio . Visible = True07141
07142
07143
End Sub07144
Private Sub CajaNuevoAleatorio_ActualizaGrafo ( ByVal valor As Boolean , ByVal» n As Long , ByVal a As Long , ByVal r As Boolean ) Handles
» CajaNuevoAleatorio . ActualizaGrafo
07145
07146
If valor = False Then Exit Sub07147
07148
'Crea nuevo grafo aleatorio07149
07150
'nombre del fichero en estatus bar07151
Me . StatusBar . Panels ( 6 ) . Text = ""07152
07153
'lee las opciones por defecto07154
OpcionesporDefecto ()07155
07156
'Cambia y posiciona el picturebox07157
PictureBox1 . Top = 007158
PictureBox1 . Left = 007159
PictureBox1 . Width = Grafico . TapizX * Grafico . Zoom07160
PictureBox1 . Height = Grafico . TapizX * Grafico . Zoom07161
07162
TotalNodos = 007163
TotalArcos = 007164
NodosMatriz = 007165
CreaGrafoAleatorio ( n , a , r )07166
07167
'no selecciona ningún nodo07168
Nd1S = - 107169
Nd2S = - 107170
07171
'Llama al proceso principal de dibujar grafo07172
DibujaGrafo ()07173
Grafico . Fichero = ""07174
Grafico . Extension = ".graphML" 'extensión por defecto .graphML07175
07176
PictureBox1 . Visible = True07177
ActivaMenus ()07178
07179
End Sub07180
Private Sub LeeFicheroGRF ( ByVal fichero As String )07181
'Esta rutina es la encargada de leer el fichero de extensión .grf07182
'e introducir los datos en las colecciones del grafo07183
07184
'Abre el fichero para leer07185
Try07186
FileOpen ( 1 , fichero , OpenMode . Input , OpenAccess . Read )07187
07188
Dim A , R , G , B As Integer07189
Dim CADENA As String07190
07191
Input ( 1 , CADENA ) 'copyright07192
Input ( 1 , CADENA ) 'versión del fichero07193
07194
'Opciones generales07195
Input ( 1 , Grafico . Zoom )07196
Input ( 1 , Grafico . Rejilla )07197
Input ( 1 , Grafico . TapizX )07198
Input ( 1 , Grafico . TapizY )07199
07200
Input ( 1 , A )07201
Input ( 1 , R )07202
Input ( 1 , G )07203
Input ( 1 , B )07204
Grafico . ColorRejilla = Color . FromArgb ( A , R , G , B )07205
07206
Input ( 1 , A )07207
Input ( 1 , R )07208
Input ( 1 , G )07209
Input ( 1 , B )07210
Grafico . ColorTapiz = Color . FromArgb ( A , R , G , B )07211
07212
'nodo07213
Dim n As String07214
Dim t As Single07215
Dim v As Integer07216
07217
Input ( 1 , n )07218
Input ( 1 , t )07219
Input ( 1 , v )07220
07221
Dim F As New Font ( n , t , v , GraphicsUnit . Pixel )07222
07223
Grafico . Fuente = F07224
07225
Input ( 1 , Grafico . TrazoNodo )07226
Input ( 1 , Grafico . RadioNodo )07227
07228
Input ( 1 , A )07229
Input ( 1 , R )07230
Input ( 1 , G )07231
Input ( 1 , B )07232
Grafico . ColNodo = Color . FromArgb ( A , R , G , B )07233
07234
07235
Input ( 1 , Grafico . textoNodo )07236
Input ( 1 , Grafico . costNodo )07237
07238
'arco07239
Input ( 1 , Grafico . minArco )07240
Input ( 1 , Grafico . maxArco )07241
Input ( 1 , Grafico . costArco )07242
Input ( 1 , Grafico . TrazoArco )07243
Input ( 1 , Grafico . BArco )07244
07245
Input ( 1 , A )07246
Input ( 1 , R )07247
Input ( 1 , G )07248
Input ( 1 , B )07249
Grafico . ColArco = Color . FromArgb ( A , R , G , B )07250
07251
07252
'---------07253
Input ( 1 , TotalNodos ) 'número de nodos07254
Input ( 1 , TotalArcos ) 'número de arcos07255
ReDim Nodos ( TotalNodos - 1 )07256
ReDim Arcos ( TotalArcos - 1 )07257
07258
Dim i As Long07259
07260
For i = 0 To TotalNodos - 107261
Input ( 1 , Nodos ( i ) . Texto )07262
Input ( 1 , Nodos ( i ) . X )07263
Input ( 1 , Nodos ( i ) . Y )07264
Input ( 1 , Nodos ( i ) . Valor )07265
Input ( 1 , Nodos ( i ) . Radio )07266
Input ( 1 , Nodos ( i ) . Grosor )07267
07268
Input ( 1 , A )07269
Input ( 1 , R )07270
Input ( 1 , G )07271
Input ( 1 , B )07272
Nodos ( i ) . Col = Color . FromArgb ( A , R , G , B )07273
07274
Next i07275
For i = 0 To TotalArcos - 107276
Input ( 1 , Arcos ( i ) . Min )07277
Input ( 1 , Arcos ( i ) . Max )07278
Input ( 1 , Arcos ( i ) . Coste )07279
Input ( 1 , Arcos ( i ) . Nd1 )07280
Input ( 1 , Arcos ( i ) . Nd2 )07281
Input ( 1 , Arcos ( i ) . B )07282
Input ( 1 , Arcos ( i ) . Texto )07283
07284
Input ( 1 , A )07285
Input ( 1 , R )07286
Input ( 1 , G )07287
Input ( 1 , B )07288
Arcos ( i ) . Col = Color . FromArgb ( A , R , G , B )07289
07290
Input ( 1 , Arcos ( i ) . Grosor )07291
Next i07292
'Extensión del fichero en formato propietario .grf07293
Grafico . Extension = ".grf"07294
'Intercepción de posibles errores en el fichero07295
Catch ex As Exception07296
Me . Cursor = Cursors . Default07297
MsgBox ( "Ha fallado la operación de abrir fichero .grf" & vbCrLf & ex» . Message , MsgBoxStyle . Exclamation , "Grafos - Excepción" )
07298
Exit Sub07299
Finally07300
FileClose ( 1 )07301
07302
End Try07303
07304
End Sub07305
Private Sub LeeFicheroGraphML ( ByVal fichero As String )07306
'Esta rutina es la encargada de leer el fichero de extensión .graphML07307
'con una estructura de datos XML07308
'e introducir los datos en las colecciones del grafo07309
07310
'Define varibles de lectura del fichero y de validación07311
Dim reader As XmlTextReader = New XmlTextReader ( fichero )07312
07313
'------------------------------------------------------------------07314
'VALIDACIÓN07315
'------------------------------------------------------------------07316
''Este trozo de código y el EventoValidacionXML07317
''Son necesarios para la validación del XML07318
''### Está deshabilitado ya que posiblemente son más problemas que07319
''### ventajas07320
'Dim v As New XmlValidatingReader(reader)07321
''Define evento de validación07322
'AddHandler v.ValidationEventHandler, AddressOf EventoValidacionXML07323
''tipo de validación por esquema07324
'v.ValidationType = ValidationType.Schema07325
''Abre el fichero para leerlo07326
''Es válido por defecto07327
'XMLValido = True07328
''Intento de validación a través de la web07329
'While v.Read07330
' 'aquí se podría añadir código para procesar el contenido07331
' 'si el documento no es válido se generará el evento de error07332
' 'donde se cambia el valor por defecto de XMLValido07333
'End While07334
'v.Close()07335
''Comprobación validación final07336
'If XMLValido Then07337
' 'xml es válido07338
'Else07339
' 'xml no es válido07340
' 'en la consola aparecen los errores07341
'End If07342
07343
'------------------------------------------------------------------07344
'LECTURA E INTERPRETACIÓN07345
'------------------------------------------------------------------07346
'Variables de estado en el árbol xml07347
Dim DNodo As Boolean = False07348
Dim DArco As Boolean = False07349
Dim DGrafo As Boolean = False07350
Dim DGrafico As Boolean = True07351
'para el tipo de letra07352
Dim n As String07353
Dim t As Single07354
Dim v As Integer07355
'para el color07356
Dim A , R , G , B As Integer07357
'para pasar el valor07358
Dim valor As String07359
07360
'Comienza el proceso de lectura del07361
Try07362
Do While ( reader . Read ())07363
Select Case reader . NodeType07364
Case XmlNodeType . Element07365
'Muestra el comienzo de un elemento.07366
'Console.Write("<" + reader.Name)07367
07368
'Se detecta el comienzo de la definición07369
If reader . Name = "graph" Then07370
DGrafo = True07371
DGrafico = False07372
'Borra el grafo actual07373
TotalNodos = 007374
TotalArcos = 007375
ReDim Arcos ( 0 )07376
ReDim Nodos ( 0 )07377
End If07378
07379
If reader . Name = "node" Then07380
DNodo = True07381
DGrafico = False07382
TotalNodos = TotalNodos + 107383
ReDim Preserve Nodos ( TotalNodos - 1 )07384
End If07385
07386
If reader . Name = "edge" Then07387
DArco = True07388
DGrafico = False07389
TotalArcos = TotalArcos + 107390
ReDim Preserve Arcos ( TotalArcos - 1 )07391
End If07392
07393
If reader . HasAttributes Then07394
'Si tiene atributos07395
While reader . MoveToNextAttribute ()07396
'Muestra el nombre del atributo y su valor07397
'Console.Write(" {0}='{1}'", reader.Name,» reader.Value)
07398
07399
'Atributos del Grafo07400
'If DGrafo = True Then07401
' If reader.Name = "parse.nodes" Then07402
' TotalNodos = reader.Value07403
' End If07404
' If reader.Name = "parse.edges" Then07405
' TotalArcos = reader.Value07406
' End If07407
'End If07408
07409
'Atributos del grafico07410
If DGrafico = True And reader . Name = "id" Then07411
valor = reader . Value07412
End If07413
07414
'Atributos del Nodo07415
If DNodo = True And reader . Name = "key" Then07416
valor = reader . Value07417
End If07418
'Atributos del Arco07419
If DArco = True And reader . Name = "source"» Then
07420
Arcos ( TotalArcos - 1 ) . Nd1 = Val ( reader .» Value . ToString . Remove ( 0 , 1 ))
07421
End If07422
If DArco = True And reader . Name = "target"» Then
07423
Arcos ( TotalArcos - 1 ) . Nd2 = Val ( reader .» Value . ToString . Remove ( 0 , 1 ))
07424
End If07425
If DArco = True And reader . Name = "key" Then07426
valor = reader . Value07427
End If07428
07429
End While07430
End If07431
'Console.WriteLine(">")07432
Case XmlNodeType . Text07433
'Muestra el texto de cada elemento.07434
'Console.WriteLine(reader.Value)07435
07436
07437
'Atributos del grafico07438
If DGrafico = True Then07439
'Tapiz por defecto07440
If valor = "GvZ" Then07441
Grafico . Zoom = reader . Value07442
End If07443
If valor = "GvR" Then07444
Grafico . Rejilla = reader . Value07445
End If07446
If valor = "GvMR" Then07447
Grafico . MostrarRejilla = reader . Value07448
End If07449
If valor = "GvI" Then07450
Grafico . Iman = reader . Value07451
End If07452
If valor = "GtX" Then07453
Grafico . TapizX = reader . Value07454
End If07455
If valor = "GtY" Then07456
Grafico . TapizY = reader . Value07457
End If07458
'Color rejilla07459
If valor = "GrCA" Then07460
A = reader . Value07461
End If07462
If valor = "GrCR" Then07463
R = reader . Value07464
End If07465
If valor = "GrCG" Then07466
G = reader . Value07467
End If07468
If valor = "GrCB" Then07469
B = reader . Value07470
Grafico . ColorRejilla = Color . FromArgb ( A , R , G» , B )
07471
End If07472
'Color tapiz07473
If valor = "GtCA" Then07474
A = reader . Value07475
End If07476
If valor = "GtCR" Then07477
R = reader . Value07478
End If07479
If valor = "GtCG" Then07480
G = reader . Value07481
End If07482
If valor = "GtCB" Then07483
B = reader . Value07484
Grafico . ColorTapiz = Color . FromArgb ( A , R , G ,» B )
07485
End If07486
'Tipo de letra07487
If valor = "GfN" Then07488
n = reader . Value07489
End If07490
If valor = "GfS" Then07491
t = reader . Value07492
End If07493
If valor = "GfSt" Then07494
v = reader . Value07495
Dim F As New Font ( n , t , v , GraphicsUnit . Pixel» )
07496
Grafico . Fuente = F07497
End If07498
'Nodo por defecto07499
If valor = "GnT" Then07500
Grafico . textoNodo = reader . Value07501
End If07502
If valor = "GnV" Then07503
Grafico . costNodo = reader . Value07504
End If07505
If valor = "GnR" Then07506
Grafico . RadioNodo = reader . Value07507
End If07508
If valor = "GnG" Then07509
Grafico . TrazoNodo = reader . Value07510
End If07511
If valor = "GnCA" Then07512
A = reader . Value07513
End If07514
If valor = "GnCR" Then07515
R = reader . Value07516
End If07517
If valor = "GnCG" Then07518
G = reader . Value07519
End If07520
If valor = "GnCB" Then07521
B = reader . Value07522
Grafico . ColNodo = Color . FromArgb ( A , R , G , B )07523
End If07524
'Arco por defecto07525
If valor = "GaMin" Then07526
Grafico . minArco = reader . Value07527
End If07528
If valor = "GaMax" Then07529
Grafico . maxArco = reader . Value07530
End If07531
If valor = "GaC" Then07532
Grafico . costArco = reader . Value07533
End If07534
If valor = "GaB" Then07535
Grafico . BArco = reader . Value07536
End If07537
If valor = "GaG" Then07538
Grafico . TrazoArco = reader . Value07539
End If07540
07541
If valor = "GnCA" Then07542
A = reader . Value07543
End If07544
If valor = "GnCR" Then07545
R = reader . Value07546
End If07547
If valor = "GnCG" Then07548
G = reader . Value07549
End If07550
If valor = "GnCB" Then07551
B = reader . Value07552
Grafico . ColNodo = Color . FromArgb ( A , R , G , B )07553
End If07554
07555
07556
End If07557
07558
'Atributos de nodos07559
If DNodo = True Then07560
If valor = "nT" Then07561
Nodos ( TotalNodos - 1 ) . Texto = reader . Value07562
End If07563
If valor = "nX" Then07564
Nodos ( TotalNodos - 1 ) . X = reader . Value07565
End If07566
If valor = "nY" Then07567
Nodos ( TotalNodos - 1 ) . Y = reader . Value07568
End If07569
If valor = "nZ" Then07570
Nodos ( TotalNodos - 1 ) . Z = reader . Value07571
End If07572
If valor = "nV" Then07573
Nodos ( TotalNodos - 1 ) . Valor = reader . Value07574
End If07575
If valor = "nR" Then07576
Nodos ( TotalNodos - 1 ) . Radio = reader . Value07577
End If07578
If valor = "nG" Then07579
Nodos ( TotalNodos - 1 ) . Grosor = reader . Value07580
End If07581
If valor = "nCA" Then07582
A = reader . Value07583
End If07584
If valor = "nCR" Then07585
R = reader . Value07586
End If07587
If valor = "nCG" Then07588
G = reader . Value07589
End If07590
If valor = "nCB" Then07591
B = reader . Value07592
Nodos ( TotalNodos - 1 ) . Col = Color . FromArgb ( A ,» R , G , B )
07593
End If07594
End If07595
07596
'Atributos de arcos07597
If DArco = True Then07598
If valor = "aT" Then07599
Arcos ( TotalArcos - 1 ) . Texto = reader . Value07600
End If07601
If valor = "aMin" Then07602
Arcos ( TotalArcos - 1 ) . Min = reader . Value07603
End If07604
If valor = "aMax" Then07605
Arcos ( TotalArcos - 1 ) . Max = reader . Value07606
End If07607
If valor = "aC" Then07608
Arcos ( TotalArcos - 1 ) . Coste = reader . Value07609
End If07610
If valor = "aB" Then07611
Arcos ( TotalArcos - 1 ) . B = reader . Value07612
End If07613
If valor = "aG" Then07614
Arcos ( TotalArcos - 1 ) . Grosor = reader . Value07615
End If07616
If valor = "aCA" Then07617
A = reader . Value07618
End If07619
If valor = "aCR" Then07620
R = reader . Value07621
End If07622
If valor = "aCG" Then07623
G = reader . Value07624
End If07625
If valor = "aCB" Then07626
B = reader . Value07627
Arcos ( TotalArcos - 1 ) . Col = Color . FromArgb ( A ,» R , G , B )
07628
End If07629
End If07630
07631
Case XmlNodeType . EndElement07632
'Muestra el final del elemento.07633
'Console.Write("</" + reader.Name)07634
'Console.WriteLine(">")07635
07636
'Se detecta el final de la definición07637
If reader . Name = "graph" Then DGrafo = False07638
If reader . Name = "node" Then DNodo = False07639
If reader . Name = "edge" Then DArco = False07640
End Select07641
Loop07642
'Console.ReadLine()07643
07644
reader . Close ()07645
07646
'Extensión del fichero en formato propietario .grf07647
Grafico . Extension = ".graphML"07648
'Intercepción de posibles errores en el fichero07649
Catch ex As Exception07650
Me . Cursor = Cursors . Default07651
MsgBox ( "Ha fallado la operación de abrir fichero .graphML" & vbCrLf» & ex . Message , MsgBoxStyle . Exclamation , "Grafos - Excepción" )
07652
Exit Sub07653
Finally07654
End Try07655
07656
End Sub07657
'Public Sub EventoValidacionXML(ByVal sender As Object, ByVal args As» System.Xml.Schema.ValidationEventArgs)
07658
' 'Este evento ocurre al intentar validar un fichero XML (Abrir .graphML)07659
' XMLValido = False07660
' Console.WriteLine("Validación XML = " & vbCrLf & args.Message)07661
'End Sub07662
07663
Private Sub mnuFormatoAutoRadio_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoAutoRadio . Click
07664
'Auto-radio nodos (valor)07665
If TotalNodos = 0 Then Exit Sub07666
07667
'pide antes confirmación07668
Dim respuesta As MsgBoxResult07669
respuesta = MsgBox ( "Esta opción cambiará el radio de los nodos» proporcionalmente a su valor." & vbCrLf & "¿Desea realmente aplicar
» cambios en el diseño?" , MsgBoxStyle . OKCancel , )
07670
If respuesta = MsgBoxResult . Cancel Then Exit Sub07671
07672
Dim i As Long07673
Dim suma As Double = 007674
07675
For i = 0 To TotalNodos - 107676
suma = suma + Nodos ( i ) . Valor07677
Next i07678
For i = 0 To TotalNodos - 107679
Nodos ( i ) . Radio = Math . Round (( Nodos ( i ) . Valor / suma ) * ( 50 - 15 ) +» 15 )
07680
Next i07681
DibujaGrafo ()07682
07683
End Sub07684
07685
Private Sub mnuFormatoAutoTrazo_Click ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles mnuFormatoAutoTrazo . Click
07686
'Auto-trazo arcos (coste)07687
If TotalArcos = 0 Then Exit Sub07688
07689
'pide antes confirmación07690
Dim respuesta As MsgBoxResult07691
respuesta = MsgBox ( "Esta opción cambiará el grosor del trazo de los» arcos proporcionalmente a su coste." & vbCrLf & "¿Desea realmente
» aplicar cambios en el diseño?" , MsgBoxStyle . OKCancel , )
07692
If respuesta = MsgBoxResult . Cancel Then Exit Sub07693
07694
Dim i As Long07695
Dim suma As Double = 007696
07697
For i = 0 To TotalArcos - 107698
suma = suma + Arcos ( i ) . Coste07699
Next i07700
For i = 0 To TotalNodos - 107701
Arcos ( i ) . Grosor = Math . Round (( Arcos ( i ) . Coste / suma ) * ( 8 - 1 ) + 1» )
07702
Next i07703
DibujaGrafo ()07704
07705
End Sub07706
07707
07708
Private Sub CajaSolucion_ActualizaGrafo ( ByVal valor As Boolean ) Handles» CajaSolucion . ActualizaGrafo
07709
'Se responde al evento de dibujar solución desde la caja de solución07710
If valor = True Then07711
DibujaGrafo ()07712
Me . Refresh ()07713
End If07714
End Sub07715
End Class00001
Public Class Form200002
Inherits System . Windows . Forms . Form00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'Form reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
Friend WithEvents TabControl1 As System . Windows . Forms . TabControl00033
Friend WithEvents TabPage1 As System . Windows . Forms . TabPage00034
Friend WithEvents TabPage2 As System . Windows . Forms . TabPage00035
Friend WithEvents TabPage3 As System . Windows . Forms . TabPage00036
Friend WithEvents udTrazoArco As System . Windows . Forms . NumericUpDown00037
Friend WithEvents Label2 As System . Windows . Forms . Label00038
Friend WithEvents chkBArco As System . Windows . Forms . CheckBox00039
Friend WithEvents GroupBox2 As System . Windows . Forms . GroupBox00040
Friend WithEvents lblColorArco As System . Windows . Forms . Label00041
Friend WithEvents btnColorArco As System . Windows . Forms . Button00042
Friend WithEvents GroupBox4 As System . Windows . Forms . GroupBox00043
Friend WithEvents Label3 As System . Windows . Forms . Label00044
Friend WithEvents lblColorNodo As System . Windows . Forms . Label00045
Friend WithEvents btnColorNodo As System . Windows . Forms . Button00046
Friend WithEvents udTrazoNodo As System . Windows . Forms . NumericUpDown00047
Friend WithEvents udRadioNodo As System . Windows . Forms . NumericUpDown00048
Friend WithEvents Label4 As System . Windows . Forms . Label00049
Friend WithEvents FontDialog1 As System . Windows . Forms . FontDialog00050
Friend WithEvents btnAplicar As System . Windows . Forms . Button00051
Friend WithEvents btnAplicarNuevos As System . Windows . Forms . Button00052
Friend WithEvents btnRestaurar As System . Windows . Forms . Button00053
Friend WithEvents udTapizX As System . Windows . Forms . NumericUpDown00054
Friend WithEvents udTapizY As System . Windows . Forms . NumericUpDown00055
Friend WithEvents btnColorTapiz As System . Windows . Forms . Button00056
Friend WithEvents GroupBox7 As System . Windows . Forms . GroupBox00057
Friend WithEvents Label7 As System . Windows . Forms . Label00058
Friend WithEvents Label8 As System . Windows . Forms . Label00059
Friend WithEvents btnCancelar As System . Windows . Forms . Button00060
Friend WithEvents TabPage4 As System . Windows . Forms . TabPage00061
Friend WithEvents GroupBox6 As System . Windows . Forms . GroupBox00062
Friend WithEvents btnColorRejilla As System . Windows . Forms . Button00063
Friend WithEvents udRejilla As System . Windows . Forms . NumericUpDown00064
Friend WithEvents lblColorRejilla As System . Windows . Forms . Label00065
Friend WithEvents Label5 As System . Windows . Forms . Label00066
Friend WithEvents chkMostrarRejilla As System . Windows . Forms . CheckBox00067
Friend WithEvents chkIman As System . Windows . Forms . CheckBox00068
Friend WithEvents TabPage5 As System . Windows . Forms . TabPage00069
Friend WithEvents lblFuente As System . Windows . Forms . Label00070
Friend WithEvents btnFuente As System . Windows . Forms . Button00071
Friend WithEvents Label1 As System . Windows . Forms . Label00072
Friend WithEvents udZoom As System . Windows . Forms . NumericUpDown00073
Friend WithEvents pbNodo As System . Windows . Forms . PictureBox00074
Friend WithEvents GroupBox3 As System . Windows . Forms . GroupBox00075
Friend WithEvents chktxtNodo As System . Windows . Forms . CheckBox00076
Friend WithEvents chkcostNodo As System . Windows . Forms . CheckBox00077
Friend WithEvents pbArco As System . Windows . Forms . PictureBox00078
Friend WithEvents GroupBox1 As System . Windows . Forms . GroupBox00079
Friend WithEvents chkminArco As System . Windows . Forms . CheckBox00080
Friend WithEvents chkmaxArco As System . Windows . Forms . CheckBox00081
Friend WithEvents chkcostArco As System . Windows . Forms . CheckBox00082
Friend WithEvents lblColorTapiz As System . Windows . Forms . PictureBox00083
Friend WithEvents chkTapizImagen As System . Windows . Forms . CheckBox00084
Friend WithEvents btnImagenTapiz As System . Windows . Forms . Button00085
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00086
Me . TabControl1 = New System . Windows . Forms . TabControl00087
Me . TabPage1 = New System . Windows . Forms . TabPage00088
Me . GroupBox7 = New System . Windows . Forms . GroupBox00089
Me . Label1 = New System . Windows . Forms . Label00090
Me . udZoom = New System . Windows . Forms . NumericUpDown00091
Me . udTapizX = New System . Windows . Forms . NumericUpDown00092
Me . btnColorTapiz = New System . Windows . Forms . Button00093
Me . Label7 = New System . Windows . Forms . Label00094
Me . udTapizY = New System . Windows . Forms . NumericUpDown00095
Me . Label8 = New System . Windows . Forms . Label00096
Me . TabPage3 = New System . Windows . Forms . TabPage00097
Me . GroupBox2 = New System . Windows . Forms . GroupBox00098
Me . GroupBox1 = New System . Windows . Forms . GroupBox00099
Me . chkminArco = New System . Windows . Forms . CheckBox00100
Me . chkmaxArco = New System . Windows . Forms . CheckBox00101
Me . chkcostArco = New System . Windows . Forms . CheckBox00102
Me . pbArco = New System . Windows . Forms . PictureBox00103
Me . udTrazoArco = New System . Windows . Forms . NumericUpDown00104
Me . Label2 = New System . Windows . Forms . Label00105
Me . chkBArco = New System . Windows . Forms . CheckBox00106
Me . btnColorArco = New System . Windows . Forms . Button00107
Me . lblColorArco = New System . Windows . Forms . Label00108
Me . TabPage2 = New System . Windows . Forms . TabPage00109
Me . GroupBox4 = New System . Windows . Forms . GroupBox00110
Me . GroupBox3 = New System . Windows . Forms . GroupBox00111
Me . chktxtNodo = New System . Windows . Forms . CheckBox00112
Me . chkcostNodo = New System . Windows . Forms . CheckBox00113
Me . pbNodo = New System . Windows . Forms . PictureBox00114
Me . Label4 = New System . Windows . Forms . Label00115
Me . udRadioNodo = New System . Windows . Forms . NumericUpDown00116
Me . udTrazoNodo = New System . Windows . Forms . NumericUpDown00117
Me . Label3 = New System . Windows . Forms . Label00118
Me . lblColorNodo = New System . Windows . Forms . Label00119
Me . btnColorNodo = New System . Windows . Forms . Button00120
Me . TabPage4 = New System . Windows . Forms . TabPage00121
Me . GroupBox6 = New System . Windows . Forms . GroupBox00122
Me . chkIman = New System . Windows . Forms . CheckBox00123
Me . chkMostrarRejilla = New System . Windows . Forms . CheckBox00124
Me . btnColorRejilla = New System . Windows . Forms . Button00125
Me . udRejilla = New System . Windows . Forms . NumericUpDown00126
Me . lblColorRejilla = New System . Windows . Forms . Label00127
Me . Label5 = New System . Windows . Forms . Label00128
Me . TabPage5 = New System . Windows . Forms . TabPage00129
Me . lblFuente = New System . Windows . Forms . Label00130
Me . btnFuente = New System . Windows . Forms . Button00131
Me . FontDialog1 = New System . Windows . Forms . FontDialog00132
Me . btnAplicar = New System . Windows . Forms . Button00133
Me . btnAplicarNuevos = New System . Windows . Forms . Button00134
Me . btnRestaurar = New System . Windows . Forms . Button00135
Me . btnCancelar = New System . Windows . Forms . Button00136
Me . lblColorTapiz = New System . Windows . Forms . PictureBox00137
Me . chkTapizImagen = New System . Windows . Forms . CheckBox00138
Me . btnImagenTapiz = New System . Windows . Forms . Button00139
Me . TabControl1 . SuspendLayout ()00140
Me . TabPage1 . SuspendLayout ()00141
Me . GroupBox7 . SuspendLayout ()00142
CType ( Me . udZoom , System . ComponentModel . ISupportInitialize ) . BeginInit ()00143
CType ( Me . udTapizX , System . ComponentModel . ISupportInitialize ) . BeginInit ()00144
CType ( Me . udTapizY , System . ComponentModel . ISupportInitialize ) . BeginInit ()00145
Me . TabPage3 . SuspendLayout ()00146
Me . GroupBox2 . SuspendLayout ()00147
Me . GroupBox1 . SuspendLayout ()00148
CType ( Me . udTrazoArco , System . ComponentModel . ISupportInitialize ) .» BeginInit ()
00149
Me . TabPage2 . SuspendLayout ()00150
Me . GroupBox4 . SuspendLayout ()00151
Me . GroupBox3 . SuspendLayout ()00152
CType ( Me . udRadioNodo , System . ComponentModel . ISupportInitialize ) .» BeginInit ()
00153
CType ( Me . udTrazoNodo , System . ComponentModel . ISupportInitialize ) .» BeginInit ()
00154
Me . TabPage4 . SuspendLayout ()00155
Me . GroupBox6 . SuspendLayout ()00156
CType ( Me . udRejilla , System . ComponentModel . ISupportInitialize ) . BeginInit (» )
00157
Me . TabPage5 . SuspendLayout ()00158
Me . SuspendLayout ()00159
'00160
'TabControl100161
'00162
Me . TabControl1 . Anchor = CType ((( System . Windows . Forms . AnchorStyles . Top Or» System . Windows . Forms . AnchorStyles . Left ) _
00163
Or System . Windows . Forms . AnchorStyles . Right ), System . Windows» . Forms . AnchorStyles )
00164
Me . TabControl1 . Controls . Add ( Me . TabPage1 )00165
Me . TabControl1 . Controls . Add ( Me . TabPage3 )00166
Me . TabControl1 . Controls . Add ( Me . TabPage2 )00167
Me . TabControl1 . Controls . Add ( Me . TabPage4 )00168
Me . TabControl1 . Controls . Add ( Me . TabPage5 )00169
Me . TabControl1 . Location = New System . Drawing . Point ( 0 , 0 )00170
Me . TabControl1 . Name = "TabControl1"00171
Me . TabControl1 . SelectedIndex = 000172
Me . TabControl1 . Size = New System . Drawing . Size ( 370 , 215 )00173
Me . TabControl1 . TabIndex = 000174
'00175
'TabPage100176
'00177
Me . TabPage1 . Controls . Add ( Me . GroupBox7 )00178
Me . TabPage1 . Location = New System . Drawing . Point ( 4 , 22 )00179
Me . TabPage1 . Name = "TabPage1"00180
Me . TabPage1 . Size = New System . Drawing . Size ( 362 , 189 )00181
Me . TabPage1 . TabIndex = 000182
Me . TabPage1 . Text = "Tapiz"00183
'00184
'GroupBox700185
'00186
Me . GroupBox7 . Controls . Add ( Me . chkTapizImagen )00187
Me . GroupBox7 . Controls . Add ( Me . lblColorTapiz )00188
Me . GroupBox7 . Controls . Add ( Me . Label1 )00189
Me . GroupBox7 . Controls . Add ( Me . udZoom )00190
Me . GroupBox7 . Controls . Add ( Me . udTapizX )00191
Me . GroupBox7 . Controls . Add ( Me . btnColorTapiz )00192
Me . GroupBox7 . Controls . Add ( Me . Label7 )00193
Me . GroupBox7 . Controls . Add ( Me . udTapizY )00194
Me . GroupBox7 . Controls . Add ( Me . Label8 )00195
Me . GroupBox7 . Controls . Add ( Me . btnImagenTapiz )00196
Me . GroupBox7 . Location = New System . Drawing . Point ( 8 , 8 )00197
Me . GroupBox7 . Name = "GroupBox7"00198
Me . GroupBox7 . Size = New System . Drawing . Size ( 344 , 176 )00199
Me . GroupBox7 . TabIndex = 700200
Me . GroupBox7 . TabStop = False00201
'00202
'Label100203
'00204
Me . Label1 . Location = New System . Drawing . Point ( 248 , 144 )00205
Me . Label1 . Name = "Label1"00206
Me . Label1 . Size = New System . Drawing . Size ( 40 , 24 )00207
Me . Label1 . TabIndex = 2300208
Me . Label1 . Text = "Zoom:"00209
Me . Label1 . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00210
'00211
'udZoom00212
'00213
Me . udZoom . DecimalPlaces = 200214
Me . udZoom . Increment = New Decimal ( New Integer () { 1 , 0 , 0 , 65536 })00215
Me . udZoom . Location = New System . Drawing . Point ( 288 , 144 )00216
Me . udZoom . Maximum = New Decimal ( New Integer () { 4 , 0 , 0 , 0 })00217
Me . udZoom . Minimum = New Decimal ( New Integer () { 2 , 0 , 0 , 65536 })00218
Me . udZoom . Name = "udZoom"00219
Me . udZoom . Size = New System . Drawing . Size ( 48 , 20 )00220
Me . udZoom . TabIndex = 2200221
Me . udZoom . Value = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00222
'00223
'udTapizX00224
'00225
Me . udTapizX . Increment = New Decimal ( New Integer () { 50 , 0 , 0 , 0 })00226
Me . udTapizX . Location = New System . Drawing . Point ( 48 , 144 )00227
Me . udTapizX . Maximum = New Decimal ( New Integer () { 2000 , 0 , 0 , 0 })00228
Me . udTapizX . Minimum = New Decimal ( New Integer () { 100 , 0 , 0 , 0 })00229
Me . udTapizX . Name = "udTapizX"00230
Me . udTapizX . Size = New System . Drawing . Size ( 56 , 20 )00231
Me . udTapizX . TabIndex = 800232
Me . udTapizX . Value = New Decimal ( New Integer () { 800 , 0 , 0 , 0 })00233
'00234
'btnColorTapiz00235
'00236
Me . btnColorTapiz . Location = New System . Drawing . Point ( 256 , 16 )00237
Me . btnColorTapiz . Name = "btnColorTapiz"00238
Me . btnColorTapiz . Size = New System . Drawing . Size ( 80 , 24 )00239
Me . btnColorTapiz . TabIndex = 2000240
Me . btnColorTapiz . Text = "Color ..."00241
'00242
'Label700243
'00244
Me . Label7 . Location = New System . Drawing . Point ( 104 , 144 )00245
Me . Label7 . Name = "Label7"00246
Me . Label7 . Size = New System . Drawing . Size ( 40 , 24 )00247
Me . Label7 . TabIndex = 900248
Me . Label7 . Text = "ancho"00249
Me . Label7 . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00250
'00251
'udTapizY00252
'00253
Me . udTapizY . Increment = New Decimal ( New Integer () { 50 , 0 , 0 , 0 })00254
Me . udTapizY . Location = New System . Drawing . Point ( 168 , 72 )00255
Me . udTapizY . Maximum = New Decimal ( New Integer () { 2000 , 0 , 0 , 0 })00256
Me . udTapizY . Minimum = New Decimal ( New Integer () { 100 , 0 , 0 , 0 })00257
Me . udTapizY . Name = "udTapizY"00258
Me . udTapizY . Size = New System . Drawing . Size ( 56 , 20 )00259
Me . udTapizY . TabIndex = 1000260
Me . udTapizY . Value = New Decimal ( New Integer () { 800 , 0 , 0 , 0 })00261
'00262
'Label800263
'00264
Me . Label8 . Location = New System . Drawing . Point ( 224 , 72 )00265
Me . Label8 . Name = "Label8"00266
Me . Label8 . Size = New System . Drawing . Size ( 24 , 24 )00267
Me . Label8 . TabIndex = 900268
Me . Label8 . Text = "alto"00269
Me . Label8 . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00270
'00271
'TabPage300272
'00273
Me . TabPage3 . Controls . Add ( Me . GroupBox2 )00274
Me . TabPage3 . Location = New System . Drawing . Point ( 4 , 22 )00275
Me . TabPage3 . Name = "TabPage3"00276
Me . TabPage3 . Size = New System . Drawing . Size ( 362 , 189 )00277
Me . TabPage3 . TabIndex = 200278
Me . TabPage3 . Text = "Arcos"00279
'00280
'GroupBox200281
'00282
Me . GroupBox2 . Controls . Add ( Me . GroupBox1 )00283
Me . GroupBox2 . Controls . Add ( Me . pbArco )00284
Me . GroupBox2 . Controls . Add ( Me . udTrazoArco )00285
Me . GroupBox2 . Controls . Add ( Me . Label2 )00286
Me . GroupBox2 . Controls . Add ( Me . chkBArco )00287
Me . GroupBox2 . Controls . Add ( Me . btnColorArco )00288
Me . GroupBox2 . Controls . Add ( Me . lblColorArco )00289
Me . GroupBox2 . Location = New System . Drawing . Point ( 8 , 8 )00290
Me . GroupBox2 . Name = "GroupBox2"00291
Me . GroupBox2 . Size = New System . Drawing . Size ( 344 , 176 )00292
Me . GroupBox2 . TabIndex = 1000293
Me . GroupBox2 . TabStop = False00294
'00295
'GroupBox100296
'00297
Me . GroupBox1 . Controls . Add ( Me . chkminArco )00298
Me . GroupBox1 . Controls . Add ( Me . chkmaxArco )00299
Me . GroupBox1 . Controls . Add ( Me . chkcostArco )00300
Me . GroupBox1 . FlatStyle = System . Windows . Forms . FlatStyle . Flat00301
Me . GroupBox1 . Location = New System . Drawing . Point ( 0 , 0 )00302
Me . GroupBox1 . Name = "GroupBox1"00303
Me . GroupBox1 . Size = New System . Drawing . Size ( 80 , 80 )00304
Me . GroupBox1 . TabIndex = 1300305
Me . GroupBox1 . TabStop = False00306
'00307
'chkminArco00308
'00309
Me . chkminArco . Checked = True00310
Me . chkminArco . CheckState = System . Windows . Forms . CheckState . Checked00311
Me . chkminArco . Location = New System . Drawing . Point ( 8 , 16 )00312
Me . chkminArco . Name = "chkminArco"00313
Me . chkminArco . Size = New System . Drawing . Size ( 64 , 16 )00314
Me . chkminArco . TabIndex = 000315
Me . chkminArco . Text = "mínimo"00316
'00317
'chkmaxArco00318
'00319
Me . chkmaxArco . Checked = True00320
Me . chkmaxArco . CheckState = System . Windows . Forms . CheckState . Checked00321
Me . chkmaxArco . Location = New System . Drawing . Point ( 8 , 32 )00322
Me . chkmaxArco . Name = "chkmaxArco"00323
Me . chkmaxArco . Size = New System . Drawing . Size ( 64 , 24 )00324
Me . chkmaxArco . TabIndex = 100325
Me . chkmaxArco . Text = "máximo"00326
'00327
'chkcostArco00328
'00329
Me . chkcostArco . Checked = True00330
Me . chkcostArco . CheckState = System . Windows . Forms . CheckState . Checked00331
Me . chkcostArco . Location = New System . Drawing . Point ( 8 , 56 )00332
Me . chkcostArco . Name = "chkcostArco"00333
Me . chkcostArco . Size = New System . Drawing . Size ( 64 , 16 )00334
Me . chkcostArco . TabIndex = 200335
Me . chkcostArco . Text = "coste"00336
'00337
'pbArco00338
'00339
Me . pbArco . BackColor = System . Drawing . Color . White00340
Me . pbArco . BorderStyle = System . Windows . Forms . BorderStyle . Fixed3D00341
Me . pbArco . Location = New System . Drawing . Point ( 88 , 72 )00342
Me . pbArco . Name = "pbArco"00343
Me . pbArco . Size = New System . Drawing . Size ( 248 , 96 )00344
Me . pbArco . TabIndex = 1200345
Me . pbArco . TabStop = False00346
'00347
'udTrazoArco00348
'00349
Me . udTrazoArco . Location = New System . Drawing . Point ( 8 , 144 )00350
Me . udTrazoArco . Maximum = New Decimal ( New Integer () { 8 , 0 , 0 , 0 })00351
Me . udTrazoArco . Minimum = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00352
Me . udTrazoArco . Name = "udTrazoArco"00353
Me . udTrazoArco . Size = New System . Drawing . Size ( 48 , 20 )00354
Me . udTrazoArco . TabIndex = 300355
Me . udTrazoArco . Value = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00356
'00357
'Label200358
'00359
Me . Label2 . Location = New System . Drawing . Point ( 8 , 128 )00360
Me . Label2 . Name = "Label2"00361
Me . Label2 . Size = New System . Drawing . Size ( 40 , 16 )00362
Me . Label2 . TabIndex = 800363
Me . Label2 . Text = "Trazo: "00364
Me . Label2 . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00365
'00366
'chkBArco00367
'00368
Me . chkBArco . Location = New System . Drawing . Point ( 88 , 48 )00369
Me . chkBArco . Name = "chkBArco"00370
Me . chkBArco . Size = New System . Drawing . Size ( 104 , 16 )00371
Me . chkBArco . TabIndex = 500372
Me . chkBArco . Text = "Bidireccional"00373
'00374
'btnColorArco00375
'00376
Me . btnColorArco . Location = New System . Drawing . Point ( 256 , 16 )00377
Me . btnColorArco . Name = "btnColorArco"00378
Me . btnColorArco . Size = New System . Drawing . Size ( 80 , 24 )00379
Me . btnColorArco . TabIndex = 600380
Me . btnColorArco . Text = "Color ..."00381
'00382
'lblColorArco00383
'00384
Me . lblColorArco . BackColor = System . Drawing . Color . Black00385
Me . lblColorArco . BorderStyle = System . Windows . Forms . BorderStyle .» FixedSingle
00386
Me . lblColorArco . Location = New System . Drawing . Point ( 224 , 16 )00387
Me . lblColorArco . Name = "lblColorArco"00388
Me . lblColorArco . Size = New System . Drawing . Size ( 24 , 24 )00389
Me . lblColorArco . TabIndex = 1100390
'00391
'TabPage200392
'00393
Me . TabPage2 . Controls . Add ( Me . GroupBox4 )00394
Me . TabPage2 . Location = New System . Drawing . Point ( 4 , 22 )00395
Me . TabPage2 . Name = "TabPage2"00396
Me . TabPage2 . Size = New System . Drawing . Size ( 362 , 189 )00397
Me . TabPage2 . TabIndex = 100398
Me . TabPage2 . Text = "Nodos"00399
'00400
'GroupBox400401
'00402
Me . GroupBox4 . Controls . Add ( Me . GroupBox3 )00403
Me . GroupBox4 . Controls . Add ( Me . pbNodo )00404
Me . GroupBox4 . Controls . Add ( Me . Label4 )00405
Me . GroupBox4 . Controls . Add ( Me . udRadioNodo )00406
Me . GroupBox4 . Controls . Add ( Me . udTrazoNodo )00407
Me . GroupBox4 . Controls . Add ( Me . Label3 )00408
Me . GroupBox4 . Controls . Add ( Me . lblColorNodo )00409
Me . GroupBox4 . Controls . Add ( Me . btnColorNodo )00410
Me . GroupBox4 . Location = New System . Drawing . Point ( 8 , 8 )00411
Me . GroupBox4 . Name = "GroupBox4"00412
Me . GroupBox4 . Size = New System . Drawing . Size ( 344 , 176 )00413
Me . GroupBox4 . TabIndex = 1600414
Me . GroupBox4 . TabStop = False00415
'00416
'GroupBox300417
'00418
Me . GroupBox3 . Controls . Add ( Me . chktxtNodo )00419
Me . GroupBox3 . Controls . Add ( Me . chkcostNodo )00420
Me . GroupBox3 . Location = New System . Drawing . Point ( 0 , 0 )00421
Me . GroupBox3 . Name = "GroupBox3"00422
Me . GroupBox3 . Size = New System . Drawing . Size ( 80 , 72 )00423
Me . GroupBox3 . TabIndex = 1900424
Me . GroupBox3 . TabStop = False00425
'00426
'chktxtNodo00427
'00428
Me . chktxtNodo . Checked = True00429
Me . chktxtNodo . CheckState = System . Windows . Forms . CheckState . Checked00430
Me . chktxtNodo . Location = New System . Drawing . Point ( 8 , 16 )00431
Me . chktxtNodo . Name = "chktxtNodo"00432
Me . chktxtNodo . Size = New System . Drawing . Size ( 64 , 24 )00433
Me . chktxtNodo . TabIndex = 100434
Me . chktxtNodo . Text = "etiqueta"00435
'00436
'chkcostNodo00437
'00438
Me . chkcostNodo . Checked = True00439
Me . chkcostNodo . CheckState = System . Windows . Forms . CheckState . Checked00440
Me . chkcostNodo . Location = New System . Drawing . Point ( 8 , 40 )00441
Me . chkcostNodo . Name = "chkcostNodo"00442
Me . chkcostNodo . Size = New System . Drawing . Size ( 56 , 16 )00443
Me . chkcostNodo . TabIndex = 200444
Me . chkcostNodo . Text = "valor"00445
'00446
'pbNodo00447
'00448
Me . pbNodo . BackColor = System . Drawing . Color . White00449
Me . pbNodo . BorderStyle = System . Windows . Forms . BorderStyle . Fixed3D00450
Me . pbNodo . Location = New System . Drawing . Point ( 96 , 48 )00451
Me . pbNodo . Name = "pbNodo"00452
Me . pbNodo . Size = New System . Drawing . Size ( 120 , 120 )00453
Me . pbNodo . TabIndex = 1800454
Me . pbNodo . TabStop = False00455
'00456
'Label400457
'00458
Me . Label4 . Location = New System . Drawing . Point ( 224 , 80 )00459
Me . Label4 . Name = "Label4"00460
Me . Label4 . Size = New System . Drawing . Size ( 48 , 16 )00461
Me . Label4 . TabIndex = 1000462
Me . Label4 . Text = "Radio: "00463
Me . Label4 . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00464
'00465
'udRadioNodo00466
'00467
Me . udRadioNodo . Location = New System . Drawing . Point ( 224 , 96 )00468
Me . udRadioNodo . Maximum = New Decimal ( New Integer () { 50 , 0 , 0 , 0 })00469
Me . udRadioNodo . Minimum = New Decimal ( New Integer () { 15 , 0 , 0 , 0 })00470
Me . udRadioNodo . Name = "udRadioNodo"00471
Me . udRadioNodo . Size = New System . Drawing . Size ( 48 , 20 )00472
Me . udRadioNodo . TabIndex = 900473
Me . udRadioNodo . Value = New Decimal ( New Integer () { 15 , 0 , 0 , 0 })00474
'00475
'udTrazoNodo00476
'00477
Me . udTrazoNodo . Location = New System . Drawing . Point ( 8 , 144 )00478
Me . udTrazoNodo . Maximum = New Decimal ( New Integer () { 5 , 0 , 0 , 0 })00479
Me . udTrazoNodo . Minimum = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00480
Me . udTrazoNodo . Name = "udTrazoNodo"00481
Me . udTrazoNodo . Size = New System . Drawing . Size ( 48 , 20 )00482
Me . udTrazoNodo . TabIndex = 300483
Me . udTrazoNodo . Value = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00484
'00485
'Label300486
'00487
Me . Label3 . Location = New System . Drawing . Point ( 8 , 128 )00488
Me . Label3 . Name = "Label3"00489
Me . Label3 . Size = New System . Drawing . Size ( 48 , 16 )00490
Me . Label3 . TabIndex = 800491
Me . Label3 . Text = "Trazo: "00492
Me . Label3 . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00493
'00494
'lblColorNodo00495
'00496
Me . lblColorNodo . BackColor = System . Drawing . Color . LightSteelBlue00497
Me . lblColorNodo . BorderStyle = System . Windows . Forms . BorderStyle .» FixedSingle
00498
Me . lblColorNodo . Location = New System . Drawing . Point ( 224 , 16 )00499
Me . lblColorNodo . Name = "lblColorNodo"00500
Me . lblColorNodo . Size = New System . Drawing . Size ( 24 , 24 )00501
Me . lblColorNodo . TabIndex = 1700502
'00503
'btnColorNodo00504
'00505
Me . btnColorNodo . Location = New System . Drawing . Point ( 256 , 16 )00506
Me . btnColorNodo . Name = "btnColorNodo"00507
Me . btnColorNodo . Size = New System . Drawing . Size ( 80 , 24 )00508
Me . btnColorNodo . TabIndex = 1300509
Me . btnColorNodo . Text = "Color ..."00510
'00511
'TabPage400512
'00513
Me . TabPage4 . Controls . Add ( Me . GroupBox6 )00514
Me . TabPage4 . Location = New System . Drawing . Point ( 4 , 22 )00515
Me . TabPage4 . Name = "TabPage4"00516
Me . TabPage4 . Size = New System . Drawing . Size ( 362 , 189 )00517
Me . TabPage4 . TabIndex = 300518
Me . TabPage4 . Text = "Rejilla"00519
'00520
'GroupBox600521
'00522
Me . GroupBox6 . Controls . Add ( Me . chkIman )00523
Me . GroupBox6 . Controls . Add ( Me . chkMostrarRejilla )00524
Me . GroupBox6 . Controls . Add ( Me . btnColorRejilla )00525
Me . GroupBox6 . Controls . Add ( Me . udRejilla )00526
Me . GroupBox6 . Controls . Add ( Me . lblColorRejilla )00527
Me . GroupBox6 . Controls . Add ( Me . Label5 )00528
Me . GroupBox6 . Location = New System . Drawing . Point ( 8 , 8 )00529
Me . GroupBox6 . Name = "GroupBox6"00530
Me . GroupBox6 . Size = New System . Drawing . Size ( 344 , 176 )00531
Me . GroupBox6 . TabIndex = 700532
Me . GroupBox6 . TabStop = False00533
'00534
'chkIman00535
'00536
Me . chkIman . Location = New System . Drawing . Point ( 8 , 40 )00537
Me . chkIman . Name = "chkIman"00538
Me . chkIman . TabIndex = 2100539
Me . chkIman . Text = "Imán"00540
'00541
'chkMostrarRejilla00542
'00543
Me . chkMostrarRejilla . Location = New System . Drawing . Point ( 8 , 16 )00544
Me . chkMostrarRejilla . Name = "chkMostrarRejilla"00545
Me . chkMostrarRejilla . TabIndex = 2000546
Me . chkMostrarRejilla . Text = "Mostrar rejilla"00547
'00548
'btnColorRejilla00549
'00550
Me . btnColorRejilla . Location = New System . Drawing . Point ( 256 , 16 )00551
Me . btnColorRejilla . Name = "btnColorRejilla"00552
Me . btnColorRejilla . Size = New System . Drawing . Size ( 80 , 24 )00553
Me . btnColorRejilla . TabIndex = 1800554
Me . btnColorRejilla . Text = "Color ..."00555
'00556
'udRejilla00557
'00558
Me . udRejilla . Increment = New Decimal ( New Integer () { 5 , 0 , 0 , 0 })00559
Me . udRejilla . Location = New System . Drawing . Point ( 8 , 72 )00560
Me . udRejilla . Minimum = New Decimal ( New Integer () { 10 , 0 , 0 , 0 })00561
Me . udRejilla . Name = "udRejilla"00562
Me . udRejilla . Size = New System . Drawing . Size ( 48 , 20 )00563
Me . udRejilla . TabIndex = 600564
Me . udRejilla . Value = New Decimal ( New Integer () { 10 , 0 , 0 , 0 })00565
'00566
'lblColorRejilla00567
'00568
Me . lblColorRejilla . BackColor = System . Drawing . Color . Silver00569
Me . lblColorRejilla . BorderStyle = System . Windows . Forms . BorderStyle .» FixedSingle
00570
Me . lblColorRejilla . Location = New System . Drawing . Point ( 224 , 16 )00571
Me . lblColorRejilla . Name = "lblColorRejilla"00572
Me . lblColorRejilla . Size = New System . Drawing . Size ( 24 , 24 )00573
Me . lblColorRejilla . TabIndex = 1900574
'00575
'Label500576
'00577
Me . Label5 . Location = New System . Drawing . Point ( 64 , 72 )00578
Me . Label5 . Name = "Label5"00579
Me . Label5 . Size = New System . Drawing . Size ( 64 , 24 )00580
Me . Label5 . TabIndex = 700581
Me . Label5 . Text = "Espacio:"00582
Me . Label5 . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00583
'00584
'TabPage500585
'00586
Me . TabPage5 . Controls . Add ( Me . lblFuente )00587
Me . TabPage5 . Controls . Add ( Me . btnFuente )00588
Me . TabPage5 . Location = New System . Drawing . Point ( 4 , 22 )00589
Me . TabPage5 . Name = "TabPage5"00590
Me . TabPage5 . Size = New System . Drawing . Size ( 362 , 189 )00591
Me . TabPage5 . TabIndex = 400592
Me . TabPage5 . Text = "Fuente"00593
'00594
'lblFuente00595
'00596
Me . lblFuente . AutoSize = True00597
Me . lblFuente . Font = New System . Drawing . Font ( "Verdana" , 12.0 !, System .» Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , CType ( 0
» , Byte ))
00598
Me . lblFuente . Location = New System . Drawing . Point ( 8 , 40 )00599
Me . lblFuente . Name = "lblFuente"00600
Me . lblFuente . Size = New System . Drawing . Size ( 122 , 23 )00601
Me . lblFuente . TabIndex = 600602
Me . lblFuente . Text = "ABC abc 0123"00603
Me . lblFuente . TextAlign = System . Drawing . ContentAlignment . MiddleCenter00604
'00605
'btnFuente00606
'00607
Me . btnFuente . Location = New System . Drawing . Point ( 264 , 24 )00608
Me . btnFuente . Name = "btnFuente"00609
Me . btnFuente . Size = New System . Drawing . Size ( 80 , 24 )00610
Me . btnFuente . TabIndex = 500611
Me . btnFuente . Text = "Fuente..."00612
'00613
'btnAplicar00614
'00615
Me . btnAplicar . Location = New System . Drawing . Point ( 184 , 224 )00616
Me . btnAplicar . Name = "btnAplicar"00617
Me . btnAplicar . Size = New System . Drawing . Size ( 88 , 24 )00618
Me . btnAplicar . TabIndex = 100619
Me . btnAplicar . Text = "Aplicar"00620
'00621
'btnAplicarNuevos00622
'00623
Me . btnAplicarNuevos . Location = New System . Drawing . Point ( 96 , 224 )00624
Me . btnAplicarNuevos . Name = "btnAplicarNuevos"00625
Me . btnAplicarNuevos . Size = New System . Drawing . Size ( 80 , 24 )00626
Me . btnAplicarNuevos . TabIndex = 000627
Me . btnAplicarNuevos . Text = "Establecer"00628
'00629
'btnRestaurar00630
'00631
Me . btnRestaurar . Location = New System . Drawing . Point ( 8 , 224 )00632
Me . btnRestaurar . Name = "btnRestaurar"00633
Me . btnRestaurar . Size = New System . Drawing . Size ( 80 , 24 )00634
Me . btnRestaurar . TabIndex = 200635
Me . btnRestaurar . Text = "Restaurar "00636
'00637
'btnCancelar00638
'00639
Me . btnCancelar . Location = New System . Drawing . Point ( 280 , 224 )00640
Me . btnCancelar . Name = "btnCancelar"00641
Me . btnCancelar . Size = New System . Drawing . Size ( 80 , 24 )00642
Me . btnCancelar . TabIndex = 300643
Me . btnCancelar . Text = "Cancelar"00644
'00645
'lblColorTapiz00646
'00647
Me . lblColorTapiz . BackColor = System . Drawing . Color . White00648
Me . lblColorTapiz . BorderStyle = System . Windows . Forms . BorderStyle . Fixed3D00649
Me . lblColorTapiz . Location = New System . Drawing . Point ( 8 , 16 )00650
Me . lblColorTapiz . Name = "lblColorTapiz"00651
Me . lblColorTapiz . Size = New System . Drawing . Size ( 152 , 120 )00652
Me . lblColorTapiz . TabIndex = 2400653
Me . lblColorTapiz . TabStop = False00654
'00655
'chkTapizImagen00656
'00657
Me . chkTapizImagen . Location = New System . Drawing . Point ( 248 , 120 )00658
Me . chkTapizImagen . Name = "chkTapizImagen"00659
Me . chkTapizImagen . Size = New System . Drawing . Size ( 88 , 16 )00660
Me . chkTapizImagen . TabIndex = 2500661
Me . chkTapizImagen . Text = "imagen tapiz"00662
'00663
'btnImagenTapiz00664
'00665
Me . btnImagenTapiz . Enabled = False00666
Me . btnImagenTapiz . Location = New System . Drawing . Point ( 256 , 40 )00667
Me . btnImagenTapiz . Name = "btnImagenTapiz"00668
Me . btnImagenTapiz . Size = New System . Drawing . Size ( 80 , 24 )00669
Me . btnImagenTapiz . TabIndex = 2000670
Me . btnImagenTapiz . Text = "Imagen ..."00671
'00672
'Form200673
'00674
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00675
Me . ClientSize = New System . Drawing . Size ( 370 , 255 )00676
Me . ControlBox = False00677
Me . Controls . Add ( Me . btnCancelar )00678
Me . Controls . Add ( Me . btnAplicar )00679
Me . Controls . Add ( Me . TabControl1 )00680
Me . Controls . Add ( Me . btnAplicarNuevos )00681
Me . Controls . Add ( Me . btnRestaurar )00682
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle .» FixedToolWindow
00683
Me . MaximizeBox = False00684
Me . MinimizeBox = False00685
Me . Name = "Form2"00686
Me . Text = "Grafos - Opciones de Formato"00687
Me . TopMost = True00688
Me . TabControl1 . ResumeLayout ( False )00689
Me . TabPage1 . ResumeLayout ( False )00690
Me . GroupBox7 . ResumeLayout ( False )00691
CType ( Me . udZoom , System . ComponentModel . ISupportInitialize ) . EndInit ()00692
CType ( Me . udTapizX , System . ComponentModel . ISupportInitialize ) . EndInit ()00693
CType ( Me . udTapizY , System . ComponentModel . ISupportInitialize ) . EndInit ()00694
Me . TabPage3 . ResumeLayout ( False )00695
Me . GroupBox2 . ResumeLayout ( False )00696
Me . GroupBox1 . ResumeLayout ( False )00697
CType ( Me . udTrazoArco , System . ComponentModel . ISupportInitialize ) . EndInit (» )
00698
Me . TabPage2 . ResumeLayout ( False )00699
Me . GroupBox4 . ResumeLayout ( False )00700
Me . GroupBox3 . ResumeLayout ( False )00701
CType ( Me . udRadioNodo , System . ComponentModel . ISupportInitialize ) . EndInit (» )
00702
CType ( Me . udTrazoNodo , System . ComponentModel . ISupportInitialize ) . EndInit (» )
00703
Me . TabPage4 . ResumeLayout ( False )00704
Me . GroupBox6 . ResumeLayout ( False )00705
CType ( Me . udRejilla , System . ComponentModel . ISupportInitialize ) . EndInit ()00706
Me . TabPage5 . ResumeLayout ( False )00707
Me . ResumeLayout ( False )00708
00709
End Sub00710
00711
00712
00713
00714
# End Region00715
00716
Public Event ActualizaGrafo ( ByVal valor As Boolean )00717
Public Event ActualizaMenu ()00718
00719
Sub DibujaArcoPrueba ()00720
00721
00722
pbArco . Width = 25000723
pbArco . Height = 10000724
00725
00726
'Crea un objeto Graphics00727
Dim G As Graphics00728
'toma el objeto graphics00729
G = TomaObjetoGraphics ( pbArco )00730
00731
'borra el objeto graphics00732
G . Clear ( Color . White )00733
00734
00735
'definiciones00736
Dim p As Pen 'pluma00737
Dim brocha As System . Drawing . SolidBrush00738
00739
Dim b As Rectangle00740
Dim i As Long 'contador00741
00742
Dim x , y As Single00743
Dim x2 , y2 As Single00744
Dim radio As Single00745
Dim t As String 'para texto00746
Dim v As Single 'para valor00747
00748
Dim tamañotexto As SizeF00749
00750
Dim LV As Single00751
Dim Xa As Single , Ya As Single00752
Dim Xb As Single , Yb As Single00753
00754
00755
Dim fuente As Font00756
00757
00758
'Cambia escala del tipo de letra00759
fuente = New Font ( lblFuente . Font . Name , lblFuente . Font . Size , lblFuente .» Font . Style , GraphicsUnit . Pixel )
00760
00761
00762
00763
'----------------------------00764
'Dibuja la colección de Arcos00765
'----------------------------00766
00767
'define el trazo y su color00768
p = New Pen ( lblColorArco . BackColor , Me . udTrazoArco . Value )00769
'toma datos del nodo 100770
x = 1000771
y = 5000772
00773
'toma datos del nodo 200774
x2 = 24000775
y2 = 5000776
00777
'línea principal de centro a centro00778
'------------------------------------00779
G . DrawLine ( p , x , y , x2 , y2 )00780
00781
00782
'pone texto etiqueta en la mitad del arco00783
'-----------------------------------------00784
00785
If chkminArco . Checked Or chkmaxArco . Checked Or chkcostArco . Checked Then00786
t = "("00787
00788
If chkminArco . Checked = True Then00789
t = t & 000790
End If00791
If chkmaxArco . Checked = True Then00792
If chkminArco . Checked Then t = t & "; "00793
t = t & 1000794
End If00795
00796
If chkcostArco . Checked = True Then00797
If chkmaxArco . Checked Or chkminArco . Checked Then t = t & "; "00798
t = t & 500799
End If00800
00801
t = t & ")"00802
00803
End If00804
00805
00806
00807
00808
tamañotexto = G . MeasureString ( t , fuente )00809
'rectangulo blanco debajo para que el texto se lea más claro00810
b = New Rectangle ( x + 0.7 * ( x2 - x ) - tamañotexto . Width / 2 , y + 0.7» * ( y2 - y ) - tamañotexto . Height / 2 , tamañotexto . Width , tamañotexto .
» Height )
00811
G . FillRectangle ( Brushes . White , b )00812
'escribe el texto00813
G . DrawString ( t , fuente , Brushes . Black , x + 0.7 * ( x2 - x ) - tamañotexto» . Width / 2 , y + 0.7 * ( y2 - y ) - tamañotexto . Height / 2 )
00814
00815
'punta de flecha destino00816
'-----------------------00817
'calcula vector unitario00818
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )00819
If LV = 0 Then LV = 0.000000100820
'vector unitario de tamaño radio del nodo destino00821
x = ( x2 - x ) / LV * 1000822
y = ( y2 - y ) / LV * 1000823
00824
'punto de intersección de la línea principal con el círculo del nodo» destino
00825
Xa = x2 '- x00826
Ya = y2 '- y00827
00828
'segmento estribor de la punta de la flecha00829
Xb = Xa - x * Me . udTrazoArco . Value - y / 2 * Me . udTrazoArco . Value00830
Yb = Ya - y * Me . udTrazoArco . Value + x / 2 * Me . udTrazoArco . Value00831
G . DrawLine ( p , Xb , Yb , Xa , Ya )00832
'segmento babor de la punta de la flecha00833
Xb = Xa - x * Me . udTrazoArco . Value + y / 2 * Me . udTrazoArco . Value00834
Yb = Ya - y * Me . udTrazoArco . Value - x / 2 * Me . udTrazoArco . Value00835
G . DrawLine ( p , Xb , Yb , Xa , Ya )00836
00837
'Caso de arco bidireccional00838
'con dos puntas de flecha00839
If Me . chkBArco . Checked = True Then00840
'punta de flecha origen00841
'-----------------------00842
'toma los nodos al revés y ya está!00843
'toma datos del nodo 100844
x = 24000845
y = 5000846
'toma datos del nodo 200847
x2 = 1000848
y2 = 5000849
00850
'calcula vector unitario00851
LV = Math . Sqrt ((( x2 - x )) ^ 2 + (( y2 - y )) ^ 2 )00852
If LV = 0 Then LV = 0.000000100853
'vector unitario de tamaño radio del nodo destino00854
x = ( x2 - x ) / LV * 1000855
y = ( y2 - y ) / LV * 1000856
00857
'punto de intersección de la línea principal con el círculo del» nodo destino
00858
Xa = x2 '- x00859
Ya = y2 '- y00860
00861
'segmento estribor de la punta de la flecha00862
Xb = Xa - x * Me . udTrazoArco . Value - y / 2 * Me . udTrazoArco . Value00863
Yb = Ya - y * Me . udTrazoArco . Value + x / 2 * Me . udTrazoArco . Value00864
G . DrawLine ( p , Xb , Yb , Xa , Ya )00865
'segmento babor de la punta de la flecha00866
Xb = Xa - x * Me . udTrazoArco . Value + y / 2 * Me . udTrazoArco . Value00867
Yb = Ya - y * Me . udTrazoArco . Value - x / 2 * Me . udTrazoArco . Value00868
G . DrawLine ( p , Xb , Yb , Xa , Ya )00869
00870
00871
End If00872
00873
00874
End Sub00875
00876
Private Sub Button3_Click ( ByVal sender As System . Object , ByVal e As System .» EventArgs )
00877
DibujaArcoPrueba ()00878
End Sub00879
00880
Private Sub btnColorArco_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnColorArco . Click
00881
lblColorArco . BackColor = DialogoColor ( lblColorArco . BackColor )00882
DibujaArcoPrueba ()00883
End Sub00884
00885
00886
00887
Private Sub btnColorNodo_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnColorNodo . Click
00888
lblColorNodo . BackColor = DialogoColor ( lblColorNodo . BackColor )00889
DibujaNodoPrueba ()00890
End Sub00891
Sub DibujaNodoPrueba ()00892
pbNodo . Width = 12000893
pbNodo . Height = 12000894
00895
'Crea un objeto Graphics00896
Dim G As Graphics00897
'toma el objeto graphics00898
G = TomaObjetoGraphics ( pbNodo )00899
00900
'borra el objeto graphics00901
G . Clear ( Color . White )00902
00903
00904
'definiciones00905
Dim p As Pen 'pluma00906
Dim brocha As System . Drawing . SolidBrush00907
00908
Dim b As Rectangle00909
Dim i As Long 'contador00910
00911
Dim x , y As Single00912
Dim x2 , y2 As Single00913
Dim radio As Single00914
Dim t As String 'para texto00915
Dim v As Single 'para valor00916
00917
Dim tamañotexto As SizeF00918
00919
Dim LV As Single00920
Dim Xa As Single , Ya As Single00921
Dim Xb As Single , Yb As Single00922
00923
Dim fuente As Font00924
00925
'Cambia escala del tipo de letra00926
fuente = New Font ( lblFuente . Font . Name , lblFuente . Font . Size , lblFuente .» Font . Style , GraphicsUnit . Pixel )
00927
00928
00929
'----------------------------00930
'Dibuja la colección de Nodos00931
'----------------------------00932
00933
'toma datos del nodo00934
x = 6000935
y = 6000936
radio = udRadioNodo . Value00937
00938
'define el trazo y su color00939
p = New Pen ( Color . Black , udTrazoNodo . Value )00940
'dibuja círculo del nodo00941
b = New Rectangle ( x - radio , y - radio , radio * 2 , radio * 2 )00942
'rellena el círculo del nodo00943
brocha = New System . Drawing . SolidBrush ( lblColorNodo . BackColor )00944
00945
G . FillEllipse ( brocha , b )00946
00947
Dim condicion As Integer00948
If chktxtNodo . Checked = False Or chkcostNodo . Checked = False Then00949
condicion = 000950
Else00951
condicion = 100952
End If00953
00954
If chktxtNodo . Checked And chkcostNodo . Checked Then00955
'dibuja ecuador del nodo00956
G . DrawLine ( p , x - radio , y , x + radio , y )00957
End If00958
If chktxtNodo . Checked Then00959
'pone texto etiqueta en la mitad superior00960
t = "etiqueta"00961
tamañotexto = G . MeasureString ( t , fuente )00962
G . DrawString ( t , fuente , Brushes . Black , x - tamañotexto . Width / 2 , y» - tamañotexto . Height / 2 - radio / 2 * condicion )
00963
End If00964
If chkcostNodo . Checked Then00965
'pone texto valor en la mitad inferior00966
t = "100"00967
tamañotexto = G . MeasureString ( t , fuente )00968
G . DrawString ( t , fuente , Brushes . Black , x - tamañotexto . Width / 2 , y» - tamañotexto . Height / 2 + radio / 2 * condicion )
00969
End If00970
'dibuja el borde del nodo00971
G . DrawEllipse ( p , b )00972
00973
End Sub00974
Private Sub Button2_Click ( ByVal sender As System . Object , ByVal e As System .» EventArgs )
00975
DibujaNodoPrueba ()00976
End Sub00977
00978
Sub ModificaOpciones ()00979
'Modifica en las variables globales los valores de las opciones00980
00981
Form1 . Grafico . Rejilla = Me . udRejilla . Value00982
Form1 . Grafico . MostrarRejilla = Me . chkMostrarRejilla . Checked00983
Form1 . Grafico . Iman = Me . chkIman . Checked00984
Form1 . Grafico . Zoom = Me . udZoom . Value00985
Form1 . Grafico . TapizX = Me . udTapizX . Value00986
Form1 . Grafico . TapizY = Me . udTapizY . Value00987
00988
Form1 . Grafico . ColorRejilla = Me . lblColorRejilla . BackColor00989
Form1 . Grafico . ColorTapiz = Me . lblColorTapiz . BackColor00990
00991
Form1 . Grafico . MostrarImagenTapiz = Me . chkTapizImagen . Checked00992
00993
'Toma valores actuales para los nodos00994
00995
Form1 . Grafico . Fuente = Me . lblFuente . Font00996
Form1 . Grafico . textoNodo = Me . chktxtNodo . Checked00997
Form1 . Grafico . costNodo = Me . chkcostNodo . Checked00998
Form1 . Grafico . RadioNodo = Me . udRadioNodo . Value00999
Form1 . Grafico . TrazoNodo = Me . udTrazoNodo . Value01000
Form1 . Grafico . ColNodo = Me . lblColorNodo . BackColor01001
01002
'Toma valores actuales para los nodos01003
Form1 . Grafico . minArco = Me . chkminArco . Checked01004
Form1 . Grafico . maxArco = Me . chkmaxArco . Checked01005
Form1 . Grafico . costArco = Me . chkcostArco . Checked01006
Form1 . Grafico . TrazoArco = Me . udTrazoArco . Value01007
Form1 . Grafico . ColArco = Me . lblColorArco . BackColor01008
Form1 . Grafico . BArco = Me . chkBArco . Checked01009
01010
01011
End Sub01012
01013
Private Sub Form2_Load ( ByVal sender As System . Object , ByVal e As System .» EventArgs ) Handles MyBase . Load
01014
LeeOpciones ()01015
01016
'dibuja estado actual de ejemplo01017
DibujaArcoPrueba ()01018
DibujaNodoPrueba ()01019
01020
End Sub01021
Public Sub LeeOpciones ()01022
Me . udZoom . Value = Form1 . Grafico . Zoom01023
Me . udRejilla . Value = Form1 . Grafico . Rejilla01024
Me . chkMostrarRejilla . Checked = Form1 . Grafico . MostrarRejilla01025
Me . chkIman . Checked = Form1 . Grafico . Iman01026
01027
Me . udTapizX . Value = Form1 . Grafico . TapizX01028
Me . udTapizY . Value = Form1 . Grafico . TapizY01029
01030
Me . lblColorRejilla . BackColor = Form1 . Grafico . ColorRejilla01031
Me . lblColorTapiz . BackColor = Form1 . Grafico . ColorTapiz01032
01033
Me . chkTapizImagen . Checked = Form1 . Grafico . MostrarImagenTapiz01034
If Me . chkTapizImagen . Checked = True Then01035
If Form1 . Grafico . ImagenTapiz <> "" Then01036
Dim img As Image01037
img = Image . FromFile ( Form1 . Grafico . ImagenTapiz )01038
lblColorTapiz . Image = img . GetThumbnailImage ( lblColorTapiz . Width» , lblColorTapiz . Height , Nothing , Nothing )
01039
End If01040
Else01041
Me . lblColorTapiz . Image = Nothing01042
End If01043
01044
'Toma valores actuales para los nodos01045
01046
Me . lblFuente . Font = Form1 . Grafico . Fuente01047
Me . chktxtNodo . Checked = Form1 . Grafico . textoNodo01048
Me . chkcostNodo . Checked = Form1 . Grafico . costNodo01049
Me . udRadioNodo . Value = Form1 . Grafico . RadioNodo01050
Me . udTrazoNodo . Value = Form1 . Grafico . TrazoNodo01051
Me . lblColorNodo . BackColor = Form1 . Grafico . ColNodo01052
01053
'Toma valores actuales para los nodos01054
Me . chkminArco . Checked = Form1 . Grafico . minArco01055
Me . chkmaxArco . Checked = Form1 . Grafico . maxArco01056
Me . chkcostArco . Checked = Form1 . Grafico . costArco01057
Me . udTrazoArco . Value = Form1 . Grafico . TrazoArco01058
Me . lblColorArco . BackColor = Form1 . Grafico . ColArco01059
Me . chkBArco . Checked = Form1 . Grafico . BArco01060
01061
End Sub01062
Private Sub btnAplicar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnAplicar . Click
01063
'Pide confirmación al usuario antes de aplicar01064
'las nuevas opciones a todo el gráfico01065
Dim respuesta As MsgBoxResult01066
respuesta = MsgBox ( "¿Desea aplicar los cambios a todo su gráfico?" ,» MsgBoxStyle . OKCancel , )
01067
If respuesta = MsgBoxResult . OK Then01068
01069
'Modifica para todos los nodos y arcos01070
ModificaOpciones ()01071
01072
Dim i As Long01073
For i = 0 To Form1 . TotalNodos - 101074
Form1 . Nodos ( i ) . Col = Form1 . Grafico . ColNodo01075
Form1 . Nodos ( i ) . Radio = Form1 . Grafico . RadioNodo01076
Form1 . Nodos ( i ) . Grosor = Form1 . Grafico . TrazoNodo01077
Next i01078
For i = 0 To Form1 . TotalArcos - 101079
Form1 . Arcos ( i ) . Col = Form1 . Grafico . ColArco01080
Form1 . Arcos ( i ) . B = Form1 . Grafico . BArco01081
Form1 . Arcos ( i ) . Grosor = Form1 . Grafico . TrazoArco01082
Next i01083
01084
RaiseEvent ActualizaGrafo ( True )01085
01086
End If01087
End Sub01088
01089
Private Sub btnAplicarNuevos_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnAplicarNuevos . Click
01090
'Aplica los valores actuales para los nuevos nodos y arcos generados01091
'Modifica para los nuevos nodos y arcos generados01092
ModificaOpciones ()01093
01094
End Sub01095
01096
01097
01098
Private Sub udTrazoNodo_ValueChanged ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles udTrazoNodo . ValueChanged
01099
DibujaNodoPrueba ()01100
End Sub01101
01102
Private Sub udRadioNodo_ValueChanged ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles udRadioNodo . ValueChanged
01103
DibujaNodoPrueba ()01104
End Sub01105
01106
01107
01108
Private Sub udTrazoArco_ValueChanged ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles udTrazoArco . ValueChanged
01109
DibujaArcoPrueba ()01110
End Sub01111
01112
Private Sub chkBArco_CheckedChanged ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles chkBArco . CheckedChanged
01113
DibujaArcoPrueba ()01114
End Sub01115
01116
Public Sub btnRestaurar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnRestaurar . Click
01117
'cambia todas las opciones a los valores por defecto01118
Form1 . OpcionesporDefecto ()01119
LeeOpciones ()01120
01121
'dibuja estado actual de ejemplo01122
DibujaArcoPrueba ()01123
DibujaNodoPrueba ()01124
End Sub01125
01126
01127
Private Sub btnColorTapiz_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnColorTapiz . Click
01128
lblColorTapiz . BackColor = DialogoColor ( lblColorTapiz . BackColor )01129
End Sub01130
01131
Protected Overrides Sub Finalize ()01132
MyBase . Finalize ()01133
End Sub01134
01135
Private Sub btnCancelar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnCancelar . Click
01136
Me . Visible = False01137
RaiseEvent ActualizaMenu ()01138
End Sub01139
01140
Private Sub chkMostrarRejilla_CheckedChanged ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles chkMostrarRejilla . CheckedChanged
01141
Form1 . Grafico . MostrarRejilla = chkMostrarRejilla . Checked01142
RaiseEvent ActualizaMenu ()01143
End Sub01144
01145
Private Sub chkIman_CheckedChanged ( ByVal sender As Object , ByVal e As System» . EventArgs ) Handles chkIman . CheckedChanged
01146
Form1 . Grafico . Iman = chkIman . Checked01147
RaiseEvent ActualizaMenu ()01148
End Sub01149
01150
01151
Private Sub btnFuente_Click ( ByVal sender As System . Object , ByVal e As System» . EventArgs ) Handles btnFuente . Click
01152
FontDialog1 . ShowColor = False01153
FontDialog1 . Font = lblFuente . Font01154
If FontDialog1 . ShowDialog () <> DialogResult . Cancel Then01155
lblFuente . Font = FontDialog1 . Font01156
DibujaNodoPrueba ()01157
DibujaArcoPrueba ()01158
End If01159
End Sub01160
01161
Private Sub chktxtNodo_CheckedChanged ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles chktxtNodo . CheckedChanged
01162
DibujaNodoPrueba ()01163
End Sub01164
01165
Private Sub chkcostNodo_CheckedChanged ( ByVal sender As System . Object , ByVal» e As System . EventArgs ) Handles chkcostNodo . CheckedChanged
01166
DibujaNodoPrueba ()01167
End Sub01168
01169
Private Sub chkminArco_CheckedChanged ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles chkminArco . CheckedChanged
01170
DibujaArcoPrueba ()01171
End Sub01172
01173
Private Sub chkmaxArco_CheckedChanged ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles chkmaxArco . CheckedChanged
01174
DibujaArcoPrueba ()01175
End Sub01176
01177
Private Sub chkcostArco_CheckedChanged ( ByVal sender As System . Object , ByVal» e As System . EventArgs ) Handles chkcostArco . CheckedChanged
01178
DibujaArcoPrueba ()01179
End Sub01180
01181
Private Sub btnColorRejilla_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnColorRejilla . Click
01182
lblColorRejilla . BackColor = DialogoColor ( lblColorRejilla . BackColor )01183
End Sub01184
01185
01186
Private Sub btnImagenTapiz_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnImagenTapiz . Click
01187
'Carga imagen desde archivo para el fondo del tapiz01188
01189
Dim openFileDialog1 As New OpenFileDialog01190
openFileDialog1 . AddExtension = True01191
openFileDialog1 . DefaultExt = ".gif" 'en caso de no especificar, se toma» gif por defecto
01192
openFileDialog1 . Filter = "Graphics Interchange Format» (*.gif)|*.gif|Bitmap Image (*.bmp)|*.bmp|Portable Network Graphics
» format (*.png)|*.png|Windows MetaFile format
» (*.wmf)|*.wmf|MetaArchivo mejorado (*.emf)|*.emf|Tagged Image File
» Format (*.tif)|*.tif|JPEG (*.jpg)|*.jpg"
01193
openFileDialog1 . FilterIndex = 1 'formato por defecto .gif01194
openFileDialog1 . Title = "Abrir Imagen para el fondo del tapiz"01195
openFileDialog1 . RestoreDirectory = True01196
01197
If openFileDialog1 . ShowDialog () = DialogResult . OK Then01198
Dim img As Image01199
img = Image . FromFile ( openFileDialog1 . FileName )01200
lblColorTapiz . Image = img . GetThumbnailImage ( lblColorTapiz . Width ,» lblColorTapiz . Height , Nothing , Nothing )
01201
Form1 . Grafico . ImagenTapiz = openFileDialog1 . FileName01202
Form1 . Grafico . MostrarImagenTapiz = True01203
Else01204
Exit Sub01205
End If01206
01207
End Sub01208
01209
Private Sub chkTapizImagen_CheckedChanged ( ByVal sender As System . Object ,» ByVal e As System . EventArgs ) Handles chkTapizImagen . CheckedChanged
01210
If chkTapizImagen . Checked = True Then01211
Form1 . Grafico . MostrarImagenTapiz = True01212
Me . btnImagenTapiz . Enabled = True01213
If Form1 . Grafico . ImagenTapiz <> "" Then01214
Dim img As Image01215
img = Image . FromFile ( Form1 . Grafico . ImagenTapiz )01216
lblColorTapiz . Image = img . GetThumbnailImage ( lblColorTapiz . Width» , lblColorTapiz . Height , Nothing , Nothing )
01217
End If01218
Else01219
Form1 . Grafico . MostrarImagenTapiz = False01220
Me . btnImagenTapiz . Enabled = False01221
Me . lblColorTapiz . Image = Nothing01222
End If01223
End Sub01224
End Class00001
Public Class Form300002
Inherits System . Windows . Forms . Form00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'Form reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
Friend WithEvents Label1 As System . Windows . Forms . Label00033
Friend WithEvents Label2 As System . Windows . Forms . Label00034
Friend WithEvents txtEtiquetaNodo As System . Windows . Forms . TextBox00035
Friend WithEvents txtCosteNodo As System . Windows . Forms . TextBox00036
Friend WithEvents btnAceptar As System . Windows . Forms . Button00037
Friend WithEvents btnCancelar As System . Windows . Forms . Button00038
Friend WithEvents lblXYNodo As System . Windows . Forms . Label00039
Friend WithEvents GroupBox4 As System . Windows . Forms . GroupBox00040
Friend WithEvents Label4 As System . Windows . Forms . Label00041
Friend WithEvents udRadioNodo As System . Windows . Forms . NumericUpDown00042
Friend WithEvents udTrazoNodo As System . Windows . Forms . NumericUpDown00043
Friend WithEvents Label3 As System . Windows . Forms . Label00044
Friend WithEvents lblColorNodo As System . Windows . Forms . Label00045
Friend WithEvents btnColorNodo As System . Windows . Forms . Button00046
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00047
Me . Label1 = New System . Windows . Forms . Label00048
Me . Label2 = New System . Windows . Forms . Label00049
Me . txtEtiquetaNodo = New System . Windows . Forms . TextBox00050
Me . txtCosteNodo = New System . Windows . Forms . TextBox00051
Me . btnAceptar = New System . Windows . Forms . Button00052
Me . btnCancelar = New System . Windows . Forms . Button00053
Me . lblXYNodo = New System . Windows . Forms . Label00054
Me . GroupBox4 = New System . Windows . Forms . GroupBox00055
Me . Label4 = New System . Windows . Forms . Label00056
Me . udRadioNodo = New System . Windows . Forms . NumericUpDown00057
Me . udTrazoNodo = New System . Windows . Forms . NumericUpDown00058
Me . Label3 = New System . Windows . Forms . Label00059
Me . lblColorNodo = New System . Windows . Forms . Label00060
Me . btnColorNodo = New System . Windows . Forms . Button00061
Me . GroupBox4 . SuspendLayout ()00062
CType ( Me . udRadioNodo , System . ComponentModel . ISupportInitialize ) .» BeginInit ()
00063
CType ( Me . udTrazoNodo , System . ComponentModel . ISupportInitialize ) .» BeginInit ()
00064
Me . SuspendLayout ()00065
'00066
'Label100067
'00068
Me . Label1 . Location = New System . Drawing . Point ( 8 , 8 )00069
Me . Label1 . Name = "Label1"00070
Me . Label1 . Size = New System . Drawing . Size ( 72 , 24 )00071
Me . Label1 . TabIndex = 000072
Me . Label1 . Text = "Etiqueta:"00073
'00074
'Label200075
'00076
Me . Label2 . Location = New System . Drawing . Point ( 152 , 8 )00077
Me . Label2 . Name = "Label2"00078
Me . Label2 . Size = New System . Drawing . Size ( 64 , 24 )00079
Me . Label2 . TabIndex = 100080
Me . Label2 . Text = "Valor:"00081
'00082
'txtEtiquetaNodo00083
'00084
Me . txtEtiquetaNodo . Location = New System . Drawing . Point ( 8 , 24 )00085
Me . txtEtiquetaNodo . Name = "txtEtiquetaNodo"00086
Me . txtEtiquetaNodo . Size = New System . Drawing . Size ( 104 , 20 )00087
Me . txtEtiquetaNodo . TabIndex = 200088
Me . txtEtiquetaNodo . Text = ""00089
'00090
'txtCosteNodo00091
'00092
Me . txtCosteNodo . Location = New System . Drawing . Point ( 152 , 24 )00093
Me . txtCosteNodo . Name = "txtCosteNodo"00094
Me . txtCosteNodo . Size = New System . Drawing . Size ( 104 , 20 )00095
Me . txtCosteNodo . TabIndex = 300096
Me . txtCosteNodo . Text = ""00097
'00098
'btnAceptar00099
'00100
Me . btnAceptar . Location = New System . Drawing . Point ( 176 , 176 )00101
Me . btnAceptar . Name = "btnAceptar"00102
Me . btnAceptar . Size = New System . Drawing . Size ( 80 , 24 )00103
Me . btnAceptar . TabIndex = 400104
Me . btnAceptar . Text = "Aceptar"00105
'00106
'btnCancelar00107
'00108
Me . btnCancelar . Location = New System . Drawing . Point ( 8 , 176 )00109
Me . btnCancelar . Name = "btnCancelar"00110
Me . btnCancelar . Size = New System . Drawing . Size ( 80 , 24 )00111
Me . btnCancelar . TabIndex = 500112
Me . btnCancelar . Text = "Cancelar"00113
'00114
'lblXYNodo00115
'00116
Me . lblXYNodo . BorderStyle = System . Windows . Forms . BorderStyle . Fixed3D00117
Me . lblXYNodo . Location = New System . Drawing . Point ( 8 , 56 )00118
Me . lblXYNodo . Name = "lblXYNodo"00119
Me . lblXYNodo . Size = New System . Drawing . Size ( 248 , 24 )00120
Me . lblXYNodo . TabIndex = 600121
Me . lblXYNodo . Text = "..."00122
'00123
'GroupBox400124
'00125
Me . GroupBox4 . Controls . Add ( Me . Label4 )00126
Me . GroupBox4 . Controls . Add ( Me . udRadioNodo )00127
Me . GroupBox4 . Controls . Add ( Me . udTrazoNodo )00128
Me . GroupBox4 . Controls . Add ( Me . Label3 )00129
Me . GroupBox4 . Controls . Add ( Me . lblColorNodo )00130
Me . GroupBox4 . Controls . Add ( Me . btnColorNodo )00131
Me . GroupBox4 . Location = New System . Drawing . Point ( 8 , 88 )00132
Me . GroupBox4 . Name = "GroupBox4"00133
Me . GroupBox4 . Size = New System . Drawing . Size ( 248 , 80 )00134
Me . GroupBox4 . TabIndex = 1700135
Me . GroupBox4 . TabStop = False00136
'00137
'Label400138
'00139
Me . Label4 . Location = New System . Drawing . Point ( 8 , 48 )00140
Me . Label4 . Name = "Label4"00141
Me . Label4 . Size = New System . Drawing . Size ( 48 , 16 )00142
Me . Label4 . TabIndex = 1000143
Me . Label4 . Text = "Radio: "00144
Me . Label4 . TextAlign = System . Drawing . ContentAlignment . MiddleCenter00145
'00146
'udRadioNodo00147
'00148
Me . udRadioNodo . Location = New System . Drawing . Point ( 56 , 48 )00149
Me . udRadioNodo . Maximum = New Decimal ( New Integer () { 50 , 0 , 0 , 0 })00150
Me . udRadioNodo . Minimum = New Decimal ( New Integer () { 15 , 0 , 0 , 0 })00151
Me . udRadioNodo . Name = "udRadioNodo"00152
Me . udRadioNodo . Size = New System . Drawing . Size ( 48 , 20 )00153
Me . udRadioNodo . TabIndex = 900154
Me . udRadioNodo . Value = New Decimal ( New Integer () { 15 , 0 , 0 , 0 })00155
'00156
'udTrazoNodo00157
'00158
Me . udTrazoNodo . Location = New System . Drawing . Point ( 56 , 16 )00159
Me . udTrazoNodo . Maximum = New Decimal ( New Integer () { 5 , 0 , 0 , 0 })00160
Me . udTrazoNodo . Minimum = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00161
Me . udTrazoNodo . Name = "udTrazoNodo"00162
Me . udTrazoNodo . Size = New System . Drawing . Size ( 48 , 20 )00163
Me . udTrazoNodo . TabIndex = 300164
Me . udTrazoNodo . Value = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00165
'00166
'Label300167
'00168
Me . Label3 . Location = New System . Drawing . Point ( 8 , 16 )00169
Me . Label3 . Name = "Label3"00170
Me . Label3 . Size = New System . Drawing . Size ( 48 , 24 )00171
Me . Label3 . TabIndex = 800172
Me . Label3 . Text = "Trazo: "00173
Me . Label3 . TextAlign = System . Drawing . ContentAlignment . MiddleCenter00174
'00175
'lblColorNodo00176
'00177
Me . lblColorNodo . BackColor = System . Drawing . Color . LightSteelBlue00178
Me . lblColorNodo . BorderStyle = System . Windows . Forms . BorderStyle .» FixedSingle
00179
Me . lblColorNodo . Location = New System . Drawing . Point ( 128 , 16 )00180
Me . lblColorNodo . Name = "lblColorNodo"00181
Me . lblColorNodo . Size = New System . Drawing . Size ( 24 , 24 )00182
Me . lblColorNodo . TabIndex = 1700183
'00184
'btnColorNodo00185
'00186
Me . btnColorNodo . Location = New System . Drawing . Point ( 160 , 16 )00187
Me . btnColorNodo . Name = "btnColorNodo"00188
Me . btnColorNodo . Size = New System . Drawing . Size ( 80 , 24 )00189
Me . btnColorNodo . TabIndex = 1300190
Me . btnColorNodo . Text = "Color ..."00191
'00192
'Form300193
'00194
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00195
Me . ClientSize = New System . Drawing . Size ( 266 , 207 )00196
Me . Controls . Add ( Me . GroupBox4 )00197
Me . Controls . Add ( Me . lblXYNodo )00198
Me . Controls . Add ( Me . btnCancelar )00199
Me . Controls . Add ( Me . btnAceptar )00200
Me . Controls . Add ( Me . txtCosteNodo )00201
Me . Controls . Add ( Me . txtEtiquetaNodo )00202
Me . Controls . Add ( Me . Label2 )00203
Me . Controls . Add ( Me . Label1 )00204
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle .» FixedToolWindow
00205
Me . MaximizeBox = False00206
Me . MinimizeBox = False00207
Me . Name = "Form3"00208
Me . Text = "Grafos - Editar Nodo"00209
Me . TopMost = True00210
Me . GroupBox4 . ResumeLayout ( False )00211
CType ( Me . udRadioNodo , System . ComponentModel . ISupportInitialize ) . EndInit (» )
00212
CType ( Me . udTrazoNodo , System . ComponentModel . ISupportInitialize ) . EndInit (» )
00213
Me . ResumeLayout ( False )00214
00215
End Sub00216
00217
# End Region00218
00219
00220
Private Sub btnColorNodo_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnColorNodo . Click
00221
lblColorNodo . BackColor = DialogoColor ( lblColorNodo . BackColor )00222
End Sub00223
00224
Private Sub Form3_Load ( ByVal sender As System . Object , ByVal e As System .» EventArgs ) Handles MyBase . Load
00225
'Toma los valores del nodo a editar00226
txtEtiquetaNodo . Text = Form1 . Nodos ( Form1 . Nd2S ) . Texto00227
txtCosteNodo . Text = Form1 . Nodos ( Form1 . Nd2S ) . Valor00228
lblXYNodo . Text = " X = " & Format ( Form1 . Nodos ( Form1 . Nd2S ) . X ,» "####.###" ) & " Y = " & Format ( Form1 . Nodos ( Form1 . Nd2S ) . Y ,
» "####.###" )
00229
lblColorNodo . BackColor = Form1 . Nodos ( Form1 . Nd2S ) . Col00230
udRadioNodo . Value = Form1 . Nodos ( Form1 . Nd2S ) . Radio00231
udTrazoNodo . Value = Form1 . Nodos ( Form1 . Nd2S ) . Grosor00232
00233
End Sub00234
00235
Private Sub btnAceptar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnAceptar . Click
00236
'Cambia los valores del nodo según los editados00237
Form1 . Nodos ( Form1 . Nd2S ) . Texto = txtEtiquetaNodo . Text00238
Form1 . Nodos ( Form1 . Nd2S ) . Valor = CSng ( txtCosteNodo . Text )00239
'lblXYNodo.Text = "X = " & Form1.Nodos(Form1.Nd2S).X & ", Y = " &» Form1.Nodos(Form1.Nd2S).Y
00240
Form1 . Nodos ( Form1 . Nd2S ) . Col = lblColorNodo . BackColor00241
Form1 . Nodos ( Form1 . Nd2S ) . Radio = udRadioNodo . Value00242
Form1 . Nodos ( Form1 . Nd2S ) . Grosor = udTrazoNodo . Value00243
Me . DialogResult = DialogResult . OK00244
00245
End Sub00246
00247
Private Sub btnCancelar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnCancelar . Click
00248
Me . DialogResult = DialogResult . Cancel00249
Me . Visible = False00250
End Sub00251
00252
Private Sub txtCosteNodo_KeyPress ( ByVal sender As Object , ByVal e As System .» Windows . Forms . KeyPressEventArgs ) Handles txtCosteNodo . KeyPress
00253
InterceptaTeclas ( e )00254
00255
End Sub00256
00257
Private Sub txtCosteNodo_Leave ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles txtCosteNodo . Leave
00258
FiltraTexto ( sender )00259
End Sub00260
00261
00262
End Class00001
Public Class Form400002
Inherits System . Windows . Forms . Form00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'Form reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
Friend WithEvents Label1 As System . Windows . Forms . Label00033
Friend WithEvents Label2 As System . Windows . Forms . Label00034
Friend WithEvents btnAceptar As System . Windows . Forms . Button00035
Friend WithEvents btnCancelar As System . Windows . Forms . Button00036
Friend WithEvents txtminArco As System . Windows . Forms . TextBox00037
Friend WithEvents txtcostArco As System . Windows . Forms . TextBox00038
Friend WithEvents lblArco As System . Windows . Forms . Label00039
Friend WithEvents GroupBox2 As System . Windows . Forms . GroupBox00040
Friend WithEvents udTrazoArco As System . Windows . Forms . NumericUpDown00041
Friend WithEvents Label3 As System . Windows . Forms . Label00042
Friend WithEvents chkBArco As System . Windows . Forms . CheckBox00043
Friend WithEvents btnColorArco As System . Windows . Forms . Button00044
Friend WithEvents lblColorArco As System . Windows . Forms . Label00045
Friend WithEvents txtmaxArco As System . Windows . Forms . TextBox00046
Friend WithEvents Label4 As System . Windows . Forms . Label00047
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00048
Me . Label1 = New System . Windows . Forms . Label00049
Me . Label2 = New System . Windows . Forms . Label00050
Me . txtminArco = New System . Windows . Forms . TextBox00051
Me . txtcostArco = New System . Windows . Forms . TextBox00052
Me . btnAceptar = New System . Windows . Forms . Button00053
Me . btnCancelar = New System . Windows . Forms . Button00054
Me . lblArco = New System . Windows . Forms . Label00055
Me . GroupBox2 = New System . Windows . Forms . GroupBox00056
Me . udTrazoArco = New System . Windows . Forms . NumericUpDown00057
Me . Label3 = New System . Windows . Forms . Label00058
Me . chkBArco = New System . Windows . Forms . CheckBox00059
Me . btnColorArco = New System . Windows . Forms . Button00060
Me . lblColorArco = New System . Windows . Forms . Label00061
Me . txtmaxArco = New System . Windows . Forms . TextBox00062
Me . Label4 = New System . Windows . Forms . Label00063
Me . GroupBox2 . SuspendLayout ()00064
CType ( Me . udTrazoArco , System . ComponentModel . ISupportInitialize ) .» BeginInit ()
00065
Me . SuspendLayout ()00066
'00067
'Label100068
'00069
Me . Label1 . Location = New System . Drawing . Point ( 8 , 8 )00070
Me . Label1 . Name = "Label1"00071
Me . Label1 . Size = New System . Drawing . Size ( 72 , 24 )00072
Me . Label1 . TabIndex = 000073
Me . Label1 . Text = "Mínimo:"00074
'00075
'Label200076
'00077
Me . Label2 . Location = New System . Drawing . Point ( 80 , 48 )00078
Me . Label2 . Name = "Label2"00079
Me . Label2 . Size = New System . Drawing . Size ( 64 , 24 )00080
Me . Label2 . TabIndex = 100081
Me . Label2 . Text = "Coste:"00082
'00083
'txtminArco00084
'00085
Me . txtminArco . Location = New System . Drawing . Point ( 8 , 24 )00086
Me . txtminArco . Name = "txtminArco"00087
Me . txtminArco . Size = New System . Drawing . Size ( 104 , 20 )00088
Me . txtminArco . TabIndex = 200089
Me . txtminArco . Text = ""00090
'00091
'txtcostArco00092
'00093
Me . txtcostArco . Location = New System . Drawing . Point ( 80 , 64 )00094
Me . txtcostArco . Name = "txtcostArco"00095
Me . txtcostArco . Size = New System . Drawing . Size ( 104 , 20 )00096
Me . txtcostArco . TabIndex = 300097
Me . txtcostArco . Text = ""00098
'00099
'btnAceptar00100
'00101
Me . btnAceptar . Location = New System . Drawing . Point ( 176 , 200 )00102
Me . btnAceptar . Name = "btnAceptar"00103
Me . btnAceptar . Size = New System . Drawing . Size ( 80 , 24 )00104
Me . btnAceptar . TabIndex = 400105
Me . btnAceptar . Text = "Aceptar"00106
'00107
'btnCancelar00108
'00109
Me . btnCancelar . Location = New System . Drawing . Point ( 8 , 200 )00110
Me . btnCancelar . Name = "btnCancelar"00111
Me . btnCancelar . Size = New System . Drawing . Size ( 80 , 24 )00112
Me . btnCancelar . TabIndex = 500113
Me . btnCancelar . Text = "Cancelar"00114
'00115
'lblArco00116
'00117
Me . lblArco . BorderStyle = System . Windows . Forms . BorderStyle . Fixed3D00118
Me . lblArco . Location = New System . Drawing . Point ( 8 , 96 )00119
Me . lblArco . Name = "lblArco"00120
Me . lblArco . Size = New System . Drawing . Size ( 248 , 24 )00121
Me . lblArco . TabIndex = 600122
Me . lblArco . Text = "..."00123
'00124
'GroupBox200125
'00126
Me . GroupBox2 . Controls . Add ( Me . udTrazoArco )00127
Me . GroupBox2 . Controls . Add ( Me . Label3 )00128
Me . GroupBox2 . Controls . Add ( Me . chkBArco )00129
Me . GroupBox2 . Controls . Add ( Me . btnColorArco )00130
Me . GroupBox2 . Controls . Add ( Me . lblColorArco )00131
Me . GroupBox2 . Location = New System . Drawing . Point ( 8 , 120 )00132
Me . GroupBox2 . Name = "GroupBox2"00133
Me . GroupBox2 . Size = New System . Drawing . Size ( 248 , 72 )00134
Me . GroupBox2 . TabIndex = 1100135
Me . GroupBox2 . TabStop = False00136
'00137
'udTrazoArco00138
'00139
Me . udTrazoArco . Location = New System . Drawing . Point ( 56 , 16 )00140
Me . udTrazoArco . Maximum = New Decimal ( New Integer () { 8 , 0 , 0 , 0 })00141
Me . udTrazoArco . Minimum = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00142
Me . udTrazoArco . Name = "udTrazoArco"00143
Me . udTrazoArco . Size = New System . Drawing . Size ( 48 , 20 )00144
Me . udTrazoArco . TabIndex = 300145
Me . udTrazoArco . Value = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00146
'00147
'Label300148
'00149
Me . Label3 . Location = New System . Drawing . Point ( 8 , 16 )00150
Me . Label3 . Name = "Label3"00151
Me . Label3 . Size = New System . Drawing . Size ( 48 , 24 )00152
Me . Label3 . TabIndex = 800153
Me . Label3 . Text = "Trazo: "00154
Me . Label3 . TextAlign = System . Drawing . ContentAlignment . MiddleCenter00155
'00156
'chkBArco00157
'00158
Me . chkBArco . Location = New System . Drawing . Point ( 16 , 40 )00159
Me . chkBArco . Name = "chkBArco"00160
Me . chkBArco . Size = New System . Drawing . Size ( 88 , 24 )00161
Me . chkBArco . TabIndex = 500162
Me . chkBArco . Text = "Bidireccional"00163
Me . chkBArco . Visible = False00164
'00165
'btnColorArco00166
'00167
Me . btnColorArco . Location = New System . Drawing . Point ( 160 , 16 )00168
Me . btnColorArco . Name = "btnColorArco"00169
Me . btnColorArco . Size = New System . Drawing . Size ( 80 , 24 )00170
Me . btnColorArco . TabIndex = 600171
Me . btnColorArco . Text = "Color ..."00172
'00173
'lblColorArco00174
'00175
Me . lblColorArco . BackColor = System . Drawing . Color . Black00176
Me . lblColorArco . BorderStyle = System . Windows . Forms . BorderStyle .» FixedSingle
00177
Me . lblColorArco . Location = New System . Drawing . Point ( 128 , 16 )00178
Me . lblColorArco . Name = "lblColorArco"00179
Me . lblColorArco . Size = New System . Drawing . Size ( 24 , 24 )00180
Me . lblColorArco . TabIndex = 1100181
'00182
'txtmaxArco00183
'00184
Me . txtmaxArco . Location = New System . Drawing . Point ( 152 , 24 )00185
Me . txtmaxArco . Name = "txtmaxArco"00186
Me . txtmaxArco . Size = New System . Drawing . Size ( 104 , 20 )00187
Me . txtmaxArco . TabIndex = 1300188
Me . txtmaxArco . Text = ""00189
'00190
'Label400191
'00192
Me . Label4 . Location = New System . Drawing . Point ( 152 , 8 )00193
Me . Label4 . Name = "Label4"00194
Me . Label4 . Size = New System . Drawing . Size ( 72 , 24 )00195
Me . Label4 . TabIndex = 1200196
Me . Label4 . Text = "Máximo:"00197
'00198
'Form400199
'00200
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00201
Me . ClientSize = New System . Drawing . Size ( 266 , 231 )00202
Me . Controls . Add ( Me . txtmaxArco )00203
Me . Controls . Add ( Me . Label4 )00204
Me . Controls . Add ( Me . GroupBox2 )00205
Me . Controls . Add ( Me . lblArco )00206
Me . Controls . Add ( Me . btnCancelar )00207
Me . Controls . Add ( Me . btnAceptar )00208
Me . Controls . Add ( Me . txtcostArco )00209
Me . Controls . Add ( Me . txtminArco )00210
Me . Controls . Add ( Me . Label2 )00211
Me . Controls . Add ( Me . Label1 )00212
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle .» FixedToolWindow
00213
Me . MaximizeBox = False00214
Me . MinimizeBox = False00215
Me . Name = "Form4"00216
Me . Text = "Grafos - Editar Arco"00217
Me . TopMost = True00218
Me . GroupBox2 . ResumeLayout ( False )00219
CType ( Me . udTrazoArco , System . ComponentModel . ISupportInitialize ) . EndInit (» )
00220
Me . ResumeLayout ( False )00221
00222
End Sub00223
00224
# End Region00225
00226
Dim Narc As Long00227
00228
00229
00230
Private Sub Form4_Load ( ByVal sender As System . Object , ByVal e As System .» EventArgs ) Handles MyBase . Load
00231
00232
Dim i As Long00233
For i = 0 To Form1 . TotalArcos - 100234
If Form1 . Arcos ( i ) . Nd1 = Form1 . Nd1S And Form1 . Arcos ( i ) . Nd2 = Form1 .» Nd2S Then
00235
Narc = i00236
Exit For00237
00238
End If00239
Next i00240
00241
00242
'Toma los valores del nodo a editar00243
txtminArco . Text = Form1 . Arcos ( Narc ) . Min00244
txtmaxArco . Text = Form1 . Arcos ( Narc ) . Max00245
txtcostArco . Text = Form1 . Arcos ( Narc ) . Coste00246
00247
lblArco . Text = " Nd1 = " & Form1 . Nodos ( Form1 . Arcos ( Narc ) . Nd1 ) . Texto &» " Nd2 = " & Form1 . Nodos ( Form1 . Arcos ( Narc ) . Nd2 ) . Texto
00248
lblColorArco . BackColor = Form1 . Arcos ( Narc ) . Col00249
chkBArco . Checked = Form1 . Arcos ( Narc ) . B00250
udTrazoArco . Value = Form1 . Arcos ( Narc ) . Grosor00251
00252
End Sub00253
00254
Private Sub btnAceptar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnAceptar . Click
00255
'Cambia los valores del nodo según los editados00256
Form1 . Arcos ( Narc ) . Min = CSng ( txtminArco . Text )00257
Form1 . Arcos ( Narc ) . Max = CSng ( txtmaxArco . Text )00258
Form1 . Arcos ( Narc ) . Coste = CSng ( txtcostArco . Text )00259
00260
Form1 . Arcos ( Narc ) . Col = lblColorArco . BackColor00261
Form1 . Arcos ( Narc ) . B = chkBArco . Checked00262
Form1 . Arcos ( Narc ) . Grosor = udTrazoArco . Value00263
00264
00265
Me . DialogResult = DialogResult . OK00266
00267
00268
End Sub00269
00270
Private Sub btnCancelar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnCancelar . Click
00271
Me . DialogResult = DialogResult . Cancel00272
Me . Visible = False00273
End Sub00274
00275
Private Sub btnColorArco_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnColorArco . Click
00276
lblColorArco . BackColor = DialogoColor ( lblColorArco . BackColor )00277
End Sub00278
00279
00280
00281
Private Sub txtminArco_KeyPress ( ByVal sender As Object , ByVal e As System .» Windows . Forms . KeyPressEventArgs ) Handles txtminArco . KeyPress
00282
InterceptaTeclas ( e )00283
00284
End Sub00285
00286
Private Sub txtcostArco_KeyPress ( ByVal sender As Object , ByVal e As System .» Windows . Forms . KeyPressEventArgs ) Handles txtcostArco . KeyPress
00287
InterceptaTeclas ( e )00288
00289
End Sub00290
00291
Private Sub txtmaxArco_KeyPress ( ByVal sender As Object , ByVal e As System .» Windows . Forms . KeyPressEventArgs ) Handles txtmaxArco . KeyPress
00292
InterceptaTeclas ( e )00293
00294
End Sub00295
00296
00297
00298
Private Sub txtminArco_Leave ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles txtminArco . Leave
00299
FiltraTexto ( sender )00300
End Sub00301
00302
Private Sub txtcostArco_Leave ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles txtcostArco . Leave
00303
FiltraTexto ( sender )00304
End Sub00305
00306
Private Sub txtmaxArco_Leave ( ByVal sender As Object , ByVal e As System .» EventArgs ) Handles txtmaxArco . Leave
00307
FiltraTexto ( sender )00308
End Sub00309
End Class00001
Public Class Form500002
Inherits System . Windows . Forms . Form00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'Form reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
Friend WithEvents btnAceptar As System . Windows . Forms . Button00033
Friend WithEvents btnCancelar As System . Windows . Forms . Button00034
Friend WithEvents Label1 As System . Windows . Forms . Label00035
Friend WithEvents GroupBox1 As System . Windows . Forms . GroupBox00036
Friend WithEvents udTotalNodos As System . Windows . Forms . NumericUpDown00037
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00038
Me . btnAceptar = New System . Windows . Forms . Button00039
Me . btnCancelar = New System . Windows . Forms . Button00040
Me . Label1 = New System . Windows . Forms . Label00041
Me . GroupBox1 = New System . Windows . Forms . GroupBox00042
Me . udTotalNodos = New System . Windows . Forms . NumericUpDown00043
Me . GroupBox1 . SuspendLayout ()00044
CType ( Me . udTotalNodos , System . ComponentModel . ISupportInitialize ) .» BeginInit ()
00045
Me . SuspendLayout ()00046
'00047
'btnAceptar00048
'00049
Me . btnAceptar . Location = New System . Drawing . Point ( 128 , 88 )00050
Me . btnAceptar . Name = "btnAceptar"00051
Me . btnAceptar . Size = New System . Drawing . Size ( 80 , 24 )00052
Me . btnAceptar . TabIndex = 000053
Me . btnAceptar . Text = "Aceptar"00054
'00055
'btnCancelar00056
'00057
Me . btnCancelar . Location = New System . Drawing . Point ( 8 , 88 )00058
Me . btnCancelar . Name = "btnCancelar"00059
Me . btnCancelar . Size = New System . Drawing . Size ( 80 , 24 )00060
Me . btnCancelar . TabIndex = 000061
Me . btnCancelar . Text = "Cancelar"00062
'00063
'Label100064
'00065
Me . Label1 . ImageAlign = System . Drawing . ContentAlignment . MiddleRight00066
Me . Label1 . Location = New System . Drawing . Point ( 8 , 24 )00067
Me . Label1 . Name = "Label1"00068
Me . Label1 . Size = New System . Drawing . Size ( 80 , 24 )00069
Me . Label1 . TabIndex = 100070
Me . Label1 . Text = "Total Nodos: "00071
Me . Label1 . TextAlign = System . Drawing . ContentAlignment . MiddleRight00072
'00073
'GroupBox100074
'00075
Me . GroupBox1 . Controls . Add ( Me . udTotalNodos )00076
Me . GroupBox1 . Controls . Add ( Me . Label1 )00077
Me . GroupBox1 . Location = New System . Drawing . Point ( 8 , 0 )00078
Me . GroupBox1 . Name = "GroupBox1"00079
Me . GroupBox1 . Size = New System . Drawing . Size ( 200 , 72 )00080
Me . GroupBox1 . TabIndex = 200081
Me . GroupBox1 . TabStop = False00082
'00083
'udTotalNodos00084
'00085
Me . udTotalNodos . Location = New System . Drawing . Point ( 104 , 24 )00086
Me . udTotalNodos . Maximum = New Decimal ( New Integer () { 200 , 0 , 0 , 0 })00087
Me . udTotalNodos . Minimum = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00088
Me . udTotalNodos . Name = "udTotalNodos"00089
Me . udTotalNodos . Size = New System . Drawing . Size ( 64 , 20 )00090
Me . udTotalNodos . TabIndex = 200091
Me . udTotalNodos . TextAlign = System . Windows . Forms . HorizontalAlignment .» Right
00092
Me . udTotalNodos . Value = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00093
'00094
'Form500095
'00096
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00097
Me . ClientSize = New System . Drawing . Size ( 218 , 119 )00098
Me . Controls . Add ( Me . GroupBox1 )00099
Me . Controls . Add ( Me . btnAceptar )00100
Me . Controls . Add ( Me . btnCancelar )00101
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle .» FixedToolWindow
00102
Me . MaximizeBox = False00103
Me . MinimizeBox = False00104
Me . Name = "Form5"00105
Me . Text = "Grafos - Total Nodos"00106
Me . TopMost = True00107
Me . GroupBox1 . ResumeLayout ( False )00108
CType ( Me . udTotalNodos , System . ComponentModel . ISupportInitialize ) . EndInit» ()
00109
Me . ResumeLayout ( False )00110
00111
End Sub00112
00113
# End Region00114
00115
Private Sub btnCancelar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnCancelar . Click
00116
'cierra el cuadro sin pena ni gloria00117
Me . DialogResult = DialogResult . Cancel00118
Me . Visible = False00119
End Sub00120
00121
Private Sub btnAceptar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnAceptar . Click
00122
'establece el nuevo valor de nodosmatriz00123
If udTotalNodos . Value > udTotalNodos . Maximum Then00124
udTotalNodos . Value = udTotalNodos . Maximum00125
End If00126
Form1 . NuevoNodosMatriz = udTotalNodos . Value00127
'cierra el cuadro y marca como que los cambios son ok00128
Me . DialogResult = DialogResult . OK00129
Me . Visible = False00130
End Sub00131
00132
Private Sub Form5_Load ( ByVal sender As System . Object , ByVal e As System .» EventArgs ) Handles MyBase . Load
00133
'toma el valor actual de nodosmatriz00134
udTotalNodos . Value = Form1 . NuevoNodosMatriz00135
00136
End Sub00137
00138
00139
End Class00001
00002
Public Class Form600003
00004
00005
Inherits System . Windows . Forms . Form00006
00007
Public Event ActualizaGrafo ( ByVal valor As Boolean )00008
# Region " Código generado por el Diseñador de Windows Forms "00009
00010
Public Sub New ()00011
MyBase . New ()00012
00013
'El Diseñador de Windows Forms requiere esta llamada.00014
InitializeComponent ()00015
00016
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00017
00018
End Sub00019
00020
'Form reemplaza a Dispose para limpiar la lista de componentes.00021
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00022
If disposing Then00023
If Not ( components Is Nothing ) Then00024
components . Dispose ()00025
End If00026
End If00027
MyBase . Dispose ( disposing )00028
End Sub00029
00030
'Requerido por el Diseñador de Windows Forms00031
Private components As System . ComponentModel . IContainer00032
00033
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00034
'Puede modificarse utilizando el Diseñador de Windows Forms.00035
'No lo modifique con el editor de código.00036
Friend WithEvents txtResultados As System . Windows . Forms . TextBox00037
Friend WithEvents ToolBar1 As System . Windows . Forms . ToolBar00038
Friend WithEvents ImageList1 As System . Windows . Forms . ImageList00039
Friend WithEvents btnGrabarResult As System . Windows . Forms . ToolBarButton00040
Friend WithEvents btnFontResult As System . Windows . Forms . ToolBarButton00041
Friend WithEvents ToolBarButton1 As System . Windows . Forms . ToolBarButton00042
Friend WithEvents ToolBarButton2 As System . Windows . Forms . ToolBarButton00043
Friend WithEvents btnCopiarResult As System . Windows . Forms . ToolBarButton00044
Friend WithEvents printDialog1 As System . Windows . Forms . PrintDialog00045
Friend WithEvents ThePrintDocument As System . Drawing . Printing . PrintDocument00046
Friend WithEvents btnPrintSetup As System . Windows . Forms . ToolBarButton00047
Friend WithEvents btnPrintPreview As System . Windows . Forms . ToolBarButton00048
Friend WithEvents ToolBarButton3 As System . Windows . Forms . ToolBarButton00049
Friend WithEvents ConfigPag As System . Windows . Forms . ToolBarButton00050
Friend WithEvents PageSetupDialog1 As System . Windows . Forms . PageSetupDialog00051
Friend WithEvents PrintPreviewDialog1 As System . Windows . Forms .» PrintPreviewDialog
00052
Friend WithEvents btnSolucionGrafo As System . Windows . Forms . ToolBarButton00053
Friend WithEvents btnVerLP As System . Windows . Forms . ToolBarButton00054
Friend WithEvents ToolBarButton6 As System . Windows . Forms . ToolBarButton00055
Friend WithEvents btnCerrar As System . Windows . Forms . ToolBarButton00056
Friend WithEvents btnVerMPS As System . Windows . Forms . ToolBarButton00057
Friend WithEvents ToolBarButton4 As System . Windows . Forms . ToolBarButton00058
Friend WithEvents btnVerResultados As System . Windows . Forms . ToolBarButton00059
Friend WithEvents ToolBarButton5 As System . Windows . Forms . ToolBarButton00060
Friend WithEvents ToolBarButton7 As System . Windows . Forms . ToolBarButton00061
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00062
Me . components = New System . ComponentModel . Container00063
Dim resources As System . Resources . ResourceManager = New System . Resources» . ResourceManager ( GetType ( Form6 ))
00064
Me . txtResultados = New System . Windows . Forms . TextBox00065
Me . ToolBar1 = New System . Windows . Forms . ToolBar00066
Me . btnGrabarResult = New System . Windows . Forms . ToolBarButton00067
Me . ToolBarButton1 = New System . Windows . Forms . ToolBarButton00068
Me . btnCopiarResult = New System . Windows . Forms . ToolBarButton00069
Me . btnFontResult = New System . Windows . Forms . ToolBarButton00070
Me . ToolBarButton2 = New System . Windows . Forms . ToolBarButton00071
Me . btnPrintSetup = New System . Windows . Forms . ToolBarButton00072
Me . ConfigPag = New System . Windows . Forms . ToolBarButton00073
Me . btnPrintPreview = New System . Windows . Forms . ToolBarButton00074
Me . ToolBarButton3 = New System . Windows . Forms . ToolBarButton00075
Me . btnSolucionGrafo = New System . Windows . Forms . ToolBarButton00076
Me . btnVerLP = New System . Windows . Forms . ToolBarButton00077
Me . ToolBarButton6 = New System . Windows . Forms . ToolBarButton00078
Me . btnCerrar = New System . Windows . Forms . ToolBarButton00079
Me . ImageList1 = New System . Windows . Forms . ImageList ( Me . components )00080
Me . printDialog1 = New System . Windows . Forms . PrintDialog00081
Me . ThePrintDocument = New System . Drawing . Printing . PrintDocument00082
Me . PageSetupDialog1 = New System . Windows . Forms . PageSetupDialog00083
Me . PrintPreviewDialog1 = New System . Windows . Forms . PrintPreviewDialog00084
Me . btnVerMPS = New System . Windows . Forms . ToolBarButton00085
Me . ToolBarButton4 = New System . Windows . Forms . ToolBarButton00086
Me . btnVerResultados = New System . Windows . Forms . ToolBarButton00087
Me . ToolBarButton5 = New System . Windows . Forms . ToolBarButton00088
Me . ToolBarButton7 = New System . Windows . Forms . ToolBarButton00089
Me . SuspendLayout ()00090
'00091
'txtResultados00092
'00093
Me . txtResultados . AcceptsReturn = True00094
Me . txtResultados . AcceptsTab = True00095
Me . txtResultados . Anchor = CType (((( System . Windows . Forms . AnchorStyles . Top» Or System . Windows . Forms . AnchorStyles . Bottom ) _
00096
Or System . Windows . Forms . AnchorStyles . Left ) _00097
Or System . Windows . Forms . AnchorStyles . Right ), System . Windows» . Forms . AnchorStyles )
00098
Me . txtResultados . Font = New System . Drawing . Font ( "Courier New" , 9.0 !,» System . Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point ,
» CType ( 0 , Byte ))
00099
Me . txtResultados . Location = New System . Drawing . Point ( 0 , 32 )00100
Me . txtResultados . Multiline = True00101
Me . txtResultados . Name = "txtResultados"00102
Me . txtResultados . ScrollBars = System . Windows . Forms . ScrollBars . Both00103
Me . txtResultados . Size = New System . Drawing . Size ( 376 , 256 )00104
Me . txtResultados . TabIndex = 000105
Me . txtResultados . Text = ""00106
Me . txtResultados . WordWrap = False00107
'00108
'ToolBar100109
'00110
Me . ToolBar1 . Buttons . AddRange ( New System . Windows . Forms . ToolBarButton () {» Me . btnGrabarResult , Me . ToolBarButton1 , Me . btnCopiarResult , Me .
» btnFontResult , Me . ToolBarButton2 , Me . btnPrintSetup , Me . ConfigPag , Me .
» btnPrintPreview , Me . ToolBarButton3 , Me . btnSolucionGrafo , Me .
» ToolBarButton4 , Me . btnVerResultados , Me . btnVerLP , Me . btnVerMPS , Me .
» ToolBarButton6 , Me . ToolBarButton5 , Me . ToolBarButton7 , Me . btnCerrar })
00111
Me . ToolBar1 . DropDownArrows = True00112
Me . ToolBar1 . ImageList = Me . ImageList100113
Me . ToolBar1 . Location = New System . Drawing . Point ( 0 , 0 )00114
Me . ToolBar1 . Name = "ToolBar1"00115
Me . ToolBar1 . ShowToolTips = True00116
Me . ToolBar1 . Size = New System . Drawing . Size ( 376 , 28 )00117
Me . ToolBar1 . TabIndex = 100118
'00119
'btnGrabarResult00120
'00121
Me . btnGrabarResult . ImageIndex = 000122
Me . btnGrabarResult . Tag = "Grabar"00123
Me . btnGrabarResult . ToolTipText = "Grabar resultados..."00124
'00125
'ToolBarButton100126
'00127
Me . ToolBarButton1 . Style = System . Windows . Forms . ToolBarButtonStyle .» Separator
00128
'00129
'btnCopiarResult00130
'00131
Me . btnCopiarResult . ImageIndex = 300132
Me . btnCopiarResult . Tag = "Copiar"00133
Me . btnCopiarResult . ToolTipText = "Copiar todo al portapapeles"00134
'00135
'btnFontResult00136
'00137
Me . btnFontResult . ImageIndex = 200138
Me . btnFontResult . Tag = "Tamaño"00139
Me . btnFontResult . ToolTipText = "Cambiar tamaño de letra"00140
'00141
'ToolBarButton200142
'00143
Me . ToolBarButton2 . Style = System . Windows . Forms . ToolBarButtonStyle .» Separator
00144
'00145
'btnPrintSetup00146
'00147
Me . btnPrintSetup . ImageIndex = 400148
Me . btnPrintSetup . Tag = "ConfigImpresora"00149
Me . btnPrintSetup . ToolTipText = "Configurar impresora..."00150
'00151
'ConfigPag00152
'00153
Me . ConfigPag . ImageIndex = 700154
Me . ConfigPag . Tag = "ConfigPagina"00155
Me . ConfigPag . ToolTipText = "Configurar página..."00156
'00157
'btnPrintPreview00158
'00159
Me . btnPrintPreview . ImageIndex = 600160
Me . btnPrintPreview . Tag = "Previsualizar"00161
Me . btnPrintPreview . ToolTipText = "Previsualizar e imprimir resultados"00162
'00163
'ToolBarButton300164
'00165
Me . ToolBarButton3 . Style = System . Windows . Forms . ToolBarButtonStyle .» Separator
00166
'00167
'btnSolucionGrafo00168
'00169
Me . btnSolucionGrafo . ImageIndex = 800170
Me . btnSolucionGrafo . Pushed = True00171
Me . btnSolucionGrafo . Style = System . Windows . Forms . ToolBarButtonStyle .» ToggleButton
00172
Me . btnSolucionGrafo . Tag = "VerSolucion"00173
Me . btnSolucionGrafo . ToolTipText = "Ver Solución o Grafo original"00174
'00175
'btnVerLP00176
'00177
Me . btnVerLP . Enabled = False00178
Me . btnVerLP . ImageIndex = 1000179
Me . btnVerLP . Style = System . Windows . Forms . ToolBarButtonStyle . ToggleButton00180
Me . btnVerLP . Tag = "VerLP"00181
Me . btnVerLP . ToolTipText = "Mostrar fichero Modelo .LP"00182
'00183
'ToolBarButton600184
'00185
Me . ToolBarButton6 . Style = System . Windows . Forms . ToolBarButtonStyle .» Separator
00186
'00187
'btnCerrar00188
'00189
Me . btnCerrar . ImageIndex = 900190
Me . btnCerrar . Tag = "Cerrar"00191
Me . btnCerrar . ToolTipText = "Cerrar ventana Resultados"00192
'00193
'ImageList100194
'00195
Me . ImageList1 . ImageSize = New System . Drawing . Size ( 16 , 16 )00196
Me . ImageList1 . ImageStream = CType ( resources . GetObject (» "ImageList1.ImageStream" ), System . Windows . Forms . ImageListStreamer )
00197
Me . ImageList1 . TransparentColor = System . Drawing . Color . Transparent00198
'00199
'ThePrintDocument00200
'00201
'00202
'PrintPreviewDialog100203
'00204
Me . PrintPreviewDialog1 . AutoScrollMargin = New System . Drawing . Size ( 0 , 0 )00205
Me . PrintPreviewDialog1 . AutoScrollMinSize = New System . Drawing . Size ( 0 , 0 )00206
Me . PrintPreviewDialog1 . ClientSize = New System . Drawing . Size ( 400 , 300 )00207
Me . PrintPreviewDialog1 . Enabled = True00208
Me . PrintPreviewDialog1 . Icon = CType ( resources . GetObject (» "PrintPreviewDialog1.Icon" ), System . Drawing . Icon )
00209
Me . PrintPreviewDialog1 . Location = New System . Drawing . Point ( 528 , 17 )00210
Me . PrintPreviewDialog1 . MinimumSize = New System . Drawing . Size ( 375 , 250 )00211
Me . PrintPreviewDialog1 . Name = "PrintPreviewDialog1"00212
Me . PrintPreviewDialog1 . TransparencyKey = System . Drawing . Color . Empty00213
Me . PrintPreviewDialog1 . Visible = False00214
'00215
'btnVerMPS00216
'00217
Me . btnVerMPS . Enabled = False00218
Me . btnVerMPS . ImageIndex = 1100219
Me . btnVerMPS . Style = System . Windows . Forms . ToolBarButtonStyle .» ToggleButton
00220
Me . btnVerMPS . Tag = "VerMPS"00221
Me . btnVerMPS . ToolTipText = "Mostrar fichero Modelo .MPS"00222
'00223
'ToolBarButton400224
'00225
Me . ToolBarButton4 . Style = System . Windows . Forms . ToolBarButtonStyle .» Separator
00226
'00227
'btnVerResultados00228
'00229
Me . btnVerResultados . ImageIndex = 1200230
Me . btnVerResultados . Pushed = True00231
Me . btnVerResultados . Style = System . Windows . Forms . ToolBarButtonStyle .» ToggleButton
00232
Me . btnVerResultados . Tag = "VerResultados"00233
Me . btnVerResultados . ToolTipText = "Mostrar resultados del análisis"00234
'00235
'ToolBarButton500236
'00237
Me . ToolBarButton5 . Style = System . Windows . Forms . ToolBarButtonStyle .» Separator
00238
'00239
'ToolBarButton700240
'00241
Me . ToolBarButton7 . Style = System . Windows . Forms . ToolBarButtonStyle .» Separator
00242
'00243
'Form600244
'00245
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00246
Me . ClientSize = New System . Drawing . Size ( 376 , 288 )00247
Me . ControlBox = False00248
Me . Controls . Add ( Me . ToolBar1 )00249
Me . Controls . Add ( Me . txtResultados )00250
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle .» SizableToolWindow
00251
Me . Icon = CType ( resources . GetObject ( "$this.Icon" ), System . Drawing . Icon )00252
Me . Name = "Form6"00253
Me . Text = " Grafos - Resultados del Análisis"00254
Me . TopMost = True00255
Me . ResumeLayout ( False )00256
00257
End Sub00258
00259
# End Region00260
00261
00262
00263
00264
00265
00266
Private Sub ToolBar1_ButtonClick ( ByVal sender As System . Object , ByVal e As» System . Windows . Forms . ToolBarButtonClickEventArgs ) Handles ToolBar1 .
» ButtonClick
00267
Select Case e . Button . Tag00268
Case "Grabar"00269
'Esta opción de menú muestra el cuadro de diálogo00270
'de grabar fichero de resultados00271
00272
Dim saveFileDialog1 As New SaveFileDialog00273
saveFileDialog1 . AddExtension = True00274
saveFileDialog1 . DefaultExt = ".txt"00275
saveFileDialog1 . Filter = "Fichero de texto (*.txt)|*.txt|Todos» los archivos (*.*)|*.*"
00276
saveFileDialog1 . FilterIndex = 1 'formato por defecto .txt00277
saveFileDialog1 . Title = "Guardar resultados del análisis"00278
saveFileDialog1 . RestoreDirectory = True00279
Try00280
If saveFileDialog1 . ShowDialog () = DialogResult . OK Then00281
'llama al menu de guardar00282
EscribeFicheroTexto ( saveFileDialog1 . FileName , Me .» txtResultados . Text )
00283
End If00284
Catch00285
Exit Sub00286
End Try00287
00288
00289
Case "ConfigImpresora"00290
'Configura impresora y parámetros de impresión00291
With printDialog100292
. PrinterSettings = Me . ThePrintDocument . PrinterSettings00293
If . ShowDialog () = DialogResult . OK Then00294
Me . ThePrintDocument . PrinterSettings = . PrinterSettings00295
End If00296
End With00297
00298
00299
Case "ConfigPagina"00300
'Establece configuración de página00301
With PageSetupDialog100302
. PageSettings = Me . ThePrintDocument . DefaultPageSettings00303
If . ShowDialog () = DialogResult . OK Then00304
Me . ThePrintDocument . DefaultPageSettings = . PageSettings00305
End If00306
End With00307
00308
00309
00310
Case "Previsualizar"00311
Try00312
'Muestra el diálogo de previsualización00313
'que a su vez llama al evento PrintPage de PrintDocument100314
00315
Me . WindowState = FormWindowState . Normal00316
00317
'Dim strText As String = Me.txtResultados.Text00318
'myReader = New StringReader(strText)00319
PrintPreviewDialog1 . Document = Me . ThePrintDocument00320
00321
PrintPreviewDialog1 . ShowDialog ()00322
00323
Catch exp As Exception00324
MsgBox ( "Ha fallado la operación de impresión." & vbCrLf &» exp . Message , MsgBoxStyle . Exclamation , "Grafos -
» Excepción" )
00325
End Try00326
00327
'Case "Imprimir"00328
' Exit Sub00329
' 'Imprimir texto00330
' printDialog1.Document = ThePrintDocument00331
' Dim strText As String = Me.txtResultados.Text00332
' myReader = New StringReader(strText)00333
' If printDialog1.ShowDialog() = DialogResult.OK Then00334
' Me.ThePrintDocument.Print()00335
' End If00336
00337
Case "Tamaño"00338
'cambia el tamaño de letra, útil para monitores grandes00339
'o personas con problemas de visualización00340
Dim n As String00341
Dim t As Single00342
Dim v As Integer00343
'toma características de la fuente original00344
n = Me . txtResultados . Font . Name00345
t = Me . txtResultados . Font . Size00346
v = Me . txtResultados . Font . Style00347
'incrementa el tamaño de la letra progresivamente00348
If t < 24 Then00349
t = t + 200350
Else00351
t = 600352
End If00353
'Crea fuente con nuevas características y establece00354
Dim F As New Font ( n , t , v , GraphicsUnit . Pixel )00355
Me . txtResultados . Font = F00356
Case "Copiar"00357
'copia todo el contenido del cuadro de texto al00358
'portapapeles00359
Me . txtResultados . SelectAll ()00360
Me . txtResultados . Copy ()00361
00362
00363
Case "VerSolucion"00364
'intercambia la solución a previsualizar00365
'y redibuja el grafo00366
00367
00368
Dim i , j As Long00369
If Me . btnSolucionGrafo . Pushed = True Then00370
00371
For i = 0 To Form1 . TotalNodos - 100372
Form1 . Nodos ( i ) = Form1 . NodosSol ( i )00373
Next i00374
For j = 0 To Form1 . TotalArcos - 100375
Form1 . Arcos ( j ) = Form1 . ArcosSol ( j )00376
Next j00377
Else00378
For i = 0 To Form1 . TotalNodos - 100379
Form1 . Nodos ( i ) = Form1 . NodosPrev ( i )00380
Next i00381
For j = 0 To Form1 . TotalArcos - 100382
Form1 . Arcos ( j ) = Form1 . ArcosPrev ( j )00383
Next j00384
End If00385
00386
RaiseEvent ActualizaGrafo ( True )00387
00388
00389
00390
Case "VerResultados"00391
Me . btnVerResultados . Pushed = True00392
00393
If Form1 . AlgoritmoMILP = True Then00394
Me . btnVerLP . Pushed = False00395
Me . btnVerMPS . Pushed = False00396
End If00397
00398
txtResultados . Text = Form1 . txtResultadosAlgoritmo00399
00400
Case "VerLP"00401
Me . btnVerResultados . Pushed = False00402
Me . btnVerLP . Pushed = True00403
Me . btnVerMPS . Pushed = False00404
00405
LeeFicheroTexto ( CurDir () & "\GrafosLP~.lp" , txtResultados . Text )00406
00407
Case "VerMPS"00408
Me . btnVerResultados . Pushed = False00409
Me . btnVerLP . Pushed = False00410
Me . btnVerMPS . Pushed = True00411
00412
LeeFicheroTexto ( CurDir () & "\GrafosLP~.mps" , txtResultados . Text» )
00413
00414
Case "Cerrar"00415
txtResultados . Text = ""00416
Form1 . txtResultadosAlgoritmo = Nothing00417
'Me.DialogResult = DialogResult.OK00418
Me . Visible = False00419
End Select00420
End Sub00421
00422
00423
Private Sub ThePrintDocument_PrintPage ( ByVal sender As Object , ByVal ev As» System . Drawing . Printing . PrintPageEventArgs ) Handles ThePrintDocument .
» PrintPage
00424
'imprime un texto con esta rutina que escribe caracter a caracter...00425
Dim leftMargin As Single = ev . MarginBounds . Left00426
Dim topMargin As Single = ev . MarginBounds . Top00427
Dim printFont As Font = Me . txtResultados . Font00428
Dim myBrush As New SolidBrush ( Color . Black )00429
00430
Static curchar As Long00431
00432
Dim txtW , txtH , LM , TM As Integer00433
00434
00435
With ThePrintDocument . DefaultPageSettings00436
txtH = . PaperSize . Height - . Margins . Top - . Margins . Bottom00437
txtW = . PaperSize . Width - . Margins . Left - . Margins . Right00438
LM = . Margins . Left00439
TM = . Margins . Top00440
End With00441
00442
00443
If ThePrintDocument . DefaultPageSettings . Landscape Then00444
Dim tmp As Integer00445
tmp = txtH00446
txtH = txtW00447
txtW = tmp00448
End If00449
Dim R As New RectangleF ( LM , TM , txtW , txtH )00450
Dim chars , lineas As Long00451
Dim fmt As New StringFormat ( StringFormatFlags . LineLimit )00452
00453
00454
ev . Graphics . MeasureString ( Mid ( Me . txtResultados . Text , curchar + 1 ),» printFont , New SizeF ( txtW , txtH ), fmt , chars , lineas )
00455
ev . Graphics . DrawString ( Mid ( Me . txtResultados . Text , curchar + 1 ),» printFont , Brushes . Black , R , fmt )
00456
00457
curchar = curchar + chars00458
If curchar < Me . txtResultados . Text . Length Then00459
ev . HasMorePages = True00460
Else00461
ev . HasMorePages = False00462
curchar = 000463
End If00464
00465
00466
00467
End Sub00468
00469
00470
00471
Protected Overrides Sub Finalize ()00472
MyBase . Finalize ()00473
End Sub00474
End Class00001
Public Class frmExportarDatos00002
Inherits System . Windows . Forms . Form00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'Form reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
Friend WithEvents btnExportar As System . Windows . Forms . Button00033
Friend WithEvents btnCancelar As System . Windows . Forms . Button00034
Friend WithEvents GroupBox2 As System . Windows . Forms . GroupBox00035
Friend WithEvents GroupBox3 As System . Windows . Forms . GroupBox00036
Friend WithEvents gbOpciones As System . Windows . Forms . GroupBox00037
Friend WithEvents chkMatrizBinaria As System . Windows . Forms . CheckBox00038
Friend WithEvents chkMatrizMinimo As System . Windows . Forms . CheckBox00039
Friend WithEvents chkMatrizMaximo As System . Windows . Forms . CheckBox00040
Friend WithEvents chkMatrizCoste As System . Windows . Forms . CheckBox00041
Friend WithEvents chkMatrizEtiqueta As System . Windows . Forms . CheckBox00042
Friend WithEvents chkMatrizValor As System . Windows . Forms . CheckBox00043
Friend WithEvents pbExportar As System . Windows . Forms . ProgressBar00044
Friend WithEvents Label1 As System . Windows . Forms . Label00045
Friend WithEvents txtFL As System . Windows . Forms . TextBox00046
Friend WithEvents Label2 As System . Windows . Forms . Label00047
Friend WithEvents Label3 As System . Windows . Forms . Label00048
Friend WithEvents txtSP As System . Windows . Forms . TextBox00049
Friend WithEvents txtNV As System . Windows . Forms . TextBox00050
Friend WithEvents chkSPTab As System . Windows . Forms . CheckBox00051
Friend WithEvents chkMatrizEtiquetaValor As System . Windows . Forms . CheckBox00052
Friend WithEvents GroupBox1 As System . Windows . Forms . GroupBox00053
Friend WithEvents chkInfoGrafos As System . Windows . Forms . CheckBox00054
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00055
Me . btnExportar = New System . Windows . Forms . Button00056
Me . btnCancelar = New System . Windows . Forms . Button00057
Me . gbOpciones = New System . Windows . Forms . GroupBox00058
Me . GroupBox3 = New System . Windows . Forms . GroupBox00059
Me . chkMatrizEtiqueta = New System . Windows . Forms . CheckBox00060
Me . chkMatrizValor = New System . Windows . Forms . CheckBox00061
Me . chkMatrizEtiquetaValor = New System . Windows . Forms . CheckBox00062
Me . GroupBox1 = New System . Windows . Forms . GroupBox00063
Me . chkInfoGrafos = New System . Windows . Forms . CheckBox00064
Me . chkSPTab = New System . Windows . Forms . CheckBox00065
Me . Label1 = New System . Windows . Forms . Label00066
Me . GroupBox2 = New System . Windows . Forms . GroupBox00067
Me . chkMatrizBinaria = New System . Windows . Forms . CheckBox00068
Me . chkMatrizMinimo = New System . Windows . Forms . CheckBox00069
Me . chkMatrizMaximo = New System . Windows . Forms . CheckBox00070
Me . chkMatrizCoste = New System . Windows . Forms . CheckBox00071
Me . txtFL = New System . Windows . Forms . TextBox00072
Me . Label2 = New System . Windows . Forms . Label00073
Me . Label3 = New System . Windows . Forms . Label00074
Me . txtSP = New System . Windows . Forms . TextBox00075
Me . txtNV = New System . Windows . Forms . TextBox00076
Me . pbExportar = New System . Windows . Forms . ProgressBar00077
Me . gbOpciones . SuspendLayout ()00078
Me . GroupBox3 . SuspendLayout ()00079
Me . GroupBox1 . SuspendLayout ()00080
Me . GroupBox2 . SuspendLayout ()00081
Me . SuspendLayout ()00082
'00083
'btnExportar00084
'00085
Me . btnExportar . Location = New System . Drawing . Point ( 176 , 224 )00086
Me . btnExportar . Name = "btnExportar"00087
Me . btnExportar . Size = New System . Drawing . Size ( 88 , 24 )00088
Me . btnExportar . TabIndex = 000089
Me . btnExportar . Text = "Exportar"00090
'00091
'btnCancelar00092
'00093
Me . btnCancelar . Location = New System . Drawing . Point ( 272 , 224 )00094
Me . btnCancelar . Name = "btnCancelar"00095
Me . btnCancelar . Size = New System . Drawing . Size ( 88 , 24 )00096
Me . btnCancelar . TabIndex = 000097
Me . btnCancelar . Text = "Cancelar"00098
'00099
'gbOpciones00100
'00101
Me . gbOpciones . Controls . Add ( Me . GroupBox3 )00102
Me . gbOpciones . Controls . Add ( Me . GroupBox1 )00103
Me . gbOpciones . Controls . Add ( Me . chkSPTab )00104
Me . gbOpciones . Controls . Add ( Me . Label1 )00105
Me . gbOpciones . Controls . Add ( Me . GroupBox2 )00106
Me . gbOpciones . Controls . Add ( Me . txtFL )00107
Me . gbOpciones . Controls . Add ( Me . Label2 )00108
Me . gbOpciones . Controls . Add ( Me . Label3 )00109
Me . gbOpciones . Controls . Add ( Me . txtSP )00110
Me . gbOpciones . Controls . Add ( Me . txtNV )00111
Me . gbOpciones . Location = New System . Drawing . Point ( 8 , 0 )00112
Me . gbOpciones . Name = "gbOpciones"00113
Me . gbOpciones . Size = New System . Drawing . Size ( 352 , 216 )00114
Me . gbOpciones . TabIndex = 100115
Me . gbOpciones . TabStop = False00116
'00117
'GroupBox300118
'00119
Me . GroupBox3 . Controls . Add ( Me . chkMatrizEtiqueta )00120
Me . GroupBox3 . Controls . Add ( Me . chkMatrizValor )00121
Me . GroupBox3 . Controls . Add ( Me . chkMatrizEtiquetaValor )00122
Me . GroupBox3 . Location = New System . Drawing . Point ( 176 , 16 )00123
Me . GroupBox3 . Name = "GroupBox3"00124
Me . GroupBox3 . Size = New System . Drawing . Size ( 168 , 88 )00125
Me . GroupBox3 . TabIndex = 300126
Me . GroupBox3 . TabStop = False00127
Me . GroupBox3 . Text = "Nodos: "00128
'00129
'chkMatrizEtiqueta00130
'00131
Me . chkMatrizEtiqueta . Checked = True00132
Me . chkMatrizEtiqueta . CheckState = System . Windows . Forms . CheckState .» Checked
00133
Me . chkMatrizEtiqueta . Location = New System . Drawing . Point ( 8 , 16 )00134
Me . chkMatrizEtiqueta . Name = "chkMatrizEtiqueta"00135
Me . chkMatrizEtiqueta . Size = New System . Drawing . Size ( 144 , 16 )00136
Me . chkMatrizEtiqueta . TabIndex = 300137
Me . chkMatrizEtiqueta . Text = "Matriz etiqueta"00138
'00139
'chkMatrizValor00140
'00141
Me . chkMatrizValor . Checked = True00142
Me . chkMatrizValor . CheckState = System . Windows . Forms . CheckState . Checked00143
Me . chkMatrizValor . Location = New System . Drawing . Point ( 8 , 40 )00144
Me . chkMatrizValor . Name = "chkMatrizValor"00145
Me . chkMatrizValor . Size = New System . Drawing . Size ( 144 , 16 )00146
Me . chkMatrizValor . TabIndex = 300147
Me . chkMatrizValor . Text = "Matriz valor"00148
'00149
'chkMatrizEtiquetaValor00150
'00151
Me . chkMatrizEtiquetaValor . Checked = True00152
Me . chkMatrizEtiquetaValor . CheckState = System . Windows . Forms . CheckState .» Checked
00153
Me . chkMatrizEtiquetaValor . Location = New System . Drawing . Point ( 8 , 64 )00154
Me . chkMatrizEtiquetaValor . Name = "chkMatrizEtiquetaValor"00155
Me . chkMatrizEtiquetaValor . Size = New System . Drawing . Size ( 144 , 16 )00156
Me . chkMatrizEtiquetaValor . TabIndex = 300157
Me . chkMatrizEtiquetaValor . Text = "Matriz etiqueta y valor"00158
'00159
'GroupBox100160
'00161
Me . GroupBox1 . Controls . Add ( Me . chkInfoGrafos )00162
Me . GroupBox1 . Location = New System . Drawing . Point ( 176 , 96 )00163
Me . GroupBox1 . Name = "GroupBox1"00164
Me . GroupBox1 . Size = New System . Drawing . Size ( 168 , 40 )00165
Me . GroupBox1 . TabIndex = 600166
Me . GroupBox1 . TabStop = False00167
'00168
'chkInfoGrafos00169
'00170
Me . chkInfoGrafos . Location = New System . Drawing . Point ( 8 , 16 )00171
Me . chkInfoGrafos . Name = "chkInfoGrafos"00172
Me . chkInfoGrafos . Size = New System . Drawing . Size ( 152 , 16 )00173
Me . chkInfoGrafos . TabIndex = 000174
Me . chkInfoGrafos . Text = "Fichero de info. Grafos"00175
'00176
'chkSPTab00177
'00178
Me . chkSPTab . Checked = True00179
Me . chkSPTab . CheckState = System . Windows . Forms . CheckState . Checked00180
Me . chkSPTab . Location = New System . Drawing . Point ( 176 , 168 )00181
Me . chkSPTab . Name = "chkSPTab"00182
Me . chkSPTab . Size = New System . Drawing . Size ( 80 , 16 )00183
Me . chkSPTab . TabIndex = 500184
Me . chkSPTab . Text = "Tabulador"00185
'00186
'Label100187
'00188
Me . Label1 . AutoSize = True00189
Me . Label1 . Location = New System . Drawing . Point ( 8 , 144 )00190
Me . Label1 . Name = "Label1"00191
Me . Label1 . Size = New System . Drawing . Size ( 134 , 16 )00192
Me . Label1 . TabIndex = 400193
Me . Label1 . Text = "Carácter para fín de línea:"00194
'00195
'GroupBox200196
'00197
Me . GroupBox2 . Controls . Add ( Me . chkMatrizBinaria )00198
Me . GroupBox2 . Controls . Add ( Me . chkMatrizMinimo )00199
Me . GroupBox2 . Controls . Add ( Me . chkMatrizMaximo )00200
Me . GroupBox2 . Controls . Add ( Me . chkMatrizCoste )00201
Me . GroupBox2 . Location = New System . Drawing . Point ( 8 , 16 )00202
Me . GroupBox2 . Name = "GroupBox2"00203
Me . GroupBox2 . Size = New System . Drawing . Size ( 160 , 120 )00204
Me . GroupBox2 . TabIndex = 300205
Me . GroupBox2 . TabStop = False00206
Me . GroupBox2 . Text = " Arcos: "00207
'00208
'chkMatrizBinaria00209
'00210
Me . chkMatrizBinaria . Checked = True00211
Me . chkMatrizBinaria . CheckState = System . Windows . Forms . CheckState . Checked00212
Me . chkMatrizBinaria . Location = New System . Drawing . Point ( 8 , 16 )00213
Me . chkMatrizBinaria . Name = "chkMatrizBinaria"00214
Me . chkMatrizBinaria . Size = New System . Drawing . Size ( 96 , 16 )00215
Me . chkMatrizBinaria . TabIndex = 300216
Me . chkMatrizBinaria . Text = "Matriz binaria"00217
'00218
'chkMatrizMinimo00219
'00220
Me . chkMatrizMinimo . Checked = True00221
Me . chkMatrizMinimo . CheckState = System . Windows . Forms . CheckState . Checked00222
Me . chkMatrizMinimo . Location = New System . Drawing . Point ( 8 , 40 )00223
Me . chkMatrizMinimo . Name = "chkMatrizMinimo"00224
Me . chkMatrizMinimo . Size = New System . Drawing . Size ( 96 , 16 )00225
Me . chkMatrizMinimo . TabIndex = 300226
Me . chkMatrizMinimo . Text = "Matriz mínimo"00227
'00228
'chkMatrizMaximo00229
'00230
Me . chkMatrizMaximo . Checked = True00231
Me . chkMatrizMaximo . CheckState = System . Windows . Forms . CheckState . Checked00232
Me . chkMatrizMaximo . Location = New System . Drawing . Point ( 8 , 64 )00233
Me . chkMatrizMaximo . Name = "chkMatrizMaximo"00234
Me . chkMatrizMaximo . Size = New System . Drawing . Size ( 104 , 16 )00235
Me . chkMatrizMaximo . TabIndex = 300236
Me . chkMatrizMaximo . Text = "Matriz máximo"00237
'00238
'chkMatrizCoste00239
'00240
Me . chkMatrizCoste . Checked = True00241
Me . chkMatrizCoste . CheckState = System . Windows . Forms . CheckState . Checked00242
Me . chkMatrizCoste . Location = New System . Drawing . Point ( 8 , 88 )00243
Me . chkMatrizCoste . Name = "chkMatrizCoste"00244
Me . chkMatrizCoste . Size = New System . Drawing . Size ( 96 , 16 )00245
Me . chkMatrizCoste . TabIndex = 300246
Me . chkMatrizCoste . Text = "Matriz coste"00247
'00248
'txtFL00249
'00250
Me . txtFL . Location = New System . Drawing . Point ( 144 , 144 )00251
Me . txtFL . MaxLength = 100252
Me . txtFL . Name = "txtFL"00253
Me . txtFL . Size = New System . Drawing . Size ( 24 , 20 )00254
Me . txtFL . TabIndex = 100255
Me . txtFL . Text = ""00256
'00257
'Label200258
'00259
Me . Label2 . AutoSize = True00260
Me . Label2 . Location = New System . Drawing . Point ( 8 , 168 )00261
Me . Label2 . Name = "Label2"00262
Me . Label2 . Size = New System . Drawing . Size ( 130 , 16 )00263
Me . Label2 . TabIndex = 400264
Me . Label2 . Text = "Carácter para separador:"00265
'00266
'Label300267
'00268
Me . Label3 . AutoSize = True00269
Me . Label3 . Location = New System . Drawing . Point ( 8 , 192 )00270
Me . Label3 . Name = "Label3"00271
Me . Label3 . Size = New System . Drawing . Size ( 124 , 16 )00272
Me . Label3 . TabIndex = 400273
Me . Label3 . Text = "Carácter para 'no valor':"00274
'00275
'txtSP00276
'00277
Me . txtSP . Location = New System . Drawing . Point ( 144 , 168 )00278
Me . txtSP . MaxLength = 100279
Me . txtSP . Name = "txtSP"00280
Me . txtSP . Size = New System . Drawing . Size ( 24 , 20 )00281
Me . txtSP . TabIndex = 100282
Me . txtSP . Text = ""00283
'00284
'txtNV00285
'00286
Me . txtNV . Location = New System . Drawing . Point ( 144 , 192 )00287
Me . txtNV . MaxLength = 100288
Me . txtNV . Name = "txtNV"00289
Me . txtNV . Size = New System . Drawing . Size ( 24 , 20 )00290
Me . txtNV . TabIndex = 100291
Me . txtNV . Text = "#"00292
'00293
'pbExportar00294
'00295
Me . pbExportar . Location = New System . Drawing . Point ( 8 , 224 )00296
Me . pbExportar . Name = "pbExportar"00297
Me . pbExportar . Size = New System . Drawing . Size ( 160 , 24 )00298
Me . pbExportar . TabIndex = 200299
'00300
'frmExportarDatos00301
'00302
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00303
Me . ClientSize = New System . Drawing . Size ( 370 , 255 )00304
Me . ControlBox = False00305
Me . Controls . Add ( Me . pbExportar )00306
Me . Controls . Add ( Me . gbOpciones )00307
Me . Controls . Add ( Me . btnExportar )00308
Me . Controls . Add ( Me . btnCancelar )00309
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle .» FixedToolWindow
00310
Me . Name = "frmExportarDatos"00311
Me . StartPosition = System . Windows . Forms . FormStartPosition . CenterScreen00312
Me . Text = "Grafos - Opciones para Exportar datos..."00313
Me . TopMost = True00314
Me . gbOpciones . ResumeLayout ( False )00315
Me . GroupBox3 . ResumeLayout ( False )00316
Me . GroupBox1 . ResumeLayout ( False )00317
Me . GroupBox2 . ResumeLayout ( False )00318
Me . ResumeLayout ( False )00319
00320
End Sub00321
00322
# End Region00323
00324
'crea matrices para la tablas de arcos00325
Dim MatrizBinario (- 1 , - 1 ) As String00326
Dim MatrizMinimo (- 1 , - 1 ) As String00327
Dim MatrizMaximo (- 1 , - 1 ) As String00328
Dim MatrizCoste (- 1 , - 1 ) As String00329
'crea matriz para la cabecera de nodos00330
Dim MatrizNodosEtiqueta () As String00331
'crea matriz par los valores de nodos00332
Dim MatrizNodosValor () As String00333
00334
00335
Sub RellenaMatricesExportar ()00336
'Esta rutina, lee los datos iniciales del grafo en formato gráfico00337
'y rellena las matrices que se usarán para la exportación de datos00338
00339
'dimensiona matrices00340
ReDim MatrizBinario ( Form1 . TotalNodos - 1 , Form1 . TotalNodos - 1 )00341
ReDim MatrizMinimo ( Form1 . TotalNodos - 1 , Form1 . TotalNodos - 1 )00342
ReDim MatrizMaximo ( Form1 . TotalNodos - 1 , Form1 . TotalNodos - 1 )00343
ReDim MatrizCoste ( Form1 . TotalNodos - 1 , Form1 . TotalNodos - 1 )00344
ReDim MatrizNodosEtiqueta ( Form1 . TotalNodos - 1 )00345
ReDim MatrizNodosValor ( Form1 . TotalNodos - 1 )00346
00347
Dim i , j , a As Long00348
00349
'i,j donde i=fila=y,j=columna=x00350
'toma valores00351
'cambia los valores decimales de coma por punto (más estándar)00352
'así además se posibilita el separador de coma (.csv)00353
For i = 0 To Form1 . TotalNodos - 100354
MatrizNodosEtiqueta ( i ) = Form1 . Nodos ( i ) . Texto00355
MatrizNodosValor ( i ) = Form1 . Nodos ( i ) . Valor . ToString . Replace ( "," ,» "." )
00356
For j = 0 To Form1 . TotalNodos - 100357
'nodo origen=y, nodo destino=x00358
'nodo origen=i, nodo destino=j00359
'rellena todas las matrices con 'no valor'00360
MatrizBinario ( i , j ) = txtNV . Text00361
MatrizMinimo ( i , j ) = txtNV . Text00362
MatrizMaximo ( i , j ) = txtNV . Text00363
MatrizCoste ( i , j ) = txtNV . Text00364
Next j00365
Next i00366
'sobreescribe las matrices00367
'con las relaciones de arco00368
For a = 0 To Form1 . TotalArcos - 100369
i = Form1 . Arcos ( a ) . Nd100370
j = Form1 . Arcos ( a ) . Nd200371
00372
MatrizBinario ( i , j ) = 100373
MatrizMinimo ( i , j ) = Form1 . Arcos ( a ) . Min . ToString . Replace ( "," , "." )00374
MatrizMaximo ( i , j ) = Form1 . Arcos ( a ) . Max . ToString . Replace ( "," , "." )00375
MatrizCoste ( i , j ) = Form1 . Arcos ( a ) . Coste . ToString . Replace ( "," , "." )00376
Next a00377
End Sub00378
00379
00380
Private Sub chkSPTab_CheckedChanged ( ByVal sender As System . Object , ByVal e» As System . EventArgs ) Handles chkSPTab . CheckedChanged
00381
If chkSPTab . Checked = True Then00382
txtSP . Enabled = False00383
Else00384
txtSP . Enabled = True00385
End If00386
End Sub00387
00388
Private Sub btnCancelar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnCancelar . Click
00389
Me . Finalize ()00390
End Sub00391
00392
Private Sub btnExportar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnExportar . Click
00393
'Proceso completo de Exportación de Datos00394
'en función de las opciones seleccionadas00395
00396
'Comprobación inicial00397
'no se puede exportar sin separador, ni tabulador00398
Dim SP As String00399
If Me . chkSPTab . Checked = False Then00400
If txtSP . Text . Length < 1 Then00401
txtSP . Text = " "00402
End If00403
SP = txtSP . Text00404
Else00405
SP = vbTab00406
End If00407
00408
'selecciona trayectoria, nombre y extensión00409
'si no, sale como si nada00410
'----------------------------------00411
Dim Fichero As String00412
Dim extension As String00413
00414
Dim saveFileDialog1 As New SaveFileDialog00415
saveFileDialog1 . AddExtension = True00416
saveFileDialog1 . DefaultExt = ".txt"00417
saveFileDialog1 . Filter = "Documento de texto (*.txt)|*.txt|Fichero» delimitado por comas (*.csv)|*.csv|Todos los archivos (*.*)|*.*"
00418
saveFileDialog1 . FilterIndex = 1 'formato por defecto .txt00419
saveFileDialog1 . Title = "Exportar Datos del Grafo"00420
saveFileDialog1 . RestoreDirectory = True00421
00422
If saveFileDialog1 . ShowDialog () = DialogResult . OK Then00423
'Selecciona el formato de texto que ha escogido el usuario00424
Select Case saveFileDialog1 . FilterIndex00425
Case 100426
extension = ".txt"00427
Case 200428
extension = ".csv"00429
'### habría que preguntar si se fuerza un estándar00430
'o se deja personalizarlo00431
'de fin de linea y separadores00432
'sp=";"00433
00434
Case Else00435
extension = saveFileDialog1 . FileName . Substring (» saveFileDialog1 . FileName . Length - 4 )
00436
End Select00437
Else00438
'el usuario canceló el cuadro de diálogo00439
Exit Sub00440
End If00441
00442
'Comienza el proceso de exportación propiamente dicho00443
Try00444
'### debería comprobar si existe un fichero del mismo base00445
'### esta rutina sobreescribe posibles ficheros existentes con la» misma base
00446
00447
'quita extensión para quedarse con la trayectoria y base del nombre00448
Fichero = saveFileDialog1 . FileName00449
Fichero = Fichero . Remove ( Fichero . Length - 4 , 4 )00450
00451
00452
btnExportar . Enabled = False00453
btnCancelar . Enabled = False00454
gbOpciones . Enabled = False00455
Me . Cursor = Cursors . WaitCursor00456
00457
00458
'cambia estado de la barra de progreso a cada paso00459
Dim paso As Integer00460
paso = 900461
Me . pbExportar . Value = 0 * 100 / paso00462
'Creación de matrices00463
'para la exportación00464
'----------------------------------00465
RellenaMatricesExportar ()00466
00467
Me . pbExportar . Value = 1 * 100 / paso00468
00469
'Graba todos los ficheros de texto00470
'----------------------------------00471
Dim txt As String00472
Dim i , j As Long00473
'MatrizNodosValor00474
If chkMatrizValor . Checked Then00475
txt = ""00476
For i = 0 To Form1 . TotalNodos - 100477
txt & = MatrizNodosValor ( i )00478
txt & = txtFL . Text & vbCrLf00479
Next00480
EscribeFicheroTexto ( Fichero & "_nval" & extension , txt )00481
End If00482
Me . pbExportar . Value = 2 * 100 / paso00483
'MatrizNodosEtiqueta00484
If chkMatrizEtiqueta . Checked Then00485
txt = ""00486
For i = 0 To Form1 . TotalNodos - 100487
txt & = MatrizNodosEtiqueta ( i )00488
txt & = txtFL . Text & vbCrLf00489
Next00490
EscribeFicheroTexto ( Fichero & "_netq" & extension , txt )00491
End If00492
Me . pbExportar . Value = 3 * 100 / paso00493
'MatrizEtiquetaValor00494
If chkMatrizEtiquetaValor . Checked Then00495
txt = ""00496
For i = 0 To Form1 . TotalNodos - 100497
txt & = MatrizNodosEtiqueta ( i )00498
txt & = SP & MatrizNodosValor ( i )00499
txt & = txtFL . Text & vbCrLf00500
Next i00501
EscribeFicheroTexto ( Fichero & "_nmat" & extension , txt )00502
End If00503
Me . pbExportar . Value = 4 * 100 / paso00504
'MatrizBinario00505
If chkMatrizBinaria . Checked Then00506
txt = ""00507
For i = 0 To Form1 . TotalNodos - 100508
For j = 0 To Form1 . TotalNodos - 100509
txt & = MatrizBinario ( i , j )00510
If j < Form1 . TotalNodos - 1 Then00511
txt & = SP00512
End If00513
Next j00514
txt & = txtFL . Text & vbCrLf00515
Next i00516
EscribeFicheroTexto ( Fichero & "_abin" & extension , txt )00517
End If00518
Me . pbExportar . Value = 5 * 100 / paso00519
'MatrizMinimo00520
If chkMatrizMinimo . Checked Then00521
txt = ""00522
For i = 0 To Form1 . TotalNodos - 100523
For j = 0 To Form1 . TotalNodos - 100524
txt & = MatrizMinimo ( i , j )00525
If j < Form1 . TotalNodos - 1 Then00526
txt & = SP00527
End If00528
Next j00529
txt & = txtFL . Text & vbCrLf00530
Next i00531
EscribeFicheroTexto ( Fichero & "_amin" & extension , txt )00532
End If00533
Me . pbExportar . Value = 6 * 100 / paso00534
'MatrizMaximo00535
If chkMatrizMaximo . Checked Then00536
txt = ""00537
For i = 0 To Form1 . TotalNodos - 100538
For j = 0 To Form1 . TotalNodos - 100539
txt & = MatrizMaximo ( i , j )00540
If j < Form1 . TotalNodos - 1 Then00541
txt & = SP00542
End If00543
Next j00544
txt & = txtFL . Text & vbCrLf00545
Next i00546
EscribeFicheroTexto ( Fichero & "_amax" & extension , txt )00547
End If00548
Me . pbExportar . Value = 7 * 100 / paso00549
'MatrizCoste00550
If chkMatrizCoste . Checked Then00551
txt = ""00552
For i = 0 To Form1 . TotalNodos - 100553
For j = 0 To Form1 . TotalNodos - 100554
txt & = MatrizCoste ( i , j )00555
If j < Form1 . TotalNodos - 1 Then00556
txt & = SP00557
End If00558
Next j00559
txt & = txtFL . Text & vbCrLf00560
Next i00561
EscribeFicheroTexto ( Fichero & "_acst" & extension , txt )00562
End If00563
Me . pbExportar . Value = 8 * 100 / paso00564
'Fichero de información del grafo00565
If chkInfoGrafos . Checked = True Then00566
txt = ""00567
txt & = "nodos =" & SP & Form1 . TotalNodos00568
txt & = txtFL . Text & vbCrLf00569
txt & = "arcos =" & SP & Form1 . TotalArcos00570
txt & = txtFL . Text & vbCrLf00571
'en el futuro se podrán añadir más campos00572
End If00573
EscribeFicheroTexto ( Fichero & "_ginf" & extension , txt )00574
00575
Me . pbExportar . Value = 9 * 100 / paso00576
00577
Catch ex As Exception00578
MsgBox ( "Ha fallado el proceso de exportar datos." & vbCrLf & ex .» Message , MsgBoxStyle . Exclamation , "Grafos - Excepción" )
00579
'Finalización correcta00580
btnExportar . Enabled = True00581
btnCancelar . Enabled = True00582
gbOpciones . Enabled = True00583
Me . pbExportar . Value = 000584
Me . Cursor = Cursors . Default00585
Exit Sub00586
Finally00587
End Try00588
00589
00590
'Finalización correcta00591
btnExportar . Enabled = True00592
btnCancelar . Enabled = True00593
gbOpciones . Enabled = True00594
Me . pbExportar . Value = 000595
Me . Cursor = Cursors . Default00596
End Sub00597
00598
00599
Private Sub txtFL_KeyPress ( ByVal sender As Object , ByVal e As System . Windows» . Forms . KeyPressEventArgs ) Handles txtFL . KeyPress
00600
'carácter de fín de línea00601
'no se permiten números00602
'si se permite coma00603
'no se permite punto00604
'no se permite + -00605
'se permite vacío00606
If e . KeyChar = "-" Or e . KeyChar = "+" Or ( e . KeyChar >= "0" And e . KeyChar» <= "9" ) Or e . KeyChar = "." Then
00607
'carácter no permitido00608
e . Handled = True00609
Else00610
End If00611
End Sub00612
00613
00614
Private Sub txtSP_KeyPress ( ByVal sender As Object , ByVal e As System . Windows» . Forms . KeyPressEventArgs ) Handles txtSP . KeyPress
00615
'carácter de separación00616
'no se permiten números00617
'si se permite coma00618
'no se permite punto00619
'no se permite + -00620
'no se permite vacío (se controla en btnExportar)00621
If e . KeyChar = "-" Or e . KeyChar = "+" Or ( e . KeyChar >= "0" And e . KeyChar» <= "9" ) Or e . KeyChar = "." Then
00622
'carácter no permitido00623
e . Handled = True00624
Else00625
End If00626
End Sub00627
00628
Private Sub txtNV_KeyPress ( ByVal sender As Object , ByVal e As System . Windows» . Forms . KeyPressEventArgs ) Handles txtNV . KeyPress
00629
'carácter de 'no valor'00630
'no se permiten números (sólo el cero 0)00631
'no se permite coma00632
'no se permite punto00633
'si se permite + -00634
'si se permite vacío00635
If ( e . KeyChar >= "1" And e . KeyChar <= "9" ) Or e . KeyChar = "," Or e .» KeyChar = "." Then
00636
'carácter no permitido00637
e . Handled = True00638
Else00639
End If00640
End Sub00641
00642
00643
End Class00001
Public Class frmImportarDatos00002
Inherits System . Windows . Forms . Form00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'Form reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
Friend WithEvents btnCancelar As System . Windows . Forms . Button00033
Friend WithEvents pbImportar As System . Windows . Forms . ProgressBar00034
Friend WithEvents btnImportar As System . Windows . Forms . Button00035
Friend WithEvents gbOpciones As System . Windows . Forms . GroupBox00036
Friend WithEvents GroupBox3 As System . Windows . Forms . GroupBox00037
Friend WithEvents chkSPTab As System . Windows . Forms . CheckBox00038
Friend WithEvents Label1 As System . Windows . Forms . Label00039
Friend WithEvents GroupBox2 As System . Windows . Forms . GroupBox00040
Friend WithEvents txtFL As System . Windows . Forms . TextBox00041
Friend WithEvents Label2 As System . Windows . Forms . Label00042
Friend WithEvents Label3 As System . Windows . Forms . Label00043
Friend WithEvents txtSP As System . Windows . Forms . TextBox00044
Friend WithEvents txtNV As System . Windows . Forms . TextBox00045
Friend WithEvents opMatrizBinaria As System . Windows . Forms . RadioButton00046
Friend WithEvents opSustituir As System . Windows . Forms . RadioButton00047
Friend WithEvents opMatrizMinimo As System . Windows . Forms . RadioButton00048
Friend WithEvents opMatrizMaximo As System . Windows . Forms . RadioButton00049
Friend WithEvents opMatrizCoste As System . Windows . Forms . RadioButton00050
Friend WithEvents opMatrizEtiqueta As System . Windows . Forms . RadioButton00051
Friend WithEvents opMatrizValor As System . Windows . Forms . RadioButton00052
Friend WithEvents opMatrizEtiquetaValor As System . Windows . Forms . RadioButton00053
Friend WithEvents opActualizar As System . Windows . Forms . RadioButton00054
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00055
Me . btnCancelar = New System . Windows . Forms . Button00056
Me . pbImportar = New System . Windows . Forms . ProgressBar00057
Me . btnImportar = New System . Windows . Forms . Button00058
Me . gbOpciones = New System . Windows . Forms . GroupBox00059
Me . GroupBox2 = New System . Windows . Forms . GroupBox00060
Me . opMatrizBinaria = New System . Windows . Forms . RadioButton00061
Me . opMatrizMinimo = New System . Windows . Forms . RadioButton00062
Me . opMatrizMaximo = New System . Windows . Forms . RadioButton00063
Me . opMatrizCoste = New System . Windows . Forms . RadioButton00064
Me . opMatrizEtiqueta = New System . Windows . Forms . RadioButton00065
Me . opMatrizValor = New System . Windows . Forms . RadioButton00066
Me . opMatrizEtiquetaValor = New System . Windows . Forms . RadioButton00067
Me . GroupBox3 = New System . Windows . Forms . GroupBox00068
Me . opActualizar = New System . Windows . Forms . RadioButton00069
Me . opSustituir = New System . Windows . Forms . RadioButton00070
Me . chkSPTab = New System . Windows . Forms . CheckBox00071
Me . Label1 = New System . Windows . Forms . Label00072
Me . txtFL = New System . Windows . Forms . TextBox00073
Me . Label2 = New System . Windows . Forms . Label00074
Me . Label3 = New System . Windows . Forms . Label00075
Me . txtSP = New System . Windows . Forms . TextBox00076
Me . txtNV = New System . Windows . Forms . TextBox00077
Me . gbOpciones . SuspendLayout ()00078
Me . GroupBox2 . SuspendLayout ()00079
Me . GroupBox3 . SuspendLayout ()00080
Me . SuspendLayout ()00081
'00082
'btnCancelar00083
'00084
Me . btnCancelar . Location = New System . Drawing . Point ( 272 , 224 )00085
Me . btnCancelar . Name = "btnCancelar"00086
Me . btnCancelar . Size = New System . Drawing . Size ( 88 , 24 )00087
Me . btnCancelar . TabIndex = 100088
Me . btnCancelar . Text = "Cancelar"00089
'00090
'pbImportar00091
'00092
Me . pbImportar . Location = New System . Drawing . Point ( 8 , 224 )00093
Me . pbImportar . Name = "pbImportar"00094
Me . pbImportar . Size = New System . Drawing . Size ( 160 , 24 )00095
Me . pbImportar . TabIndex = 400096
'00097
'btnImportar00098
'00099
Me . btnImportar . Location = New System . Drawing . Point ( 176 , 224 )00100
Me . btnImportar . Name = "btnImportar"00101
Me . btnImportar . Size = New System . Drawing . Size ( 88 , 24 )00102
Me . btnImportar . TabIndex = 300103
Me . btnImportar . Text = "Importar"00104
'00105
'gbOpciones00106
'00107
Me . gbOpciones . Controls . Add ( Me . GroupBox2 )00108
Me . gbOpciones . Controls . Add ( Me . GroupBox3 )00109
Me . gbOpciones . Controls . Add ( Me . chkSPTab )00110
Me . gbOpciones . Controls . Add ( Me . Label1 )00111
Me . gbOpciones . Controls . Add ( Me . txtFL )00112
Me . gbOpciones . Controls . Add ( Me . Label2 )00113
Me . gbOpciones . Controls . Add ( Me . Label3 )00114
Me . gbOpciones . Controls . Add ( Me . txtSP )00115
Me . gbOpciones . Controls . Add ( Me . txtNV )00116
Me . gbOpciones . Location = New System . Drawing . Point ( 8 , 0 )00117
Me . gbOpciones . Name = "gbOpciones"00118
Me . gbOpciones . Size = New System . Drawing . Size ( 352 , 216 )00119
Me . gbOpciones . TabIndex = 500120
Me . gbOpciones . TabStop = False00121
'00122
'GroupBox200123
'00124
Me . GroupBox2 . Controls . Add ( Me . opMatrizBinaria )00125
Me . GroupBox2 . Controls . Add ( Me . opMatrizMinimo )00126
Me . GroupBox2 . Controls . Add ( Me . opMatrizMaximo )00127
Me . GroupBox2 . Controls . Add ( Me . opMatrizCoste )00128
Me . GroupBox2 . Controls . Add ( Me . opMatrizEtiqueta )00129
Me . GroupBox2 . Controls . Add ( Me . opMatrizValor )00130
Me . GroupBox2 . Controls . Add ( Me . opMatrizEtiquetaValor )00131
Me . GroupBox2 . Location = New System . Drawing . Point ( 8 , 16 )00132
Me . GroupBox2 . Name = "GroupBox2"00133
Me . GroupBox2 . Size = New System . Drawing . Size ( 336 , 120 )00134
Me . GroupBox2 . TabIndex = 300135
Me . GroupBox2 . TabStop = False00136
Me . GroupBox2 . Text = "Tipo de datos: "00137
'00138
'opMatrizBinaria00139
'00140
Me . opMatrizBinaria . Location = New System . Drawing . Point ( 8 , 16 )00141
Me . opMatrizBinaria . Name = "opMatrizBinaria"00142
Me . opMatrizBinaria . Size = New System . Drawing . Size ( 144 , 16 )00143
Me . opMatrizBinaria . TabIndex = 000144
Me . opMatrizBinaria . Text = "Matriz binaria (arcos)"00145
'00146
'opMatrizMinimo00147
'00148
Me . opMatrizMinimo . Checked = True00149
Me . opMatrizMinimo . Location = New System . Drawing . Point ( 8 , 40 )00150
Me . opMatrizMinimo . Name = "opMatrizMinimo"00151
Me . opMatrizMinimo . Size = New System . Drawing . Size ( 144 , 16 )00152
Me . opMatrizMinimo . TabIndex = 000153
Me . opMatrizMinimo . TabStop = True00154
Me . opMatrizMinimo . Text = "Matriz mínimo (arcos)"00155
'00156
'opMatrizMaximo00157
'00158
Me . opMatrizMaximo . Location = New System . Drawing . Point ( 8 , 64 )00159
Me . opMatrizMaximo . Name = "opMatrizMaximo"00160
Me . opMatrizMaximo . Size = New System . Drawing . Size ( 144 , 16 )00161
Me . opMatrizMaximo . TabIndex = 000162
Me . opMatrizMaximo . Text = "Matriz máximo (arcos)"00163
'00164
'opMatrizCoste00165
'00166
Me . opMatrizCoste . Location = New System . Drawing . Point ( 8 , 88 )00167
Me . opMatrizCoste . Name = "opMatrizCoste"00168
Me . opMatrizCoste . Size = New System . Drawing . Size ( 144 , 16 )00169
Me . opMatrizCoste . TabIndex = 000170
Me . opMatrizCoste . Text = "Matriz coste (arcos)"00171
'00172
'opMatrizEtiqueta00173
'00174
Me . opMatrizEtiqueta . Location = New System . Drawing . Point ( 152 , 16 )00175
Me . opMatrizEtiqueta . Name = "opMatrizEtiqueta"00176
Me . opMatrizEtiqueta . Size = New System . Drawing . Size ( 144 , 16 )00177
Me . opMatrizEtiqueta . TabIndex = 000178
Me . opMatrizEtiqueta . Text = "Matriz etiqueta (nodos)"00179
'00180
'opMatrizValor00181
'00182
Me . opMatrizValor . Location = New System . Drawing . Point ( 152 , 40 )00183
Me . opMatrizValor . Name = "opMatrizValor"00184
Me . opMatrizValor . Size = New System . Drawing . Size ( 144 , 16 )00185
Me . opMatrizValor . TabIndex = 000186
Me . opMatrizValor . Text = "Matriz valor (nodos)"00187
'00188
'opMatrizEtiquetaValor00189
'00190
Me . opMatrizEtiquetaValor . Location = New System . Drawing . Point ( 152 , 64 )00191
Me . opMatrizEtiquetaValor . Name = "opMatrizEtiquetaValor"00192
Me . opMatrizEtiquetaValor . Size = New System . Drawing . Size ( 176 , 16 )00193
Me . opMatrizEtiquetaValor . TabIndex = 000194
Me . opMatrizEtiquetaValor . Text = "Matriz etiqueta y valor (nodos)"00195
'00196
'GroupBox300197
'00198
Me . GroupBox3 . Controls . Add ( Me . opActualizar )00199
Me . GroupBox3 . Controls . Add ( Me . opSustituir )00200
Me . GroupBox3 . Location = New System . Drawing . Point ( 256 , 136 )00201
Me . GroupBox3 . Name = "GroupBox3"00202
Me . GroupBox3 . Size = New System . Drawing . Size ( 88 , 72 )00203
Me . GroupBox3 . TabIndex = 300204
Me . GroupBox3 . TabStop = False00205
'00206
'opActualizar00207
'00208
Me . opActualizar . Location = New System . Drawing . Point ( 8 , 40 )00209
Me . opActualizar . Name = "opActualizar"00210
Me . opActualizar . Size = New System . Drawing . Size ( 72 , 16 )00211
Me . opActualizar . TabIndex = 000212
Me . opActualizar . Text = "Actualizar"00213
'00214
'opSustituir00215
'00216
Me . opSustituir . Checked = True00217
Me . opSustituir . Location = New System . Drawing . Point ( 8 , 16 )00218
Me . opSustituir . Name = "opSustituir"00219
Me . opSustituir . Size = New System . Drawing . Size ( 72 , 16 )00220
Me . opSustituir . TabIndex = 000221
Me . opSustituir . TabStop = True00222
Me . opSustituir . Text = "Sustituir"00223
'00224
'chkSPTab00225
'00226
Me . chkSPTab . Checked = True00227
Me . chkSPTab . CheckState = System . Windows . Forms . CheckState . Checked00228
Me . chkSPTab . Location = New System . Drawing . Point ( 176 , 168 )00229
Me . chkSPTab . Name = "chkSPTab"00230
Me . chkSPTab . Size = New System . Drawing . Size ( 80 , 16 )00231
Me . chkSPTab . TabIndex = 500232
Me . chkSPTab . Text = "Tabulador"00233
'00234
'Label100235
'00236
Me . Label1 . AutoSize = True00237
Me . Label1 . Location = New System . Drawing . Point ( 8 , 144 )00238
Me . Label1 . Name = "Label1"00239
Me . Label1 . Size = New System . Drawing . Size ( 134 , 16 )00240
Me . Label1 . TabIndex = 400241
Me . Label1 . Text = "Carácter para fín de línea:"00242
'00243
'txtFL00244
'00245
Me . txtFL . Location = New System . Drawing . Point ( 144 , 144 )00246
Me . txtFL . MaxLength = 100247
Me . txtFL . Name = "txtFL"00248
Me . txtFL . Size = New System . Drawing . Size ( 24 , 20 )00249
Me . txtFL . TabIndex = 100250
Me . txtFL . Text = ""00251
'00252
'Label200253
'00254
Me . Label2 . AutoSize = True00255
Me . Label2 . Location = New System . Drawing . Point ( 8 , 168 )00256
Me . Label2 . Name = "Label2"00257
Me . Label2 . Size = New System . Drawing . Size ( 130 , 16 )00258
Me . Label2 . TabIndex = 400259
Me . Label2 . Text = "Carácter para separador:"00260
'00261
'Label300262
'00263
Me . Label3 . AutoSize = True00264
Me . Label3 . Location = New System . Drawing . Point ( 8 , 192 )00265
Me . Label3 . Name = "Label3"00266
Me . Label3 . Size = New System . Drawing . Size ( 124 , 16 )00267
Me . Label3 . TabIndex = 400268
Me . Label3 . Text = "Carácter para 'no valor':"00269
'00270
'txtSP00271
'00272
Me . txtSP . Location = New System . Drawing . Point ( 144 , 168 )00273
Me . txtSP . MaxLength = 100274
Me . txtSP . Name = "txtSP"00275
Me . txtSP . Size = New System . Drawing . Size ( 24 , 20 )00276
Me . txtSP . TabIndex = 100277
Me . txtSP . Text = ""00278
'00279
'txtNV00280
'00281
Me . txtNV . Location = New System . Drawing . Point ( 144 , 192 )00282
Me . txtNV . MaxLength = 100283
Me . txtNV . Name = "txtNV"00284
Me . txtNV . Size = New System . Drawing . Size ( 24 , 20 )00285
Me . txtNV . TabIndex = 100286
Me . txtNV . Text = "#"00287
'00288
'frmImportarDatos00289
'00290
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00291
Me . ClientSize = New System . Drawing . Size ( 368 , 253 )00292
Me . ControlBox = False00293
Me . Controls . Add ( Me . gbOpciones )00294
Me . Controls . Add ( Me . pbImportar )00295
Me . Controls . Add ( Me . btnImportar )00296
Me . Controls . Add ( Me . btnCancelar )00297
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle .» FixedToolWindow
00298
Me . Name = "frmImportarDatos"00299
Me . Text = "Grafos - Opciones para Importar datos..."00300
Me . TopMost = True00301
Me . gbOpciones . ResumeLayout ( False )00302
Me . GroupBox2 . ResumeLayout ( False )00303
Me . GroupBox3 . ResumeLayout ( False )00304
Me . ResumeLayout ( False )00305
00306
End Sub00307
00308
# End Region00309
00310
'crea matrices genérica00311
Dim MatrizGenerica (- 1 , - 1 ) As String00312
00313
'crea matrices para la tablas de arcos00314
Dim MatrizBinario (- 1 , - 1 ) As String00315
Dim MatrizMinimo (- 1 , - 1 ) As String00316
Dim MatrizMaximo (- 1 , - 1 ) As String00317
Dim MatrizCoste (- 1 , - 1 ) As String00318
'crea matriz para la cabecera de nodos00319
Dim MatrizNodosEtiqueta () As String00320
'crea matriz par los valores de nodos00321
Dim MatrizNodosValor () As String00322
00323
00324
Public Event ActualizaGrafo ( ByVal valor As Boolean )00325
00326
Private Sub btnCancelar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnCancelar . Click
00327
RaiseEvent ActualizaGrafo ( True )00328
Me . Visible = False00329
End Sub00330
00331
Private Sub btnImportar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnImportar . Click
00332
'Proceso completo de Importación de Datos00333
'en función de las opciones seleccionadas00334
'y del grafo existente en el tapiz00335
00336
'Comprobación inicial00337
'no se puede importar sin separador, ni tabulador00338
Dim SP As String00339
If Me . chkSPTab . Checked = False Then00340
If txtSP . Text . Length < 1 Then00341
txtSP . Text = " "00342
End If00343
SP = txtSP . Text00344
Else00345
SP = vbTab00346
End If00347
00348
'Aviso de sustitución de datos00349
If Form1 . TotalNodos > 0 And opSustituir . Checked = True Then00350
Dim respuesta As MsgBoxResult00351
respuesta = MsgBox ( "Con la opción Sustituir activada, si abre un» fichero para importar," & vbCrLf & "perderá los datos actuales
» del grafo." & vbCrLf & vbCrLf & "¿Desea realmente proseguir e
» importar los datos del fichero?" , MsgBoxStyle . Information ,
» MsgBoxStyle . OKCancel )
00352
If respuesta = MsgBoxResult . Cancel Then Exit Sub00353
End If00354
'Aviso de actualización de datos00355
If Form1 . TotalNodos > 0 And opActualizar . Checked = True Then00356
Dim respuesta As MsgBoxResult00357
respuesta = MsgBox ( "Con la opción Actualizar activada, si abre un» fichero para importar," & vbCrLf & "se actualizarán los datos y
» dimensiones actuales del grafo." & vbCrLf & vbCrLf & "¿Desea
» realmente proseguir e importar los datos del fichero?" ,
» MsgBoxStyle . Information , MsgBoxStyle . OKCancel )
00358
If respuesta = MsgBoxResult . Cancel Then Exit Sub00359
End If00360
'Esta opción de menú muestra el cuadro de diálogo00361
'de abrir fichero para la importación de datos00362
Dim openFileDialog1 As New OpenFileDialog00363
Dim Fichero As String00364
00365
openFileDialog1 . AddExtension = True00366
openFileDialog1 . DefaultExt = ".txt" 'extensión por defecto00367
openFileDialog1 . Filter = "Documento de texto (*.txt)|*.txt|Fichero» delimitado por comas (*.csv)|*.csv|Todos los archivos (*.*)|*.*"
00368
openFileDialog1 . FilterIndex = 1 'formato por defecto .txt00369
openFileDialog1 . Title = "Importar Datos del Grafo"00370
openFileDialog1 . RestoreDirectory = True00371
00372
If openFileDialog1 . ShowDialog () = DialogResult . OK Then00373
Fichero = openFileDialog1 . FileName00374
Else00375
Exit Sub 'el usuario eligió cancelar, sale como si nada00376
End If00377
00378
'deshabilita botones y cursor ratón00379
Me . Cursor = Cursors . WaitCursor00380
btnImportar . Enabled = False00381
btnCancelar . Enabled = False00382
gbOpciones . Enabled = False00383
00384
'cambia estado de la barra de progreso a cada paso00385
Dim paso As Integer00386
paso = 500387
pbImportar . Value = 0 * 100 / paso00388
00389
'Comienza el proceso de importación propiamente dicho00390
Try00391
Dim texto As String00392
00393
'Abre el fichero y lee su contenido00394
LeeFicheroTexto ( Fichero , texto )00395
'fin abrir fichero00396
pbImportar . Value = 1 * 100 / paso00397
'Comprueba longitud mínima del fichero de texto00398
If texto . Length <= 1 Then 'genera un error personalizado00399
Err () . Description = "Error de formato en el fichero» seleccionado." & vbCrLf & "Este fichero no contiene datos."
00400
Err () . Raise ( 1 )00401
End If00402
00403
00404
'cuenta filas y columnas del fichero00405
Dim i , j , a , b As Long00406
Dim filas As Long00407
Dim columnas As Long00408
Dim c As String00409
Dim p As String00410
00411
filas = 000412
columnas = 000413
For a = 0 To texto . Length - 100414
c = texto . Substring ( a , 1 )00415
If ( c = SP Or Asc ( c ) = Asc ( vbCrLf )) And filas = 0 Then00416
columnas = columnas + 100417
00418
'corrección por el error de conteo que puede originar la» línea anterior
00419
If a > 0 Then00420
If ( texto . Substring ( a - 1 , 1 ) = SP And Asc ( c ) = Asc (» vbCrLf )) Then
00421
columnas = columnas - 100422
End If00423
If ( texto . Substring ( a - 1 , 1 ) = txtFL . Text And txtFL .» Text <> "" And Asc ( c ) = Asc ( vbCrLf )) Then
00424
columnas = columnas - 100425
End If00426
End If00427
End If00428
If Asc ( c ) = Asc ( vbCrLf ) Then 'ha encontrado final de linea00429
filas = filas + 100430
End If00431
Next a00432
If c = SP And txtFL . Text = SP Then 'las líneas acaban con una doble» terminación, en teoría
00433
columnas = columnas - 100434
End If00435
pbImportar . Value = 2 * 100 / paso00436
'Comprueba longitud mínima del fichero de texto00437
If filas <= 0 Then 'genera un error personalizado00438
Err () . Description = "Error de formato en el fichero» seleccionado." & vbCrLf & "Número de filas insuficiente."
00439
Err () . Raise ( 1 )00440
End If00441
'Comprueba longitud mínima del fichero de texto00442
If columnas <= 0 Then 'genera un error personalizado00443
Err () . Description = "Error de formato en el fichero» seleccionado." & vbCrLf & "Número de columnas insuficiente."
00444
Err () . Raise ( 1 )00445
End If00446
00447
'comprobaciones según tipo de opción de importación y tamaño00448
'si importamos datos de arcos la matriz debe ser cuadrada00449
If opMatrizBinaria . Checked Or opMatrizMinimo . Checked Or» opMatrizMaximo . Checked Or opMatrizCoste . Checked Then
00450
If columnas <> filas Then 'genera un error personalizado00451
Err () . Description = "Error de formato en el fichero» seleccionado." & vbCrLf & "La matriz debe ser cuadrada."
00452
Err () . Raise ( 1 )00453
End If00454
End If00455
'si importamos datos de nodos (etiqueta o valor) la matriz de una» columna
00456
If opMatrizEtiqueta . Checked Or opMatrizValor . Checked Then00457
If columnas <> 1 Then 'genera un error personalizado00458
Err () . Description = "Error de formato en el fichero» seleccionado." & vbCrLf & "Número de columnas
» incorrecto."
00459
Err () . Raise ( 1 )00460
End If00461
End If00462
'si importamos datos de nodos (etiqueta y valor) la matriz de una» columna
00463
If opMatrizEtiquetaValor . Checked Then00464
If columnas <> 2 Then 'genera un error personalizado00465
Err () . Description = "Error de formato en el fichero» seleccionado." & vbCrLf & "Número de columnas
» incorrecto."
00466
Err () . Raise ( 1 )00467
End If00468
End If00469
'comprueba el máximo de nodos (200)00470
If columnas > 200 Then 'genera un error personalizado00471
Err () . Description = "Error de formato en el fichero» seleccionado." & vbCrLf & "Número de columnas demasiado
» grande."
00472
Err () . Raise ( 1 )00473
End If00474
pbImportar . Value = 3 * 100 / paso00475
'dimensiona matrices (i,j)=(filas,columnas)00476
'todas contienen strings00477
ReDim MatrizGenerica ( filas - 1 , columnas - 1 )00478
'ReDim MatrizBinario(filas - 1, columnas - 1)00479
'ReDim MatrizMinimo(filas - 1, columnas - 1)00480
'ReDim MatrizMaximo(filas - 1, columnas - 1)00481
'ReDim MatrizCoste(filas - 1, columnas - 1)00482
'ReDim MatrizNodosEtiqueta(filas - 1)00483
'ReDim MatrizNodosValor(filas - 1)00484
00485
'lee datos según opciones00486
'busca finales de línea00487
'busca elementos de cada línea según separador00488
'atención a posible duplicidad de final de línea)00489
p = ""00490
i = 000491
j = 000492
For a = 0 To texto . Length - 100493
c = texto . Substring ( a , 1 )00494
00495
If c <> SP And Asc ( c ) <> Asc ( vbCrLf ) And Asc ( c ) <> Asc ( vbCr )» And Asc ( c ) <> Asc ( vbLf ) Then
00496
'el separador decimal se transforma en punto para una» correcta importación
00497
If c = "," Then c = "." 'separador decimal00498
'caracter que incluir a la palabra00499
p & = c00500
00501
End If00502
If c = SP Or ( Asc ( c ) = Asc ( vbCrLf ) And j = columnas - 1 ) Then00503
'pone palabra en matriz00504
MatrizGenerica ( i , j ) = p00505
00506
'columnas = columnas + 100507
j = j + 100508
If j > columnas - 1 Then00509
j = 000510
End If00511
'resetea palabra00512
p = ""00513
End If00514
If Asc ( c ) = Asc ( vbCrLf ) Then 'ha encontrado final de linea00515
'filas = filas + 100516
i = i + 100517
'salta de línea00518
'resetea palabra00519
p = ""00520
End If00521
Next a00522
pbImportar . Value = 4 * 100 / paso00523
00524
'Sustituir00525
'se crean todos los datos de un nuevo grafo00526
00527
'-------------------------------------------00528
If opSustituir . Checked = True Or ( Form1 . TotalNodos = 0 And» opActualizar . Checked = True ) Then
00529
'también se usa esta rutina cuando no existe ningún grafo y se» actualiza
00530
00531
'Crea sólo una colección de nodos00532
If opMatrizValor . Checked = True Or opMatrizEtiqueta . Checked =» True Or opMatrizEtiquetaValor . Checked = True Then
00533
'Crea las dimensiones de nodos y arcos00534
Form1 . TotalNodos = filas00535
Form1 . TotalArcos = 000536
00537
ReDim Form1 . Nodos ( Form1 . TotalNodos - 1 )00538
ReDim Form1 . Arcos ( 0 )00539
00540
For i = 0 To filas - 100541
'Crea nodo con las opciones de dibujo básicas00542
Form1 . Nodos ( i ) . X = Rnd () * Form1 . Grafico . TapizX00543
Form1 . Nodos ( i ) . Y = Rnd () * Form1 . Grafico . TapizY00544
Form1 . Nodos ( i ) . Col = Form1 . Grafico . ColNodo00545
Form1 . Nodos ( i ) . Radio = Form1 . Grafico . RadioNodo00546
Form1 . Nodos ( i ) . Grosor = Form1 . Grafico . TrazoNodo00547
00548
If opMatrizValor . Checked = True Then00549
Form1 . Nodos ( i ) . Valor = Val ( MatrizGenerica ( i , 0 ))00550
Form1 . Nodos ( i ) . Texto = i . ToString00551
End If00552
If opMatrizEtiqueta . Checked = True Then00553
Form1 . Nodos ( i ) . Valor = 000554
Form1 . Nodos ( i ) . Texto = MatrizGenerica ( i , 0 )00555
End If00556
If opMatrizEtiquetaValor . Checked = True Then00557
Form1 . Nodos ( i ) . Texto = MatrizGenerica ( i , 0 )00558
Form1 . Nodos ( i ) . Valor = Val ( MatrizGenerica ( i , 1 ))00559
End If00560
Next i00561
00562
Else00563
'se están importando matrices de arcos00564
'primero crea los nodos necesarios00565
00566
'Crea las dimensiones de nodos y arcos00567
Form1 . TotalNodos = filas00568
Form1 . TotalArcos = 000569
00570
ReDim Form1 . Nodos ( Form1 . TotalNodos - 1 )00571
ReDim Form1 . Arcos ( 0 )00572
00573
For i = 0 To filas - 100574
'Crea nodo con las opciones de dibujo básicas00575
Form1 . Nodos ( i ) . X = Rnd () * Form1 . Grafico . TapizX00576
Form1 . Nodos ( i ) . Y = Rnd () * Form1 . Grafico . TapizY00577
Form1 . Nodos ( i ) . Col = Form1 . Grafico . ColNodo00578
Form1 . Nodos ( i ) . Radio = Form1 . Grafico . RadioNodo00579
Form1 . Nodos ( i ) . Grosor = Form1 . Grafico . TrazoNodo00580
Form1 . Nodos ( i ) . Valor = 000581
Form1 . Nodos ( i ) . Texto = i . ToString00582
Next i00583
00584
'después recorre toda la matriz buscando arcos00585
For i = 0 To filas - 100586
For j = 0 To columnas - 100587
'mira si existe un arco00588
If MatrizGenerica ( i , j ) <> txtNV . Text Then00589
'existe si es un valor diferente del no valor00590
00591
'redimensiona matrices de arcos00592
Form1 . TotalArcos = Form1 . TotalArcos + 100593
a = Form1 . TotalArcos - 100594
ReDim Preserve Form1 . Arcos ( Form1 . TotalArcos -» 1 )
00595
00596
Form1 . Arcos ( a ) . Texto = a . ToString00597
Form1 . Arcos ( a ) . Col = Form1 . Grafico . ColArco00598
Form1 . Arcos ( a ) . Grosor = Form1 . Grafico .» TrazoNodo
00599
Form1 . Arcos ( a ) . Nd1 = i00600
Form1 . Arcos ( a ) . Nd2 = j00601
00602
If opMatrizBinaria . Checked = True Then00603
Form1 . Arcos ( a ) . Min = 000604
Form1 . Arcos ( a ) . Max = 000605
Form1 . Arcos ( a ) . Coste = 000606
End If00607
If opMatrizMinimo . Checked = True Then00608
Form1 . Arcos ( a ) . Min = Val ( MatrizGenerica ( i» , j ))
00609
Form1 . Arcos ( a ) . Max = 000610
Form1 . Arcos ( a ) . Coste = 000611
End If00612
If opMatrizMaximo . Checked = True Then00613
Form1 . Arcos ( a ) . Min = 000614
Form1 . Arcos ( a ) . Max = Val ( MatrizGenerica ( i» , j ))
00615
Form1 . Arcos ( a ) . Coste = 000616
End If00617
If opMatrizCoste . Checked = True Then00618
Form1 . Arcos ( a ) . Min = 000619
Form1 . Arcos ( a ) . Max = 000620
Form1 . Arcos ( a ) . Coste = Val ( MatrizGenerica» ( i , j ))
00621
End If00622
End If00623
Next j00624
Next i00625
End If00626
pbImportar . Value = 5 * 100 / paso00627
End If 'fin sustituir00628
00629
'Actualizar00630
'----------00631
If opActualizar . Checked = True And Form1 . TotalNodos > 0 Then00632
00633
'crea una copia de seguridad de los arcos existentes00634
Dim vArcos () As Form1 . Arco00635
ReDim vArcos ( Form1 . TotalArcos - 1 )00636
vArcos = Form1 . Arcos00637
'guarda dimensiones del grafo existente00638
Dim vTotalNodos As Long00639
vTotalNodos = Form1 . TotalNodos00640
Dim vTotalArcos As Long00641
vTotalArcos = Form1 . TotalArcos00642
00643
'Crea las dimensiones de nodos y arcos para el nuevo grafo00644
'Nodos00645
Form1 . TotalNodos = filas00646
ReDim Preserve Form1 . Nodos ( Form1 . TotalNodos - 1 )00647
00648
'Arcos00649
If opMatrizBinaria . Checked Or opMatrizMinimo . Checked Or» opMatrizMaximo . Checked Or opMatrizCoste . Checked Then
00650
'primero recorre toda la matriz buscando arcos00651
a = 000652
For i = 0 To filas - 100653
For j = 0 To columnas - 100654
'mira si existe un arco00655
If MatrizGenerica ( i , j ) <> txtNV . Text Then00656
a = a + 100657
End If00658
Next j00659
Next i00660
00661
Form1 . TotalArcos = a00662
ReDim Preserve Form1 . Arcos ( Form1 . TotalArcos - 1 )00663
End If00664
00665
'Actualización de datos:00666
'si existe arco o nodo se cambian los datos implicados00667
'el resto los existentes00668
00669
'si se crea arco o nodo, se toma el dato implicado00670
'el resto los valores por defecto00671
00672
'Actualización de nodos00673
'----------------------00674
'si Nf<=Nv se habrán borrado nodos de la parte alta matriz00675
For i = 0 To Form1 . TotalNodos - 100676
'si Nf>Nv se deben crear nuevos nodos00677
If ( i + 1 ) > vTotalNodos Then00678
'Crea nodo con las opciones de dibujo básicas00679
Form1 . Nodos ( i ) . X = Rnd () * Form1 . Grafico . TapizX00680
Form1 . Nodos ( i ) . Y = Rnd () * Form1 . Grafico . TapizY00681
Form1 . Nodos ( i ) . Col = Form1 . Grafico . ColNodo00682
Form1 . Nodos ( i ) . Radio = Form1 . Grafico . RadioNodo00683
Form1 . Nodos ( i ) . Grosor = Form1 . Grafico . TrazoNodo00684
Form1 . Nodos ( i ) . Valor = 000685
Form1 . Nodos ( i ) . Texto = i . ToString00686
End If00687
'si hay que actualizar algo se actualiza00688
If opMatrizValor . Checked = True Then00689
Form1 . Nodos ( i ) . Valor = Val ( MatrizGenerica ( i , 0 ))00690
Form1 . Nodos ( i ) . Texto = i . ToString00691
End If00692
If opMatrizEtiqueta . Checked = True Then00693
Form1 . Nodos ( i ) . Valor = 000694
Form1 . Nodos ( i ) . Texto = MatrizGenerica ( i , 0 )00695
End If00696
If opMatrizEtiquetaValor . Checked = True Then00697
Form1 . Nodos ( i ) . Texto = MatrizGenerica ( i , 0 )00698
Form1 . Nodos ( i ) . Valor = Val ( MatrizGenerica ( i , 1 ))00699
End If00700
Next i00701
00702
'Actualización de arcos00703
'----------------------00704
'si se están actualizando datos de nodos...00705
'si Nf<=Nv se deben borrar arcos implicados00706
'el resto de datos se mantienen de los existentes00707
If opMatrizValor . Checked = True Or opMatrizEtiqueta . Checked =» True Or opMatrizEtiquetaValor . Checked = True Then
00708
Form1 . TotalArcos = 000709
For a = 0 To vTotalArcos - 100710
If vArcos ( a ) . Nd1 <= filas - 1 And vArcos ( a ) . Nd2 <=» filas - 1 Then
00711
'se trata de un arco existente con nodo origen y» final
00712
'que hay que mantener en la nueva matriz de nodos00713
00714
Form1 . TotalArcos = Form1 . TotalArcos + 100715
ReDim Preserve Form1 . Arcos ( Form1 . TotalArcos - 1 )00716
00717
Form1 . Arcos ( Form1 . TotalArcos - 1 ) = vArcos ( a )00718
End If00719
Next a00720
End If00721
00722
'si se están actualizando datos de arcos...00723
If opMatrizBinaria . Checked Or opMatrizMinimo . Checked Or» opMatrizMaximo . Checked Or opMatrizCoste . Checked Then
00724
'si Af>Av se deben incluir arcos00725
'si Af<=Av se deben borrar arcos00726
'después recorre toda la matriz buscando arcos00727
a = - 100728
For i = 0 To filas - 100729
For j = 0 To columnas - 100730
'mira si existe un arco00731
If MatrizGenerica ( i , j ) <> txtNV . Text Then00732
'existe si es un valor diferente del no valor00733
00734
'crea los arcos nuevos necesarios00735
a = a + 100736
If ( a + 1 ) > vTotalArcos Then00737
Form1 . Arcos ( a ) . Texto = a . ToString00738
Form1 . Arcos ( a ) . Col = Form1 . Grafico .» ColArco
00739
Form1 . Arcos ( a ) . Grosor = Form1 . Grafico .» TrazoNodo
00740
End If00741
00742
'Actualiza origen destino en todos00743
Form1 . Arcos ( a ) . Nd1 = i00744
Form1 . Arcos ( a ) . Nd2 = j00745
'actualiza valores de importación00746
'If opMatrizBinaria.Checked = True Then00747
'End If00748
If opMatrizMinimo . Checked = True Then00749
Form1 . Arcos ( a ) . Min = Val ( MatrizGenerica ( i» , j ))
00750
Form1 . Arcos ( a ) . Max = 000751
Form1 . Arcos ( a ) . Coste = 000752
End If00753
If opMatrizMaximo . Checked = True Then00754
Form1 . Arcos ( a ) . Min = 000755
Form1 . Arcos ( a ) . Max = Val ( MatrizGenerica ( i» , j ))
00756
Form1 . Arcos ( a ) . Coste = 000757
End If00758
If opMatrizCoste . Checked = True Then00759
Form1 . Arcos ( a ) . Min = 000760
Form1 . Arcos ( a ) . Max = 000761
Form1 . Arcos ( a ) . Coste = Val ( MatrizGenerica» ( i , j ))
00762
End If00763
End If00764
Next j00765
Next i00766
End If00767
00768
pbImportar . Value = 5 * 100 / paso00769
End If 'fin actualizar00770
00771
00772
'en caso de error00773
Catch ex As Exception00774
Me . Cursor = Cursors . Default00775
MsgBox ( "Ha fallado el proceso de importar datos." & vbCrLf & ex .» Message , MsgBoxStyle . Exclamation , "Grafos - Excepción" )
00776
'habilita botones y cursor ratón00777
btnImportar . Enabled = True00778
btnCancelar . Enabled = True00779
gbOpciones . Enabled = True00780
pbImportar . Value = 0 * 100 / paso00781
Me . Cursor = Cursors . Default00782
Exit Sub00783
Finally00784
End Try00785
00786
'habilita botones y cursor ratón00787
btnImportar . Enabled = True00788
btnCancelar . Enabled = True00789
gbOpciones . Enabled = True00790
Me . Cursor = Cursors . Default00791
pbImportar . Value = 0 * 100 / paso00792
'Dibuja el grafo00793
RaiseEvent ActualizaGrafo ( True )00794
End Sub00795
Private Sub chkSPTab_CheckedChanged ( ByVal sender As Object , ByVal e As» System . EventArgs ) Handles chkSPTab . CheckedChanged
00796
If chkSPTab . Checked = True Then00797
txtSP . Enabled = False00798
Else00799
txtSP . Enabled = True00800
End If00801
End Sub00802
Private Sub txtFL_KeyPress ( ByVal sender As Object , ByVal e As System . Windows» . Forms . KeyPressEventArgs ) Handles txtFL . KeyPress
00803
'carácter de fín de línea00804
'no se permiten números00805
'si se permite coma00806
'no se permite punto00807
'no se permite + -00808
'se permite vacío00809
If e . KeyChar = "-" Or e . KeyChar = "+" Or ( e . KeyChar >= "0" And e . KeyChar» <= "9" ) Or e . KeyChar = "." Then
00810
'carácter no permitido00811
e . Handled = True00812
Else00813
End If00814
End Sub00815
Private Sub txtSP_KeyPress ( ByVal sender As Object , ByVal e As System . Windows» . Forms . KeyPressEventArgs ) Handles txtSP . KeyPress
00816
'carácter de separación00817
'si se permite coma00818
'no se permite punto00819
'no se permite + -00820
'no se permite vacío (se controla en btnExportar)00821
If e . KeyChar = "-" Or e . KeyChar = "+" Or ( e . KeyChar >= "0" And e . KeyChar» <= "9" ) Or e . KeyChar = "." Then
00822
'carácter no permitido00823
e . Handled = True00824
Else00825
End If00826
End Sub00827
Private Sub txtNV_KeyPress ( ByVal sender As Object , ByVal e As System . Windows» . Forms . KeyPressEventArgs ) Handles txtNV . KeyPress
00828
'carácter de 'no valor'00829
'no se permiten números (sólo el cero 0)00830
'no se permite coma00831
'no se permite punto00832
'si se permite + -00833
'si se permite vacío00834
If ( e . KeyChar >= "1" And e . KeyChar <= "9" ) Or e . KeyChar = "," Or e .» KeyChar = "." Then
00835
'carácter no permitido00836
e . Handled = True00837
Else00838
End If00839
End Sub00840
00841
Private Sub txtSP_TextChanged ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles txtSP . TextChanged
00842
00843
End Sub00844
End Class00001
Public Class frmNuevoAleatorio00002
Inherits System . Windows . Forms . Form00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'Form reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
Friend WithEvents btnCancelar As System . Windows . Forms . Button00033
Friend WithEvents GroupBox1 As System . Windows . Forms . GroupBox00034
Friend WithEvents Label1 As System . Windows . Forms . Label00035
Friend WithEvents Label2 As System . Windows . Forms . Label00036
Friend WithEvents udTNodos As System . Windows . Forms . NumericUpDown00037
Friend WithEvents udTArcos As System . Windows . Forms . NumericUpDown00038
Friend WithEvents btnCrear As System . Windows . Forms . Button00039
Friend WithEvents chkArcosMismoNodo As System . Windows . Forms . CheckBox00040
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00041
Me . btnCrear = New System . Windows . Forms . Button00042
Me . btnCancelar = New System . Windows . Forms . Button00043
Me . GroupBox1 = New System . Windows . Forms . GroupBox00044
Me . udTNodos = New System . Windows . Forms . NumericUpDown00045
Me . Label1 = New System . Windows . Forms . Label00046
Me . udTArcos = New System . Windows . Forms . NumericUpDown00047
Me . Label2 = New System . Windows . Forms . Label00048
Me . chkArcosMismoNodo = New System . Windows . Forms . CheckBox00049
Me . GroupBox1 . SuspendLayout ()00050
CType ( Me . udTNodos , System . ComponentModel . ISupportInitialize ) . BeginInit ()00051
CType ( Me . udTArcos , System . ComponentModel . ISupportInitialize ) . BeginInit ()00052
Me . SuspendLayout ()00053
'00054
'btnCrear00055
'00056
Me . btnCrear . Location = New System . Drawing . Point ( 176 , 112 )00057
Me . btnCrear . Name = "btnCrear"00058
Me . btnCrear . Size = New System . Drawing . Size ( 88 , 24 )00059
Me . btnCrear . TabIndex = 500060
Me . btnCrear . Text = "Crear"00061
'00062
'btnCancelar00063
'00064
Me . btnCancelar . Location = New System . Drawing . Point ( 272 , 112 )00065
Me . btnCancelar . Name = "btnCancelar"00066
Me . btnCancelar . Size = New System . Drawing . Size ( 88 , 24 )00067
Me . btnCancelar . TabIndex = 400068
Me . btnCancelar . Text = "Cancelar"00069
'00070
'GroupBox100071
'00072
Me . GroupBox1 . Controls . Add ( Me . chkArcosMismoNodo )00073
Me . GroupBox1 . Controls . Add ( Me . udTNodos )00074
Me . GroupBox1 . Controls . Add ( Me . Label1 )00075
Me . GroupBox1 . Controls . Add ( Me . udTArcos )00076
Me . GroupBox1 . Controls . Add ( Me . Label2 )00077
Me . GroupBox1 . Location = New System . Drawing . Point ( 8 , 8 )00078
Me . GroupBox1 . Name = "GroupBox1"00079
Me . GroupBox1 . Size = New System . Drawing . Size ( 352 , 96 )00080
Me . GroupBox1 . TabIndex = 600081
Me . GroupBox1 . TabStop = False00082
'00083
'udTNodos00084
'00085
Me . udTNodos . Location = New System . Drawing . Point ( 88 , 24 )00086
Me . udTNodos . Maximum = New Decimal ( New Integer () { 200 , 0 , 0 , 0 })00087
Me . udTNodos . Minimum = New Decimal ( New Integer () { 1 , 0 , 0 , 0 })00088
Me . udTNodos . Name = "udTNodos"00089
Me . udTNodos . Size = New System . Drawing . Size ( 56 , 20 )00090
Me . udTNodos . TabIndex = 1100091
Me . udTNodos . Value = New Decimal ( New Integer () { 30 , 0 , 0 , 0 })00092
'00093
'Label100094
'00095
Me . Label1 . Location = New System . Drawing . Point ( 16 , 24 )00096
Me . Label1 . Name = "Label1"00097
Me . Label1 . Size = New System . Drawing . Size ( 72 , 16 )00098
Me . Label1 . TabIndex = 100099
Me . Label1 . Text = "Total Nodos:"00100
'00101
'udTArcos00102
'00103
Me . udTArcos . Location = New System . Drawing . Point ( 280 , 24 )00104
Me . udTArcos . Name = "udTArcos"00105
Me . udTArcos . Size = New System . Drawing . Size ( 56 , 20 )00106
Me . udTArcos . TabIndex = 1100107
Me . udTArcos . Value = New Decimal ( New Integer () { 50 , 0 , 0 , 0 })00108
'00109
'Label200110
'00111
Me . Label2 . Location = New System . Drawing . Point ( 160 , 24 )00112
Me . Label2 . Name = "Label2"00113
Me . Label2 . Size = New System . Drawing . Size ( 128 , 16 )00114
Me . Label2 . TabIndex = 100115
Me . Label2 . Text = "Densidad de Arcos (%):"00116
'00117
'chkArcosMismoNodo00118
'00119
Me . chkArcosMismoNodo . Location = New System . Drawing . Point ( 16 , 56 )00120
Me . chkArcosMismoNodo . Name = "chkArcosMismoNodo"00121
Me . chkArcosMismoNodo . Size = New System . Drawing . Size ( 232 , 24 )00122
Me . chkArcosMismoNodo . TabIndex = 1200123
Me . chkArcosMismoNodo . Text = "Arcos sobre un mismo nodo"00124
'00125
'frmNuevoAleatorio00126
'00127
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00128
Me . ClientSize = New System . Drawing . Size ( 368 , 143 )00129
Me . ControlBox = False00130
Me . Controls . Add ( Me . GroupBox1 )00131
Me . Controls . Add ( Me . btnCrear )00132
Me . Controls . Add ( Me . btnCancelar )00133
Me . Cursor = System . Windows . Forms . Cursors . Default00134
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle .» FixedToolWindow
00135
Me . Name = "frmNuevoAleatorio"00136
Me . Text = "Grafos - Opciones de generación de grafo aleatorio"00137
Me . TopMost = True00138
Me . GroupBox1 . ResumeLayout ( False )00139
CType ( Me . udTNodos , System . ComponentModel . ISupportInitialize ) . EndInit ()00140
CType ( Me . udTArcos , System . ComponentModel . ISupportInitialize ) . EndInit ()00141
Me . ResumeLayout ( False )00142
00143
End Sub00144
00145
# End Region00146
00147
Public Event ActualizaGrafo ( ByVal valor As Boolean , ByVal n As Long , ByVal a» As Long , ByVal r As Boolean )
00148
00149
Private Sub btnCancelar_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles btnCancelar . Click
00150
RaiseEvent ActualizaGrafo ( False , 0 , 0 , False )00151
Me . Visible = False00152
End Sub00153
00154
Private Sub btnCrear_Click ( ByVal sender As System . Object , ByVal e As System .» EventArgs ) Handles btnCrear . Click
00155
'deshabilita botones y cursor ratón00156
Me . Cursor = Cursors . WaitCursor00157
btnCrear . Enabled = False00158
btnCancelar . Enabled = False00159
00160
RaiseEvent ActualizaGrafo ( True , udTNodos . Value , udTArcos . Value ,» chkArcosMismoNodo . Checked )
00161
00162
00163
'habilita botones y cursor ratón00164
Me . Cursor = Cursors . Default00165
btnCrear . Enabled = True00166
btnCancelar . Enabled = True00167
Me . Visible = False00168
End Sub00169
End Class00001
Option Strict Off00002
Option Explicit On00003
Friend Class lpsolve5100004
00005
'lpsolve version 5 routines00006
00007
Private Declare Function SetEnvironmentVariableA Lib "kernel32" ( ByVal lpname» As String , ByVal lpValue As String ) As Integer
00008
Private Declare Function GetEnvironmentVariableA Lib "kernel32" ( ByVal lpname» As String , ByVal lpBuffer As String , ByVal nSize As Integer ) As Integer
00009
00010
'----------------------------------------------------------------------------» -------------------------------------------------
00011
00012
Public Declare Function add_column Lib "lpsolve51.dll" Alias "add_column" (» ByVal lp As Integer , ByRef column As Double ) As Boolean
00013
Public Declare Function add_columnex Lib "lpsolve51.dll" Alias "add_columnex"» ( ByVal lp As Integer , ByVal count As Integer , ByRef column As Double ,
» ByRef rowno As Integer ) As Boolean
00014
Public Declare Function add_constraint Lib "lpsolve51.dll" Alias» "add_constraint" ( ByVal lp As Integer , ByRef row As Double , ByVal
» constr_type As lpsolve_constr_types , ByVal rh As Double ) As Boolean
00015
Public Declare Function add_constraintex Lib "lpsolve51.dll" Alias» "add_constraintex" ( ByVal lp As Integer , ByVal count As Integer , ByRef
» row As Double , ByRef colno As Integer , ByVal constr_type As
» lpsolve_constr_types , ByVal rh As Double ) As Boolean
00016
Public Declare Function add_lag_con Lib "lpsolve51.dll" Alias "add_lag_con" (» ByVal lp As Integer , ByRef row As Double , ByVal con_type As
» lpsolve_constr_types , ByVal rhs As Double ) As Boolean
00017
Public Declare Function add_SOS Lib "lpsolve51.dll" Alias "add_SOS" ( ByVal lp» As Integer , ByVal name As String , ByVal sostype As Integer , ByVal
» priority As Integer , ByVal count As Integer , ByRef sosvars As Integer ,
» ByRef weights As Double ) As Integer
00018
Public Declare Function column_in_lp Lib "lpsolve51.dll" Alias "column_in_lp"» ( ByVal lp As Integer , ByRef column As Double ) As Integer
00019
Public Declare Sub default_basis Lib "lpsolve51.dll" Alias "default_basis" (» ByVal lp As Integer )
00020
Public Declare Function del_column Lib "lpsolve51.dll" Alias "del_column" (» ByVal lp As Integer , ByVal column As Integer ) As Boolean
00021
Public Declare Function del_constraint Lib "lpsolve51.dll" Alias» "del_constraint" ( ByVal lp As Integer , ByVal del_row As Integer ) As
» Boolean
00022
Public Declare Sub delete_lp Lib "lpsolve51.dll" Alias "delete_lp" ( ByVal lp» As Integer )
00023
Public Declare Function get_anti_degen Lib "lpsolve51.dll" Alias» "get_anti_degen" ( ByVal lp As Integer ) As lpsolve_anti_degen
00024
Public Declare Sub get_basis Lib "lpsolve51.dll" Alias "get_basis" ( ByVal lp» As Integer , ByRef bascolumn As Integer , ByVal nonbasic As Boolean )
00025
Public Declare Function get_basiscrash Lib "lpsolve51.dll" Alias» "get_basiscrash" ( ByVal lp As Integer ) As lpsolve_basiscrash
00026
Public Declare Function get_bb_depthlimit Lib "lpsolve51.dll" Alias» "get_bb_depthlimit" ( ByVal lp As Integer ) As Integer
00027
Public Declare Function get_bb_floorfirst Lib "lpsolve51.dll" Alias» "get_bb_floorfirst" ( ByVal lp As Integer ) As lpsolve_branch
00028
Public Declare Function get_bb_rule Lib "lpsolve51.dll" Alias "get_bb_rule" (» ByVal lp As Integer ) As lpsolve_BBstrategies
00029
Public Declare Function get_bounds_tighter Lib "lpsolve51.dll" Alias» "get_bounds_tighter" ( ByVal lp As Integer ) As Boolean
00030
Public Declare Function get_break_at_value Lib "lpsolve51.dll" Alias» "get_break_at_value" ( ByVal lp As Integer ) As Double
00031
Public Declare Function get_col_name Lib "lpsolve51.dll" Alias "get_col_name"» ( ByVal lp As Integer , ByVal column As Integer ) As String
00032
Public Declare Function get_column Lib "lpsolve51.dll" Alias "get_column" (» ByVal lp As Integer , ByVal col_nr As Integer , ByRef column As Double ) As
» Boolean
00033
Public Declare Function get_constr_type Lib "lpsolve51.dll" Alias» "get_constr_type" ( ByVal lp As Integer , ByVal row As Integer ) As
» lpsolve_constr_types
00034
Public Declare Function get_constraints Lib "lpsolve51.dll" Alias» "get_constraints" ( ByVal lp As Integer , ByRef constr As Double ) As
» Boolean
00035
Public Declare Function get_dual_solution Lib "lpsolve51.dll" Alias» "get_dual_solution" ( ByVal lp As Integer , ByRef rc As Double ) As Boolean
00036
Public Declare Function get_epsb Lib "lpsolve51.dll" Alias "get_epsb" ( ByVal» lp As Integer ) As Double
00037
Public Declare Function get_epsd Lib "lpsolve51.dll" Alias "get_epsd" ( ByVal» lp As Integer ) As Double
00038
Public Declare Function get_epsel Lib "lpsolve51.dll" Alias "get_epsel" (» ByVal lp As Integer ) As Double
00039
Public Declare Function get_epsint Lib "lpsolve51.dll" Alias "get_epsint" (» ByVal lp As Integer ) As Double
00040
Public Declare Function get_epsperturb Lib "lpsolve51.dll" Alias» "get_epsperturb" ( ByVal lp As Integer ) As Double
00041
Public Declare Function get_epspivot Lib "lpsolve51.dll" Alias "get_epspivot"» ( ByVal lp As Integer ) As Double
00042
Public Declare Function get_improve Lib "lpsolve51.dll" Alias "get_improve" (» ByVal lp As Integer ) As lpsolve_improves
00043
Public Declare Function get_infinite Lib "lpsolve51.dll" Alias "get_infinite"» ( ByVal lp As Integer ) As Double
00044
Public Declare Function get_lambda Lib "lpsolve51.dll" Alias "get_lambda" (» ByVal lp As Integer , ByRef lambda As Double ) As Boolean
00045
Public Declare Function get_lowbo Lib "lpsolve51.dll" Alias "get_lowbo" (» ByVal lp As Integer , ByVal column As Integer ) As Double
00046
Public Declare Function get_lp_index Lib "lpsolve51.dll" Alias "get_lp_index"» ( ByVal lp As Integer , ByVal orig_index As Integer ) As Integer
00047
Public Declare Function get_lp_name Lib "lpsolve51.dll" Alias "get_lp_name" (» ByVal lp As Integer ) As String
00048
Public Declare Function get_Lrows Lib "lpsolve51.dll" Alias "get_Lrows" (» ByVal lp As Integer ) As Integer
00049
Public Declare Function get_mat Lib "lpsolve51.dll" Alias "get_mat" ( ByVal lp» As Integer , ByVal row As Integer , ByVal column As Integer ) As Double
00050
Public Declare Function get_max_level Lib "lpsolve51.dll" Alias» "get_max_level" ( ByVal lp As Integer ) As Integer
00051
Public Declare Function get_maxpivot Lib "lpsolve51.dll" Alias "get_maxpivot"» ( ByVal lp As Integer ) As Integer
00052
Public Declare Function get_mip_gap Lib "lpsolve51.dll" Alias "get_mip_gap" (» ByVal lp As Integer , ByVal absolute As Boolean ) As Double
00053
Public Declare Function get_Ncolumns Lib "lpsolve51.dll" Alias "get_Ncolumns"» ( ByVal lp As Integer ) As Integer
00054
Public Declare Function get_negrange Lib "lpsolve51.dll" Alias "get_negrange"» ( ByVal lp As Integer ) As Double
00055
Public Declare Function get_nameindex Lib "lpsolve51.dll" Alias» "get_nameindex" ( ByVal lp As Integer , ByVal name As String , ByVal isrow
» As Boolean ) As Integer
00056
Public Declare Function get_nonzeros Lib "lpsolve51.dll" Alias "get_nonzeros"» ( ByVal lp As Integer ) As Integer
00057
Public Declare Function get_Norig_columns Lib "lpsolve51.dll" Alias» "get_Norig_columns" ( ByVal lp As Integer ) As Integer
00058
Public Declare Function get_Norig_rows Lib "lpsolve51.dll" Alias» "get_Norig_rows" ( ByVal lp As Integer ) As Integer
00059
Public Declare Function get_Nrows Lib "lpsolve51.dll" Alias "get_Nrows" (» ByVal lp As Integer ) As Integer
00060
Public Declare Function get_obj_bound Lib "lpsolve51.dll" Alias» "get_obj_bound" ( ByVal lp As Integer ) As Double
00061
Public Declare Function get_objective Lib "lpsolve51.dll" Alias» "get_objective" ( ByVal lp As Integer ) As Double
00062
Public Declare Function get_orig_index Lib "lpsolve51.dll" Alias» "get_orig_index" ( ByVal lp As Integer , ByVal lp_index As Integer ) As
» Integer
00063
Public Declare Function get_origcol_name Lib "lpsolve51.dll" Alias» "get_origcol_name" ( ByVal lp As Integer , ByVal column As Integer ) As
» String
00064
Public Declare Function get_origrow_name Lib "lpsolve51.dll" Alias» "get_origrow_name" ( ByVal lp As Integer , ByVal row As Integer ) As String
00065
Public Declare Function get_pivoting Lib "lpsolve51.dll" Alias "get_pivoting"» ( ByVal lp As Integer ) As lpsolve_piv_rules
00066
Public Declare Function get_presolve Lib "lpsolve51.dll" Alias "get_presolve"» ( ByVal lp As Integer ) As lpsolve_presolve
00067
Public Declare Function get_primal_solution Lib "lpsolve51.dll" Alias» "get_primal_solution" ( ByVal lp As Integer , ByRef pv_Renamed As Double )
» As Boolean
00068
Public Declare Function get_print_sol Lib "lpsolve51.dll" Alias» "get_print_sol" ( ByVal lp As Integer ) As Integer
00069
Public Declare Function get_PseudoCosts Lib "lpsolve51.dll" Alias» "get_PseudoCosts" ( ByVal lp As Integer , ByRef clower As Double , ByRef
» cupper As Double , ByRef updatelimit As Integer ) As Boolean
00070
Public Declare Function get_rh Lib "lpsolve51.dll" Alias "get_rh" ( ByVal lp» As Integer , ByVal row As Integer ) As Double
00071
Public Declare Function get_rh_range Lib "lpsolve51.dll" Alias "get_rh_range"» ( ByVal lp As Integer , ByVal row As Integer ) As Double
00072
Public Declare Function get_row Lib "lpsolve51.dll" Alias "get_row" ( ByVal lp» As Integer , ByVal row_nr As Integer , ByRef row As Double ) As Boolean
00073
Public Declare Function get_row_name Lib "lpsolve51.dll" Alias "get_row_name"» ( ByVal lp As Integer , ByVal row As Integer ) As String
00074
Public Declare Function get_scalelimit Lib "lpsolve51.dll" Alias» "get_scalelimit" ( ByVal lp As Integer ) As Double
00075
Public Declare Function get_scaling Lib "lpsolve51.dll" Alias "get_scaling" (» ByVal lp As Integer ) As lpsolve_scales
00076
Public Declare Function get_sensitivity_obj Lib "lpsolve51.dll" Alias» "get_sensitivity_obj" ( ByVal lp As Integer , ByRef objfrom As Double ,
» ByRef objtill As Double ) As Boolean
00077
Public Declare Function get_sensitivity_objex Lib "lpsolve51.dll" Alias» "get_sensitivity_objex" ( ByVal lp As Integer , ByRef objfrom As Double ,
» ByRef objtill As Double , ByRef objfromvalue As Double , ByRef objtillvalue
» As Double ) As Boolean
00078
Public Declare Function get_sensitivity_rhs Lib "lpsolve51.dll" Alias» "get_sensitivity_rhs" ( ByVal lp As Integer , ByRef duals As Double , ByRef
» dualsfrom As Double , ByRef dualstill As Double ) As Boolean
00079
Public Declare Function get_simplextype Lib "lpsolve51.dll" Alias» "get_simplextype" ( ByVal lp As Integer ) As lpsolve_simplextypes
00080
Public Declare Function get_solutioncount Lib "lpsolve51.dll" Alias» "get_solutioncount" ( ByVal lp As Integer ) As Integer
00081
Public Declare Function get_solutionlimit Lib "lpsolve51.dll" Alias» "get_solutionlimit" ( ByVal lp As Integer ) As Integer
00082
Public Declare Function get_status Lib "lpsolve51.dll" Alias "get_status" (» ByVal lp As Integer ) As Integer
00083
Public Declare Function get_statustext Lib "lpsolve51.dll" Alias» "get_statustext" ( ByVal lp As Integer , ByVal statuscode As Integer ) As
» String
00084
Public Declare Function get_timeout Lib "lpsolve51.dll" Alias "get_timeout" (» ByVal lp As Integer ) As Integer
00085
Public Declare Function get_total_iter Lib "lpsolve51.dll" Alias» "get_total_iter" ( ByVal lp As Integer ) As Integer
00086
Public Declare Function get_total_nodes Lib "lpsolve51.dll" Alias» "get_total_nodes" ( ByVal lp As Integer ) As Integer
00087
Public Declare Function get_upbo Lib "lpsolve51.dll" Alias "get_upbo" ( ByVal» lp As Integer , ByVal column As Integer ) As Double
00088
Public Declare Function get_var_branch Lib "lpsolve51.dll" Alias» "get_var_branch" ( ByVal lp As Integer , ByVal column As Integer ) As
» lpsolve_branch
00089
Public Declare Function get_var_dualresult Lib "lpsolve51.dll" Alias» "get_var_dualresult" ( ByVal lp As Integer , ByVal index As Integer ) As
» Double
00090
Public Declare Function get_var_primalresult Lib "lpsolve51.dll" Alias» "get_var_primalresult" ( ByVal lp As Integer , ByVal index As Integer ) As
» Double
00091
Public Declare Function get_var_priority Lib "lpsolve51.dll" Alias» "get_var_priority" ( ByVal lp As Integer , ByVal column As Integer ) As
» Integer
00092
Public Declare Function get_variables Lib "lpsolve51.dll" Alias» "get_variables" ( ByVal lp As Integer , ByRef var As Double ) As Boolean
00093
Public Declare Function get_verbose Lib "lpsolve51.dll" Alias "get_verbose" (» ByVal lp As Integer ) As Integer
00094
Public Declare Function get_working_objective Lib "lpsolve51.dll" Alias» "get_working_objective" ( ByVal lp As Integer ) As Double
00095
Public Declare Function has_BFP Lib "lpsolve51.dll" Alias "has_BFP" ( ByVal lp» As Integer ) As Boolean
00096
Public Declare Function has_XLI Lib "lpsolve51.dll" Alias "has_XLI" ( ByVal lp» As Integer ) As Boolean
00097
Public Declare Function is_add_rowmode Lib "lpsolve51.dll" Alias» "is_add_rowmode" ( ByVal lp As Integer ) As Boolean
00098
Public Declare Function is_anti_degen Lib "lpsolve51.dll" Alias» "is_anti_degen" ( ByVal lp As Integer , ByVal testmask As
» lpsolve_anti_degen ) As Boolean
00099
Public Declare Function is_binary Lib "lpsolve51.dll" Alias "is_binary" (» ByVal lp As Integer , ByVal column As Integer ) As Boolean
00100
Public Declare Function is_break_at_first Lib "lpsolve51.dll" Alias» "is_break_at_first" ( ByVal lp As Integer ) As Boolean
00101
Public Declare Function is_constr_type Lib "lpsolve51.dll" Alias» "is_constr_type" ( ByVal lp As Integer , ByVal row As Integer , ByVal mask
» As Integer ) As Boolean
00102
Public Declare Function is_debug Lib "lpsolve51.dll" Alias "is_debug" ( ByVal» lp As Integer ) As Boolean
00103
Public Declare Function is_feasible Lib "lpsolve51.dll" Alias "is_feasible" (» ByVal lp As Integer , ByRef values As Double , ByVal threshold As Double )
» As Boolean
00104
Public Declare Function is_free Lib "lpsolve51.dll" Alias "is_free" ( ByVal lp» As Integer , ByVal column As Integer ) As Boolean
00105
Public Declare Function is_infinite Lib "lpsolve51.dll" Alias "is_infinite" (» ByVal lp As Integer , ByVal value As Double ) As Boolean
00106
Public Declare Function is_int Lib "lpsolve51.dll" Alias "is_int" ( ByVal lp» As Integer , ByVal column As Integer ) As Boolean
00107
Public Declare Function is_integerscaling Lib "lpsolve51.dll" Alias» "is_integerscaling" ( ByVal lp As Integer ) As Boolean
00108
Public Declare Function is_lag_trace Lib "lpsolve51.dll" Alias "is_lag_trace"» ( ByVal lp As Integer ) As Boolean
00109
Public Declare Function is_maxim Lib "lpsolve51.dll" Alias "is_maxim" ( ByVal» lp As Integer ) As Boolean
00110
Public Declare Function is_nativeBFP Lib "lpsolve51.dll" Alias "is_nativeBFP"» ( ByVal lp As Integer ) As Boolean
00111
Public Declare Function is_nativeXLI Lib "lpsolve51.dll" Alias "is_nativeXLI"» ( ByVal lp As Integer ) As Boolean
00112
Public Declare Function is_negative Lib "lpsolve51.dll" Alias "is_negative" (» ByVal lp As Integer , ByVal column As Integer ) As Boolean
00113
Public Declare Function is_piv_mode Lib "lpsolve51.dll" Alias "is_piv_mode" (» ByVal lp As Integer , ByVal testmask As lpsolve_piv_rules ) As Boolean
00114
Public Declare Function is_piv_rule Lib "lpsolve51.dll" Alias "is_piv_rule" (» ByVal lp As Integer , ByVal rule As lpsolve_piv_rules ) As Boolean
00115
Public Declare Function is_presolve Lib "lpsolve51.dll" Alias "is_presolve" (» ByVal lp As Integer , ByVal testmask As lpsolve_presolve ) As Boolean
00116
Public Declare Function is_scalemode Lib "lpsolve51.dll" Alias "is_scalemode"» ( ByVal lp As Integer , ByVal testmask As lpsolve_scales ) As Boolean
00117
Public Declare Function is_scaletype Lib "lpsolve51.dll" Alias "is_scaletype"» ( ByVal lp As Integer , ByVal scaletype As lpsolve_scales ) As Boolean
00118
Public Declare Function is_semicont Lib "lpsolve51.dll" Alias "is_semicont" (» ByVal lp As Integer , ByVal column As Integer ) As Boolean
00119
Public Declare Function is_SOS_var Lib "lpsolve51.dll" Alias "is_SOS_var" (» ByVal lp As Integer , ByVal column As Integer ) As Boolean
00120
Public Declare Function is_trace Lib "lpsolve51.dll" Alias "is_trace" ( ByVal» lp As Integer ) As Boolean
00121
Public Declare Sub version Lib "lpsolve51.dll" Alias "lp_solve_version" (» ByRef majorversion As Integer , ByRef minorversion As Integer , ByRef
» release As Integer , ByRef build As Integer )
00122
Public Declare Function make_lp Lib "lpsolve51.dll" Alias "make_lp" ( ByVal» rows As Integer , ByVal columns As Integer ) As Integer
00123
Public Declare Sub print_constraints Lib "lpsolve51.dll" Alias» "print_constraints" ( ByVal lp As Integer , ByVal columns As Integer )
00124
Public Declare Function print_debugdump Lib "lpsolve51.dll" Alias» "print_debugdump" ( ByVal lp As Integer , ByVal filename As String ) As
» Boolean
00125
Public Declare Sub print_duals Lib "lpsolve51.dll" Alias "print_duals" ( ByVal» lp As Integer )
00126
Public Declare Sub print_lp Lib "lpsolve51.dll" Alias "print_lp" ( ByVal lp As» Integer )
00127
Public Declare Sub print_objective Lib "lpsolve51.dll" Alias» "print_objective" ( ByVal lp As Integer )
00128
Public Declare Sub print_scales Lib "lpsolve51.dll" Alias "print_scales" (» ByVal lp As Integer )
00129
Public Declare Sub print_solution Lib "lpsolve51.dll" Alias "print_solution"» ( ByVal lp As Integer , ByVal columns As Integer )
00130
Public Declare Sub print_str Lib "lpsolve51.dll" Alias "print_str" ( ByVal lp» As Integer , ByVal str_Renamed As String )
00131
Public Declare Sub print_tableau Lib "lpsolve51.dll" Alias "print_tableau" (» ByVal lp As Integer )
00132
Public Delegate Function abortfunc ( ByVal lp As Integer , ByVal userhandle As» Integer ) As Integer
00133
Public Declare Sub put_abortfunc Lib "lpsolve51.dll" Alias "put_abortfunc" (» ByVal lp As Integer , ByVal newctrlc As abortfunc , ByVal ctrlchandle As
» Integer )
00134
Public Delegate Sub logfunc ( ByVal lp As Integer , ByVal userhandle As Integer» , ByVal buf As String )
00135
Public Declare Sub put_logfunc Lib "lpsolve51.dll" Alias "put_logfunc" ( ByVal» lp As Integer , ByVal newlog As logfunc , ByVal loghandle As Integer )
00136
Public Delegate Sub msgfunc ( ByVal lp As Integer , ByVal userhandle As Integer» , ByVal message As lpsolve_msgmask )
00137
Public Declare Sub put_msgfunc Lib "lpsolve51.dll" Alias "put_msgfunc" ( ByVal» lp As Integer , ByVal newmsg As msgfunc , ByVal msghandle As Integer ,
» ByVal mask As lpsolve_msgmask )
00138
Public Declare Function read_basis Lib "lpsolve51.dll" Alias "read_basis" (» ByVal lp As Integer , ByVal filename As String , ByVal info As String ) As
» Boolean
00139
Public Declare Function read_freeMPS Lib "lpsolve51.dll" Alias "read_freeMPS"» ( ByVal filename As String , ByVal verbose As Integer ) As Integer
00140
Public Declare Function read_LP Lib "lpsolve51.dll" Alias "read_LP" ( ByVal» filename As String , ByVal verbose As Integer , ByVal lp_name As String ) As
» Integer
00141
Public Declare Function read_MPS Lib "lpsolve51.dll" Alias "read_MPS" ( ByVal» filename As String , ByVal verbose As Integer ) As Integer
00142
Public Declare Function read_XLI Lib "lpsolve51.dll" Alias "read_XLI" ( ByVal» xliname As String , ByVal modelname As String , ByVal dataname As String ,
» ByVal options As String , ByVal verbose As Integer ) As Integer
00143
Public Declare Sub reset_basis Lib "lpsolve51.dll" Alias "reset_basis" ( ByVal» lp As Integer )
00144
Public Declare Function set_add_rowmode Lib "lpsolve51.dll" Alias» "set_add_rowmode" ( ByVal lp As Integer , ByVal turnon As Boolean ) As
» Boolean
00145
Public Declare Sub set_anti_degen Lib "lpsolve51.dll" Alias "set_anti_degen"» ( ByVal lp As Integer , ByVal anti_degen As lpsolve_anti_degen )
00146
Public Declare Function set_basis Lib "lpsolve51.dll" Alias "set_basis" (» ByVal lp As Integer , ByRef bascolumn As Integer , ByVal nonbasic As
» Boolean ) As Boolean
00147
Public Declare Sub set_basiscrash Lib "lpsolve51.dll" Alias "set_basiscrash"» ( ByVal lp As Integer , ByVal mode As lpsolve_basiscrash )
00148
Public Declare Sub set_bb_depthlimit Lib "lpsolve51.dll" Alias» "set_bb_depthlimit" ( ByVal lp As Integer , ByVal bb_maxlevel As Integer )
00149
Public Declare Sub set_bb_floorfirst Lib "lpsolve51.dll" Alias» "set_bb_floorfirst" ( ByVal lp As Integer , ByVal bb_floorfirst As
» lpsolve_branch )
00150
Public Declare Sub set_bb_rule Lib "lpsolve51.dll" Alias "set_bb_rule" ( ByVal» lp As Integer , ByVal bb_rule As lpsolve_BBstrategies )
00151
Public Declare Function set_BFP Lib "lpsolve51.dll" Alias "set_BFP" ( ByVal lp» As Integer , ByVal filename As String ) As Boolean
00152
Public Declare Function set_binary Lib "lpsolve51.dll" Alias "set_binary" (» ByVal lp As Integer , ByVal column As Integer , ByVal must_be_bin As
» Boolean ) As Boolean
00153
Public Declare Function set_bounds Lib "lpsolve51.dll" Alias "set_bounds" (» ByVal lp As Integer , ByVal column As Integer , ByVal lower As Double ,
» ByVal upper As Double ) As Boolean
00154
Public Declare Sub set_bounds_tighter Lib "lpsolve51.dll" Alias» "set_bounds_tighter" ( ByVal lp As Integer , ByVal tighten As Boolean )
00155
Public Declare Sub set_break_at_first Lib "lpsolve51.dll" Alias» "set_break_at_first" ( ByVal lp As Integer , ByVal break_at_first As
» Boolean )
00156
Public Declare Sub set_break_at_value Lib "lpsolve51.dll" Alias» "set_break_at_value" ( ByVal lp As Integer , ByVal break_at_value As Double
» )
00157
Public Declare Function set_col_name Lib "lpsolve51.dll" Alias "set_col_name"» ( ByVal lp As Integer , ByVal column As Integer , ByVal new_name As String )
» As Boolean
00158
Public Declare Function set_column Lib "lpsolve51.dll" Alias "set_column" (» ByVal lp As Integer , ByVal col_no As Integer , ByRef column As Double ) As
» Boolean
00159
Public Declare Function set_columnex Lib "lpsolve51.dll" Alias "set_columnex"» ( ByVal lp As Integer , ByVal col_no As Integer , ByVal count As Integer ,
» ByRef column As Double , ByRef rowno As Integer ) As Boolean
00160
Public Declare Function set_constr_type Lib "lpsolve51.dll" Alias» "set_constr_type" ( ByVal lp As Integer , ByVal row As Integer , ByVal
» con_type As lpsolve_constr_types ) As Boolean
00161
Public Declare Sub set_debug Lib "lpsolve51.dll" Alias "set_debug" ( ByVal lp» As Integer , ByVal debug_ As Boolean )
00162
Public Declare Sub set_epsb Lib "lpsolve51.dll" Alias "set_epsb" ( ByVal lp As» Integer , ByVal epsb As Double )
00163
Public Declare Sub set_epsd Lib "lpsolve51.dll" Alias "set_epsd" ( ByVal lp As» Integer , ByVal epsd As Double )
00164
Public Declare Sub set_epsel Lib "lpsolve51.dll" Alias "set_epsel" ( ByVal lp» As Integer , ByVal epsel As Double )
00165
Public Declare Sub set_epsint Lib "lpsolve51.dll" Alias "set_epsint" ( ByVal» lp As Integer , ByVal epsint As Double )
00166
Public Declare Sub set_epsperturb Lib "lpsolve51.dll" Alias "set_epsperturb"» ( ByVal lp As Integer , ByVal epsperturb As Double )
00167
Public Declare Sub set_epspivot Lib "lpsolve51.dll" Alias "set_epspivot" (» ByVal lp As Integer , ByVal epspivot As Double )
00168
Public Declare Function set_free Lib "lpsolve51.dll" Alias "set_free" ( ByVal» lp As Integer , ByVal column As Integer ) As Boolean
00169
Public Declare Sub set_improve Lib "lpsolve51.dll" Alias "set_improve" ( ByVal» lp As Integer , ByVal improve As lpsolve_improves )
00170
Public Declare Sub set_infinite Lib "lpsolve51.dll" Alias "set_infinite" (» ByVal lp As Integer , ByVal infinite As Double )
00171
Public Declare Function set_int Lib "lpsolve51.dll" Alias "set_int" ( ByVal lp» As Integer , ByVal column As Integer , ByVal must_be_int As Boolean ) As
» Boolean
00172
Public Declare Sub set_lag_trace Lib "lpsolve51.dll" Alias "set_lag_trace" (» ByVal lp As Integer , ByVal lag_trace As Boolean )
00173
Public Declare Function set_lowbo Lib "lpsolve51.dll" Alias "set_lowbo" (» ByVal lp As Integer , ByVal column As Integer , ByVal value As Double ) As
» Boolean
00174
Public Declare Function set_lp_name Lib "lpsolve51.dll" Alias "set_lp_name" (» ByVal lp As Integer , ByVal lpname As String ) As Boolean
00175
Public Declare Function set_mat Lib "lpsolve51.dll" Alias "set_mat" ( ByVal lp» As Integer , ByVal row As Integer , ByVal column As Integer , ByVal value
» As Double ) As Boolean
00176
Public Declare Sub set_maxim Lib "lpsolve51.dll" Alias "set_maxim" ( ByVal lp» As Integer )
00177
Public Declare Sub set_maxpivot Lib "lpsolve51.dll" Alias "set_maxpivot" (» ByVal lp As Integer , ByVal max_num_inv As Integer )
00178
Public Declare Sub set_minim Lib "lpsolve51.dll" Alias "set_minim" ( ByVal lp» As Integer )
00179
Public Declare Sub set_mip_gap Lib "lpsolve51.dll" Alias "set_mip_gap" ( ByVal» lp As Integer , ByVal absolute As Boolean , ByVal mip_gap As Double )
00180
Public Declare Sub set_negrange Lib "lpsolve51.dll" Alias "set_negrange" (» ByVal lp As Integer , ByVal negrange As Double )
00181
Public Declare Function set_obj Lib "lpsolve51.dll" Alias "set_obj" ( ByVal lp» As Integer , ByVal column As Integer , ByVal value As Double ) As Boolean
00182
Public Declare Sub set_obj_bound Lib "lpsolve51.dll" Alias "set_obj_bound" (» ByVal lp As Integer , ByVal obj_bound As Double )
00183
Public Declare Function set_obj_fn Lib "lpsolve51.dll" Alias "set_obj_fn" (» ByVal lp As Integer , ByRef row As Double ) As Boolean
00184
Public Declare Function set_obj_fnex Lib "lpsolve51.dll" Alias "set_obj_fnex"» ( ByVal lp As Integer , ByVal count As Integer , ByRef row As Double , ByRef
» colno As Integer ) As Boolean
00185
Public Declare Function set_outputfile Lib "lpsolve51.dll" Alias» "set_outputfile" ( ByVal lp As Integer , ByVal filename As String ) As
» Boolean
00186
Public Declare Sub set_pivoting Lib "lpsolve51.dll" Alias "set_pivoting" (» ByVal lp As Integer , ByVal piv_rule As lpsolve_piv_rules )
00187
Public Declare Sub set_preferdual Lib "lpsolve51.dll" Alias "set_preferdual"» ( ByVal lp As Integer , ByVal dodual As Boolean )
00188
Public Declare Sub set_presolve Lib "lpsolve51.dll" Alias "set_presolve" (» ByVal lp As Integer , ByVal do_presolve As lpsolve_presolve )
00189
Public Declare Sub set_print_sol Lib "lpsolve51.dll" Alias "set_print_sol" (» ByVal lp As Integer , ByVal print_sol As Integer )
00190
Public Declare Function set_PseudoCosts Lib "lpsolve51.dll" Alias» "set_PseudoCosts" ( ByVal lp As Integer , ByRef clower As Double , ByRef
» cupper As Double , ByRef updatelimit As Integer ) As Boolean
00191
Public Declare Function set_rh Lib "lpsolve51.dll" Alias "set_rh" ( ByVal lp» As Integer , ByVal row As Integer , ByVal value As Double ) As Boolean
00192
Public Declare Function set_rh_range Lib "lpsolve51.dll" Alias "set_rh_range"» ( ByVal lp As Integer , ByVal row As Integer , ByVal deltavalue As Double )
» As Boolean
00193
Public Declare Sub set_rh_vec Lib "lpsolve51.dll" Alias "set_rh_vec" ( ByVal» lp As Integer , ByRef rh As Double )
00194
Public Declare Function set_row Lib "lpsolve51.dll" Alias "set_row" ( ByVal lp» As Integer , ByVal row_no As Integer , ByRef row As Double ) As Boolean
00195
Public Declare Function set_row_name Lib "lpsolve51.dll" Alias "set_row_name"» ( ByVal lp As Integer , ByVal row As Integer , ByVal new_name As String ) As
» Boolean
00196
Public Declare Function set_rowex Lib "lpsolve51.dll" Alias "set_rowex" (» ByVal lp As Integer , ByVal row_no As Integer , ByVal count As Integer ,
» ByRef row As Double , ByRef colno As Integer ) As Boolean
00197
Public Declare Sub set_scalelimit Lib "lpsolve51.dll" Alias "set_scalelimit"» ( ByVal lp As Integer , ByVal scalelimit As Double )
00198
Public Declare Sub set_scaling Lib "lpsolve51.dll" Alias "set_scaling" ( ByVal» lp As Integer , ByVal scalemode As lpsolve_scales )
00199
Public Declare Function set_semicont Lib "lpsolve51.dll" Alias "set_semicont"» ( ByVal lp As Integer , ByVal column As Integer , ByVal must_be_sc As
» Boolean ) As Boolean
00200
Public Declare Sub set_sense Lib "lpsolve51.dll" Alias "set_sense" ( ByVal lp» As Integer , ByVal maximize As Boolean )
00201
Public Declare Sub set_simplextype Lib "lpsolve51.dll" Alias» "set_simplextype" ( ByVal lp As Integer , ByVal simplextype As
» lpsolve_simplextypes )
00202
Public Declare Sub set_solutionlimit Lib "lpsolve51.dll" Alias» "set_solutionlimit" ( ByVal lp As Integer , ByVal limit As Integer )
00203
Public Declare Sub set_timeout Lib "lpsolve51.dll" Alias "set_timeout" ( ByVal» lp As Integer , ByVal sectimeout As Integer )
00204
Public Declare Sub set_trace Lib "lpsolve51.dll" Alias "set_trace" ( ByVal lp» As Integer , ByVal trace As Boolean )
00205
Public Declare Function set_upbo Lib "lpsolve51.dll" Alias "set_upbo" ( ByVal» lp As Integer , ByVal column As Integer , ByVal value As Double ) As Boolean
00206
Public Declare Function set_var_branch Lib "lpsolve51.dll" Alias» "set_var_branch" ( ByVal lp As Integer , ByVal column As Integer , ByVal
» branch_mode As lpsolve_branch ) As Boolean
00207
Public Declare Function set_var_weights Lib "lpsolve51.dll" Alias» "set_var_weights" ( ByVal lp As Integer , ByRef weights As Double ) As
» Boolean
00208
Public Declare Sub set_verbose Lib "lpsolve51.dll" Alias "set_verbose" ( ByVal» lp As Integer , ByVal verbose As Integer )
00209
Public Declare Function set_XLI Lib "lpsolve51.dll" Alias "set_XLI" ( ByVal lp» As Integer , ByVal filename As String ) As Boolean
00210
Public Declare Function solve Lib "lpsolve51.dll" Alias "solve" ( ByVal lp As» Integer ) As lpsolve_return
00211
Public Declare Function str_add_column Lib "lpsolve51.dll" Alias» "str_add_column" ( ByVal lp As Integer , ByVal col_string As String ) As
» Boolean
00212
Public Declare Function str_add_constraint Lib "lpsolve51.dll" Alias» "str_add_constraint" ( ByVal lp As Integer , ByVal row_string As String ,
» ByVal constr_type As lpsolve_constr_types , ByVal rh As Double ) As Boolean
00213
Public Declare Function str_add_lag_con Lib "lpsolve51.dll" Alias» "str_add_lag_con" ( ByVal lp As Integer , ByVal row_string As String , ByVal
» con_type As lpsolve_constr_types , ByVal rhs As Double ) As Boolean
00214
Public Declare Function str_set_obj_fn Lib "lpsolve51.dll" Alias» "str_set_obj_fn" ( ByVal lp As Integer , ByVal row_string As String ) As
» Boolean
00215
Public Declare Function str_set_rh_vec Lib "lpsolve51.dll" Alias» "str_set_rh_vec" ( ByVal lp As Integer , ByVal rh_string As String ) As
» Boolean
00216
Public Declare Function time_elapsed Lib "lpsolve51.dll" Alias "time_elapsed"» ( ByVal lp As Integer ) As Double
00217
Public Declare Sub unscale Lib "lpsolve51.dll" Alias "unscale" ( ByVal lp As» Integer )
00218
Public Declare Function write_basis Lib "lpsolve51.dll" Alias "write_basis" (» ByVal lp As Integer , ByVal filename As String ) As Boolean
00219
Public Declare Function write_freemps Lib "lpsolve51.dll" Alias» "write_freemps" ( ByVal lp As Integer , ByVal filename As String ) As
» Boolean
00220
Public Declare Function write_lp Lib "lpsolve51.dll" Alias "write_lp" ( ByVal» lp As Integer , ByVal filename As String ) As Boolean
00221
Public Declare Function write_mps Lib "lpsolve51.dll" Alias "write_mps" (» ByVal lp As Integer , ByVal filename As String ) As Boolean
00222
Public Declare Function write_XLI Lib "lpsolve51.dll" Alias "write_XLI" (» ByVal lp As Integer , ByVal filename As String , ByVal options As String ,
» ByVal results As Boolean ) As Boolean
00223
00224
'----------------------------------------------------------------------------» -------------------------------------------------
00225
00226
'possible type of constraints00227
Public Enum lpsolve_constr_types00228
LE = 100229
EQ = 300230
GE = 200231
FR = 000232
End Enum00233
00234
'Possible Scalings00235
Public Enum lpsolve_scales00236
SCALE_EXTREME = 100237
SCALE_RANGE = 200238
SCALE_MEAN = 300239
SCALE_GEOMETRIC = 400240
SCALE_CURTISREID = 700241
SCALE_QUADRATIC = 800242
SCALE_LOGARITHMIC = 1600243
SCALE_USERWEIGHT = 3100244
SCALE_POWER2 = 3200245
SCALE_EQUILIBRATE = 6400246
SCALE_INTEGERS = 12800247
End Enum00248
00249
'Possible Improvements00250
Public Enum lpsolve_improves00251
IMPROVE_NONE = 000252
IMPROVE_FTRAN = 100253
IMPROVE_BTRAN = 200254
IMPROVE_SOLVE = lpsolve_improves . IMPROVE_FTRAN + lpsolve_improves .» IMPROVE_BTRAN
00255
IMPROVE_INVERSE = 400256
End Enum00257
00258
Public Enum lpsolve_piv_rules00259
PRICER_FIRSTINDEX = 000260
PRICER_DANTZIG = 100261
PRICER_DEVEX = 200262
PRICER_STEEPESTEDGE = 300263
PRICE_PRIMALFALLBACK = 400264
PRICE_MULTIPLE = 800265
PRICE_PARTIAL = 1600266
PRICE_ADAPTIVE = 3200267
PRICE_HYBRID = 6400268
PRICE_RANDOMIZE = 12800269
PRICE_AUTOPARTIALCOLS = 25600270
PRICE_AUTOPARTIALROWS = 51200271
PRICE_LOOPLEFT = 102400272
PRICE_LOOPALTERNATE = 204800273
PRICE_AUTOPARTIAL = lpsolve_piv_rules . PRICE_AUTOPARTIALCOLS +» lpsolve_piv_rules . PRICE_AUTOPARTIALROWS
00274
End Enum00275
00276
Public Enum lpsolve_presolve00277
PRESOLVE_NONE = 000278
PRESOLVE_ROWS = 100279
PRESOLVE_COLS = 200280
PRESOLVE_LINDEP = 400281
PRESOLVE_SOS = 3200282
PRESOLVE_REDUCEMIP = 6400283
PRESOLVE_DUALS = 12800284
PRESOLVE_SENSDUALS = 25600285
End Enum00286
00287
Public Enum lpsolve_anti_degen00288
ANTIDEGEN_NONE = 000289
ANTIDEGEN_FIXEDVARS = 100290
ANTIDEGEN_COLUMNCHECK = 200291
ANTIDEGEN_STALLING = 400292
ANTIDEGEN_NUMFAILURE = 800293
ANTIDEGEN_LOSTFEAS = 1600294
ANTIDEGEN_INFEASIBLE = 3200295
ANTIDEGEN_DYNAMIC = 6400296
ANTIDEGEN_DURINGBB = 12800297
End Enum00298
00299
Public Enum lpsolve_basiscrash00300
CRASH_NOTHING = 000301
CRASH_MOSTFEASIBLE = 200302
End Enum00303
00304
Public Enum lpsolve_simplextypes00305
SIMPLEX_PRIMAL_PRIMAL = 500306
SIMPLEX_DUAL_PRIMAL = 600307
SIMPLEX_PRIMAL_DUAL = 900308
SIMPLEX_DUAL_DUAL = 1000309
End Enum00310
00311
'B&B strategies00312
Public Enum lpsolve_BBstrategies00313
NODE_FIRSTSELECT = 000314
NODE_GAPSELECT = 100315
NODE_RANGESELECT = 200316
NODE_FRACTIONSELECT = 300317
NODE_PSEUDOCOSTSELECT = 400318
NODE_PSEUDONONINTSELECT = 500319
NODE_PSEUDORATIOSELECT = 600320
NODE_USERSELECT = 700321
NODE_WEIGHTREVERSEMODE = 800322
NODE_BRANCHREVERSEMODE = 1600323
NODE_GREEDYMODE = 3200324
NODE_PSEUDOCOSTMODE = 6400325
NODE_DEPTHFIRSTMODE = 12800326
NODE_RANDOMIZEMODE = 25600327
NODE_GUBMODE = 51200328
NODE_DYNAMICMODE = 102400329
NODE_RESTARTMODE = 204800330
End Enum00331
00332
'possible return values of lp solver00333
Public Enum lpsolve_return00334
NOMEMORY = - 200335
OPTIMAL = 000336
SUBOPTIMAL = 100337
INFEASIBLE = 200338
UNBOUNDED = 300339
DEGENERATE = 400340
NUMFAILURE = 500341
USERABORT = 600342
TIMEOUT = 700343
PROCFAIL = 1000344
PROCBREAK = 1100345
FEASFOUND = 1200346
NOFEASFOUND = 1300347
End Enum00348
00349
'possible branch values00350
Public Enum lpsolve_branch00351
BRANCH_CEILING = 000352
BRANCH_FLOOR = 100353
BRANCH_AUTOMATIC = 200354
End Enum00355
00356
'possible message values00357
Public Enum lpsolve_msgmask00358
MSG_PRESOLVE = 100359
MSG_LPFEASIBLE = 800360
MSG_LPOPTIMAL = 1600361
MSG_MILPEQUAL = 3200362
MSG_MILPFEASIBLE = 12800363
MSG_MILPBETTER = 51200364
End Enum00365
00366
Private Function SetEnvironmentVariable ( ByRef name As String , ByRef value As» String ) As Boolean
00367
00368
SetEnvironmentVariable = SetEnvironmentVariableA ( name , value )00369
00370
End Function00371
00372
Private Function GetEnvironmentVariable ( ByRef name As String ) As String00373
Dim l As Integer00374
Dim buf As String00375
00376
l = GetEnvironmentVariableA ( name , vbNullString , 0 )00377
If l > 0 Then00378
buf = Space ( l )00379
l = GetEnvironmentVariableA ( name , buf , Len ( buf ))00380
GetEnvironmentVariable = Mid ( buf , 1 , l )00381
End If00382
00383
End Function00384
00385
Public Function Init ( Optional ByVal dllPath As String = "" ) As Boolean00386
Static bEnvChanged As Boolean00387
Dim Path As String00388
Dim buf As String00389
00390
If Len ( dllPath ) = 0 Then00391
dllPath = CurDir ()00392
End If00393
buf = dllPath00394
If Right ( buf , 1 ) <> "\" Then00395
buf = buf & "\"00396
End If00397
buf = buf & "lpsolve51.dll"00398
On Error Resume Next00399
Init = ( Len ( Dir ( buf , FileAttribute . Normal )) > 0 )00400
If Init Then00401
If Not bEnvChanged Then00402
bEnvChanged = True00403
Path = GetEnvironmentVariable ( "PATH" )00404
If InStr ( 1 , Path & ";" , dllPath & ";" , CompareMethod . Text ) = 0» Then
00405
SetEnvironmentVariable ( "PATH" , dllPath & ";" & Path )00406
End If00407
End If00408
End If00409
00410
End Function00411
00412
End Class00001
Imports System . IO00002
00003
Module Module100004
00005
00006
00007
Public Function TomaObjetoGraphics ( ByVal pbox As PictureBox ) As Graphics00008
'crea un bitmap de las mismas dimesiones que el picturebox00009
Dim bmp As Bitmap00010
bmp = New Bitmap ( pbox . Width , pbox . Height )00011
'asigna el bitmap al picturebox00012
00013
pbox . Image = bmp00014
'---------------------------------00015
'esta línea parece importante00016
'la he añadido y al hacer pruebas00017
'la memoria se comporta mejor!!!00018
pbox . Invalidate ()00019
'------------------------------------00020
'crea un objeto graphics a partir del bitmap00021
Dim G2 As Graphics00022
G2 = Graphics . FromImage ( bmp )00023
00024
'devuelve el objeto Graphics00025
Return G200026
00027
End Function00028
00029
00030
Public Sub FiltraTexto ( ByVal Caja As TextBox )00031
'Esta rutina repasa el contenido de la caja de texto y00032
'evita que existan más de una coma seguida00033
'evita más de 2 punto y coma en toda la cadena00034
'también evita dos signos menos seguidos00035
'Si se deja pasar, ocasionaría errores de conversión a single!!!00036
Dim i As Long00037
Dim cadena1 As String00038
Dim cadena2 As String00039
Dim l As String00040
00041
cadena1 = Caja . Text00042
cadena2 = ""00043
00044
Dim contpc As Long 'contador de punto y coma00045
Dim contc As Long 'contador de coma00046
Dim contm As Long 'contador de signo menos00047
Dim marcai As Long 'marca de inicio00048
contpc = 000049
contc = 000050
contm = 000051
marcai = 100052
For i = 1 To cadena1 . Length00053
l = Mid ( cadena1 , i , 1 )00054
00055
If l = "," Then contc = contc + 100056
If l = "-" Then contm = contm + 100057
If l = ";" Then contpc = contpc + 1 : contc = 0 : contm = 0 :» marcai = i + 1
00058
00059
If ( l = "," And contc > 1 ) Or ( l = "-" And ( contm > 1 Or marcai <>» i )) Or ( l = ";" And contpc > 2 ) Then
00060
00061
Else00062
cadena2 = cadena2 & l00063
End If00064
00065
Next i00066
Caja . Text = cadena200067
End Sub00068
00069
00070
Public Function DialogoColor ( ByVal ColorInicial As Color ) As Color00071
'Muestra cuadro de diálogo de color00072
Dim MiDialogo As New ColorDialog00073
00074
'permite elegir cualquier color incluso personalizados00075
MiDialogo . AllowFullOpen = True00076
MiDialogo . AnyColor = True00077
MiDialogo . FullOpen = True00078
00079
MiDialogo . ShowHelp = True00080
00081
MiDialogo . Color = ColorInicial00082
MiDialogo . ShowDialog ()00083
Return MiDialogo . Color00084
00085
00086
End Function00087
00088
Public Function CopiaImagenPortapapeles ( ByVal pbox As PictureBox )00089
'Copia la imagen al portapapeles00090
'los datos NO permanecerán en el portapapeles aunque se cierre el» programa
00091
'si se ponía true petaba (no sé porqué) en XP00092
Clipboard . SetDataObject ( pbox . Image , False )00093
End Function00094
Public Function ExportaImagen ( ByVal pbox As PictureBox )00095
00096
'Esta opción de menú muestra el cuadro de diálogo00097
'de grabar fichero y maneja las opciones de exportar00098
'la imagen del picturebox a un formato gráfico00099
00100
Dim saveFileDialog1 As New SaveFileDialog00101
00102
saveFileDialog1 . Filter = "Graphics Interchange Format» (*.gif)|*.gif|Bitmap Image (*.bmp)|*.bmp|Tagged Image File Format
» (*.tif)|*.tif|Portable Network Graphics format (*.png)|*.png|Scalable
» Vector Graphics (*.svg)|*.svg"
00103
saveFileDialog1 . FilterIndex = 1 'formato por defecto .gif00104
saveFileDialog1 . Title = "Exportar Imagen del Grafo"00105
saveFileDialog1 . RestoreDirectory = True00106
00107
If saveFileDialog1 . ShowDialog () = DialogResult . OK Then00108
Try00109
'Selecciona el formato gráfico que ha escogido el usuario00110
Select Case saveFileDialog1 . FilterIndex00111
Case 100112
pbox . Image . Save ( saveFileDialog1 . FileName , System .» Drawing . Imaging . ImageFormat . Gif )
00113
Case 200114
pbox . Image . Save ( saveFileDialog1 . FileName , System .» Drawing . Imaging . ImageFormat . Bmp )
00115
Case 300116
pbox . Image . Save ( saveFileDialog1 . FileName , System .» Drawing . Imaging . ImageFormat . Tiff )
00117
Case 400118
pbox . Image . Save ( saveFileDialog1 . FileName , System .» Drawing . Imaging . ImageFormat . Png )
00119
Case 500120
Dim f1 As New Form100121
f1 . DibujaGrafoSVG ( saveFileDialog1 . FileName )00122
End Select00123
Catch ex As Exception00124
MsgBox ( "Ha fallado el proceso de exportar imagen." & vbCrLf &» ex . Message , MsgBoxStyle . Exclamation , "Grafos - Excepción" )
00125
Exit Function00126
Finally00127
00128
End Try00129
End If00130
00131
00132
00133
End Function00134
00135
Public Function InterceptaTeclas ( ByVal e As Object )00136
00137
'no permite la pulsación de punto decimal00138
If e . KeyChar = "." Then00139
e . Handled = True00140
End If00141
'sólo numeros, separador ; y coma decimal00142
If e . KeyChar = "-" Or ( e . KeyChar >= "0" And e . KeyChar <= "9" ) Or e .» KeyChar = "," Or e . KeyChar = Chr ( Keys . Delete ) Or e . KeyChar = Chr ( Keys
» . Back ) Then
00143
'caracter permitido00144
Else00145
e . Handled = True00146
End If00147
00148
00149
End Function00150
00151
Public Sub LeeFicheroTexto ( ByVal TrayectoriaFichero As String , ByRef Texto» As String )
00152
'Abre el fichero para leer00153
Try00154
00155
Dim s As Stream = File . OpenRead ( TrayectoriaFichero )00156
Dim sr As StreamReader = New StreamReader ( TrayectoriaFichero ,» System . Text . Encoding . Default , False )
00157
00158
Texto = sr . ReadToEnd00159
sr . Close ()00160
sr = Nothing00161
Catch ex As Exception00162
'MsgBox("Ha fallado la operación de abrir el fichero." & vbCrLf &» ex.Message, MsgBoxStyle.Exclamation, "Grafos - Excepción")
00163
Exit Sub00164
Finally00165
00166
End Try00167
FileClose ()00168
End Sub00169
00170
Public Sub EscribeFicheroTexto ( ByVal TrayectoriaFichero As String , ByVal» Texto As String )
00171
'Abre el fichero para guardar00172
'si existe el fichero lo borra00173
00174
00175
Try00176
Dim sw As StreamWriter = New StreamWriter ( TrayectoriaFichero )00177
00178
sw . Write ( Texto )00179
sw . Close ()00180
sw = Nothing00181
Catch ex As Exception00182
'MsgBox("Ha fallado la operación de guardar el fichero." & vbCrLf &» ex.Message, MsgBoxStyle.Exclamation, "Grafos - Excepción")
00183
Exit Sub00184
Finally00185
'¿se habrá cerrado?00186
00187
End Try00188
FileClose ()00189
00190
End Sub00191
End Module00001
Public Class Splash00002
Inherits System . Windows . Forms . Form00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'Form reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
Friend WithEvents PictureBox1 As System . Windows . Forms . PictureBox00033
Friend WithEvents GroupBox1 As System . Windows . Forms . GroupBox00034
Friend WithEvents Label4 As System . Windows . Forms . Label00035
Friend WithEvents lblVersion As System . Windows . Forms . Label00036
Friend WithEvents lblDescripcion As System . Windows . Forms . Label00037
Friend WithEvents lblCopyR As System . Windows . Forms . Label00038
Friend WithEvents lblTitle As System . Windows . Forms . Label00039
Friend WithEvents lblCopyR2 As System . Windows . Forms . Label00040
Friend WithEvents linkGrafos As System . Windows . Forms . LinkLabel00041
Friend WithEvents PictureBox2 As System . Windows . Forms . PictureBox00042
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00043
Dim resources As System . Resources . ResourceManager = New System . Resources» . ResourceManager ( GetType ( Splash ))
00044
Me . PictureBox1 = New System . Windows . Forms . PictureBox00045
Me . GroupBox1 = New System . Windows . Forms . GroupBox00046
Me . lblCopyR2 = New System . Windows . Forms . Label00047
Me . lblCopyR = New System . Windows . Forms . Label00048
Me . lblTitle = New System . Windows . Forms . Label00049
Me . lblVersion = New System . Windows . Forms . Label00050
Me . Label4 = New System . Windows . Forms . Label00051
Me . lblDescripcion = New System . Windows . Forms . Label00052
Me . linkGrafos = New System . Windows . Forms . LinkLabel00053
Me . PictureBox2 = New System . Windows . Forms . PictureBox00054
Me . SuspendLayout ()00055
'00056
'PictureBox100057
'00058
Me . PictureBox1 . BackColor = System . Drawing . Color . Black00059
Me . PictureBox1 . Dock = System . Windows . Forms . DockStyle . Top00060
Me . PictureBox1 . Location = New System . Drawing . Point ( 0 , 0 )00061
Me . PictureBox1 . Name = "PictureBox1"00062
Me . PictureBox1 . Size = New System . Drawing . Size ( 450 , 72 )00063
Me . PictureBox1 . TabIndex = 000064
Me . PictureBox1 . TabStop = False00065
'00066
'GroupBox100067
'00068
Me . GroupBox1 . BackColor = System . Drawing . Color . LightSlateGray00069
Me . GroupBox1 . Location = New System . Drawing . Point ( 8 , 224 )00070
Me . GroupBox1 . Name = "GroupBox1"00071
Me . GroupBox1 . Size = New System . Drawing . Size ( 435 , 8 )00072
Me . GroupBox1 . TabIndex = 100073
Me . GroupBox1 . TabStop = False00074
'00075
'lblCopyR200076
'00077
Me . lblCopyR2 . Font = New System . Drawing . Font ( "Verdana" , 7.0 !)00078
Me . lblCopyR2 . Location = New System . Drawing . Point ( 8 , 240 )00079
Me . lblCopyR2 . Name = "lblCopyR2"00080
Me . lblCopyR2 . Size = New System . Drawing . Size ( 440 , 112 )00081
Me . lblCopyR2 . TabIndex = 200082
Me . lblCopyR2 . Text = "Advertencia: este programa está protegido por las» leyes de derechos de autor y ot" & _
00083
"ros tratados internacionales. Grafos es un software libre y gratuito.» Se distrib" & _
00084
"uye bajo las condiciones: Reconocimiento-NoComercial-CompartirIgual» 2.1. (Creati" & _
00085
"ve Commons License). La comercialización sin consentimiento del autor» de este pr" & _
00086
"ograma o cualquier parte del mismo, está penada por la ley con severas» sanciones" & _
00087
" civiles y penales, y será objeto de todas las acciones judiciales que» correspon" & _
00088
"dan."" & vbcrlf & ""Grafos incluye la librería lp_solve 5.x Copyright» 1991, 2005 F" & _
00089
"ree Software Foundation, Inc. bajo licencia LGPL."00090
Me . lblCopyR2 . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00091
'00092
'lblCopyR00093
'00094
Me . lblCopyR . Font = New System . Drawing . Font ( "Verdana" , 8.25 !, System .» Drawing . FontStyle . Bold , System . Drawing . GraphicsUnit . Point , CType ( 0 ,
» Byte ))
00095
Me . lblCopyR . ForeColor = System . Drawing . Color . FromArgb ( CType ( 0 , Byte ),» CType ( 0 , Byte ), CType ( 64 , Byte ))
00096
Me . lblCopyR . Location = New System . Drawing . Point ( 16 , 176 )00097
Me . lblCopyR . Name = "lblCopyR"00098
Me . lblCopyR . Size = New System . Drawing . Size ( 424 , 16 )00099
Me . lblCopyR . TabIndex = 400100
Me . lblCopyR . Text = "(cc) 2003..2005 - Alejandro Rodríguez Villalobos"00101
Me . lblCopyR . TextAlign = System . Drawing . ContentAlignment . MiddleRight00102
'00103
'lblTitle00104
'00105
Me . lblTitle . BackColor = System . Drawing . Color . Black00106
Me . lblTitle . Font = New System . Drawing . Font ( "Impact" , 36.0 !, System .» Drawing . FontStyle . Bold , System . Drawing . GraphicsUnit . Point , CType ( 0 ,
» Byte ))
00107
Me . lblTitle . ForeColor = System . Drawing . Color . White00108
Me . lblTitle . Location = New System . Drawing . Point ( 8 , 8 )00109
Me . lblTitle . Name = "lblTitle"00110
Me . lblTitle . Size = New System . Drawing . Size ( 216 , 56 )00111
Me . lblTitle . TabIndex = 500112
Me . lblTitle . Text = "Grafos"00113
'00114
'lblVersion00115
'00116
Me . lblVersion . BackColor = System . Drawing . Color . Black00117
Me . lblVersion . Font = New System . Drawing . Font ( "Verdana" , 8.25 !, System .» Drawing . FontStyle . Bold , System . Drawing . GraphicsUnit . Point , CType ( 0 ,
» Byte ))
00118
Me . lblVersion . ForeColor = System . Drawing . Color . FromArgb ( CType ( 255 , Byte )» , CType ( 128 , Byte ), CType ( 0 , Byte ))
00119
Me . lblVersion . Location = New System . Drawing . Point ( 288 , 48 )00120
Me . lblVersion . Name = "lblVersion"00121
Me . lblVersion . Size = New System . Drawing . Size ( 152 , 16 )00122
Me . lblVersion . TabIndex = 600123
Me . lblVersion . Text = "versión: "00124
Me . lblVersion . TextAlign = System . Drawing . ContentAlignment . MiddleRight00125
'00126
'Label400127
'00128
Me . Label4 . Font = New System . Drawing . Font ( "Verdana" , 8.25 !, System .» Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , CType ( 0
» , Byte ))
00129
Me . Label4 . ForeColor = System . Drawing . Color . FromArgb ( CType ( 0 , Byte ),» CType ( 0 , Byte ), CType ( 64 , Byte ))
00130
Me . Label4 . Location = New System . Drawing . Point ( 120 , 192 )00131
Me . Label4 . Name = "Label4"00132
Me . Label4 . Size = New System . Drawing . Size ( 320 , 24 )00133
Me . Label4 . TabIndex = 700134
Me . Label4 . Text = "arodriguez@omp.upv.es"00135
Me . Label4 . TextAlign = System . Drawing . ContentAlignment . MiddleRight00136
'00137
'lblDescripcion00138
'00139
Me . lblDescripcion . Font = New System . Drawing . Font ( "Verdana" , 8.25 !,» System . Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point ,
» CType ( 0 , Byte ))
00140
Me . lblDescripcion . ForeColor = System . Drawing . Color . Lavender00141
Me . lblDescripcion . Location = New System . Drawing . Point ( 5 , 80 )00142
Me . lblDescripcion . Name = "lblDescripcion"00143
Me . lblDescripcion . Size = New System . Drawing . Size ( 440 , 64 )00144
Me . lblDescripcion . TabIndex = 800145
Me . lblDescripcion . Text = "Programa para la construcción, edición y» análisis de grafos en modo tabular o grá" & _
00146
"fico. Permite exportar el grafo a diferentes formatos de ficheros» gráficos. Cont" & _
00147
"empla valores de mínimo, máximo y coste en los arcos; y coste en los» nodos. Arco" & _
00148
"s bidireccionales, etc."00149
Me . lblDescripcion . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00150
'00151
'linkGrafos00152
'00153
Me . linkGrafos . ActiveLinkColor = System . Drawing . Color . FromArgb ( CType ( 255 ,» Byte ), CType ( 128 , Byte ), CType ( 0 , Byte ))
00154
Me . linkGrafos . Anchor = CType (( System . Windows . Forms . AnchorStyles . Top Or» System . Windows . Forms . AnchorStyles . Right ), System . Windows . Forms .
» AnchorStyles )
00155
Me . linkGrafos . AutoSize = True00156
Me . linkGrafos . BackColor = System . Drawing . Color . Black00157
Me . linkGrafos . Font = New System . Drawing . Font ( "Verdana" , 8.25 !, System .» Drawing . FontStyle . Regular , System . Drawing . GraphicsUnit . Point , CType ( 0
» , Byte ))
00158
Me . linkGrafos . ForeColor = System . Drawing . Color . White00159
Me . linkGrafos . LinkColor = System . Drawing . Color . White00160
Me . linkGrafos . Location = New System . Drawing . Point ( 272 , 8 )00161
Me . linkGrafos . Name = "linkGrafos"00162
Me . linkGrafos . RightToLeft = System . Windows . Forms . RightToLeft . No00163
Me . linkGrafos . Size = New System . Drawing . Size ( 170 , 17 )00164
Me . linkGrafos . TabIndex = 900165
Me . linkGrafos . TabStop = True00166
Me . linkGrafos . Text = "más información en la web..."00167
Me . linkGrafos . VisitedLinkColor = System . Drawing . Color . White00168
'00169
'PictureBox200170
'00171
Me . PictureBox2 . Cursor = System . Windows . Forms . Cursors . Hand00172
Me . PictureBox2 . Image = CType ( resources . GetObject ( "PictureBox2.Image" ),» System . Drawing . Image )
00173
Me . PictureBox2 . Location = New System . Drawing . Point ( 8 , 176 )00174
Me . PictureBox2 . Name = "PictureBox2"00175
Me . PictureBox2 . Size = New System . Drawing . Size ( 90 , 33 )00176
Me . PictureBox2 . SizeMode = System . Windows . Forms . PictureBoxSizeMode .» AutoSize
00177
Me . PictureBox2 . TabIndex = 1000178
Me . PictureBox2 . TabStop = False00179
'00180
'Splash00181
'00182
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00183
Me . BackColor = System . Drawing . Color . LightSlateGray00184
Me . ClientSize = New System . Drawing . Size ( 450 , 359 )00185
Me . Controls . Add ( Me . PictureBox2 )00186
Me . Controls . Add ( Me . linkGrafos )00187
Me . Controls . Add ( Me . Label4 )00188
Me . Controls . Add ( Me . lblDescripcion )00189
Me . Controls . Add ( Me . lblVersion )00190
Me . Controls . Add ( Me . lblTitle )00191
Me . Controls . Add ( Me . lblCopyR2 )00192
Me . Controls . Add ( Me . GroupBox1 )00193
Me . Controls . Add ( Me . PictureBox1 )00194
Me . Controls . Add ( Me . lblCopyR )00195
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle .» FixedToolWindow
00196
Me . MaximizeBox = False00197
Me . MinimizeBox = False00198
Me . Name = "Splash"00199
Me . ShowInTaskbar = False00200
Me . StartPosition = System . Windows . Forms . FormStartPosition . CenterScreen00201
Me . Text = "Acerca de Grafos"00202
Me . TopMost = True00203
Me . ResumeLayout ( False )00204
00205
End Sub00206
00207
# End Region00208
00209
00210
00211
00212
00213
Private Sub Splash_Load ( ByVal sender As System . Object , ByVal e As System .» EventArgs ) Handles MyBase . Load
00214
00215
Dim nombre As String00216
nombre = System . Diagnostics . FileVersionInfo . GetVersionInfo ( System .» Reflection . Assembly . GetExecutingAssembly . Location ) . ProductName
00217
00218
Me . Text = "Acerca de " & nombre00219
00220
'Me.lblVersion.Text = Me.ProductVersion00221
Dim version As String00222
version = System . Diagnostics . FileVersionInfo . GetVersionInfo ( System .» Reflection . Assembly . GetExecutingAssembly . Location ) . FileMajorPart
00223
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileMinorPart
00224
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileBuildPart
00225
00226
Me . lblTitle . Text = System . Diagnostics . FileVersionInfo . GetVersionInfo (» System . Reflection . Assembly . GetExecutingAssembly . Location ) . ProductName
00227
Me . lblVersion . Text = "versión: " & version00228
Me . lblDescripcion . Text = System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . Comments
00229
Me . lblCopyR . Text = System . Diagnostics . FileVersionInfo . GetVersionInfo (» System . Reflection . Assembly . GetExecutingAssembly . Location ) .
» LegalCopyright
00230
Me . lblCopyR2 . Text = System . Diagnostics . FileVersionInfo . GetVersionInfo (» System . Reflection . Assembly . GetExecutingAssembly . Location ) .
» LegalTrademarks
00231
00232
End Sub00233
00234
00235
Private Sub linkGrafos_LinkClicked ( ByVal sender As System . Object , ByVal e As» System . Windows . Forms . LinkLabelLinkClickedEventArgs ) Handles linkGrafos .
» LinkClicked
00236
' inicia Navegador y navega hacia la página de Grafos00237
Process . Start ( "http://ttt.upv.es/~arodrigu/grafos/" )00238
End Sub00239
00240
Private Sub PictureBox2_Click ( ByVal sender As System . Object , ByVal e As» System . EventArgs ) Handles PictureBox2 . Click
00241
' inicia Navegador y navega hacia la página de licencia de Grafos00242
Process . Start ( "http://ttt.upv.es/~arodrigu/grafos/http://creativecommons.org/licenses/by-nc-sa/3.0/deed.es" )00243
00244
End Sub00245
End Class00001
Public Class Splash000002
Inherits System . Windows . Forms . Form00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'Form reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
Friend WithEvents PictureBox1 As System . Windows . Forms . PictureBox00033
Friend WithEvents Timer1 As System . Windows . Forms . Timer00034
Friend WithEvents lblCopyR As System . Windows . Forms . Label00035
Friend WithEvents lblVersion As System . Windows . Forms . Label00036
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00037
Me . components = New System . ComponentModel . Container00038
Dim resources As System . Resources . ResourceManager = New System . Resources» . ResourceManager ( GetType ( Splash0 ))
00039
Me . PictureBox1 = New System . Windows . Forms . PictureBox00040
Me . Timer1 = New System . Windows . Forms . Timer ( Me . components )00041
Me . lblCopyR = New System . Windows . Forms . Label00042
Me . lblVersion = New System . Windows . Forms . Label00043
Me . SuspendLayout ()00044
'00045
'PictureBox100046
'00047
Me . PictureBox1 . Image = CType ( resources . GetObject ( "PictureBox1.Image" ),» System . Drawing . Image )
00048
Me . PictureBox1 . Location = New System . Drawing . Point ( 0 , 0 )00049
Me . PictureBox1 . Name = "PictureBox1"00050
Me . PictureBox1 . Size = New System . Drawing . Size ( 433 , 361 )00051
Me . PictureBox1 . SizeMode = System . Windows . Forms . PictureBoxSizeMode .» AutoSize
00052
Me . PictureBox1 . TabIndex = 000053
Me . PictureBox1 . TabStop = False00054
'00055
'Timer100056
'00057
Me . Timer1 . Interval = 400000058
'00059
'lblCopyR00060
'00061
Me . lblCopyR . BackColor = System . Drawing . Color . Black00062
Me . lblCopyR . BorderStyle = System . Windows . Forms . BorderStyle . FixedSingle00063
Me . lblCopyR . Dock = System . Windows . Forms . DockStyle . Bottom00064
Me . lblCopyR . ForeColor = System . Drawing . Color . White00065
Me . lblCopyR . Location = New System . Drawing . Point ( 0 , 344 )00066
Me . lblCopyR . Name = "lblCopyR"00067
Me . lblCopyR . Size = New System . Drawing . Size ( 432 , 24 )00068
Me . lblCopyR . TabIndex = 100069
Me . lblCopyR . Text = "(cc) 2003..2005 - Alejandro Rodríguez Villalobos"00070
Me . lblCopyR . TextAlign = System . Drawing . ContentAlignment . MiddleRight00071
'00072
'lblVersion00073
'00074
Me . lblVersion . BackColor = System . Drawing . Color . Black00075
Me . lblVersion . Font = New System . Drawing . Font ( "Verdana" , 8.25 !, System .» Drawing . FontStyle . Bold , System . Drawing . GraphicsUnit . Point , CType ( 0 ,
» Byte ))
00076
Me . lblVersion . ForeColor = System . Drawing . Color . FromArgb ( CType ( 255 , Byte )» , CType ( 128 , Byte ), CType ( 0 , Byte ))
00077
Me . lblVersion . Location = New System . Drawing . Point ( 5 , 348 )00078
Me . lblVersion . Name = "lblVersion"00079
Me . lblVersion . Size = New System . Drawing . Size ( 152 , 16 )00080
Me . lblVersion . TabIndex = 700081
Me . lblVersion . Text = "versión: "00082
Me . lblVersion . TextAlign = System . Drawing . ContentAlignment . MiddleLeft00083
'00084
'Splash000085
'00086
Me . AutoScaleBaseSize = New System . Drawing . Size ( 5 , 13 )00087
Me . ClientSize = New System . Drawing . Size ( 432 , 368 )00088
Me . Controls . Add ( Me . lblVersion )00089
Me . Controls . Add ( Me . lblCopyR )00090
Me . Controls . Add ( Me . PictureBox1 )00091
Me . FormBorderStyle = System . Windows . Forms . FormBorderStyle . None00092
Me . Name = "Splash0"00093
Me . ShowInTaskbar = False00094
Me . StartPosition = System . Windows . Forms . FormStartPosition . CenterScreen00095
Me . Text = "Splash0"00096
Me . TopMost = True00097
Me . ResumeLayout ( False )00098
00099
End Sub00100
00101
# End Region00102
00103
Private Sub Timer1_Tick ( ByVal sender As System . Object , ByVal e As System .» EventArgs ) Handles Timer1 . Tick
00104
Me . Visible = False00105
End Sub00106
00107
00108
00109
Private Sub Splash0_Load ( ByVal sender As System . Object , ByVal e As System .» EventArgs ) Handles MyBase . Load
00110
00111
Dim CopyR As String00112
CopyR = System . Diagnostics . FileVersionInfo . GetVersionInfo ( System .» Reflection . Assembly . GetExecutingAssembly . Location ) . LegalCopyright
00113
Me . lblCopyR . Text = CopyR00114
00115
Dim version As String00116
version = System . Diagnostics . FileVersionInfo . GetVersionInfo ( System .» Reflection . Assembly . GetExecutingAssembly . Location ) . FileMajorPart
00117
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileMinorPart
00118
version = version & "." & System . Diagnostics . FileVersionInfo .» GetVersionInfo ( System . Reflection . Assembly . GetExecutingAssembly .
» Location ) . FileBuildPart
00119
00120
Me . lblVersion . Text = "versión: " & version00121
00122
00123
00124
Timer1 . Enabled = True00125
End Sub00126
End Class00001
Public Class Dijkstra00002
Inherits System . Windows . Forms . UserControl00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'UserControl1 reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00033
'00034
'Dijkstra00035
'00036
Me . Name = "Dijkstra"00037
Me . Size = New System . Drawing . Size ( 248 , 152 )00038
00039
End Sub00040
00041
# End Region00042
00043
00044
Private Const cSinEstatus As Integer = 000045
Private Const cCandidato As Integer = 100046
Private Const cProcesado As Integer = 200047
Private Const cMaximo As Single = 99999999999999999900048
Private Const cMinimo As Single = - 99999999999999999900049
00050
'Declaraciones de Eventos00051
Public Event Fin ( ByVal TextoRespuesta As String , ByVal MatrizArcosMinimos As» Array ) 'ver parámetros de solución
00052
Public Event Fallo ( ByVal TextoError As String )00053
'Declaraciones de Variables00054
Public DatosIncorrectos As Boolean = False00055
00056
'Declara la estructura del objeto Arco o relación entre nodos00057
Public Structure Arco00058
'Dim Texto As String 'etiqueta00059
'Dim Min As Single 'valor de mínimo00060
'Dim Max As Single 'valor de máximo00061
Dim Coste As Single 'valor de coste00062
00063
Dim EnRuta As Boolean00064
'Dim Col As Color 'color del arco00065
'Dim Grosor As Single 'trazo del arco00066
Dim Nd1 As Integer 'nodo origen00067
Dim Nd2 As Integer 'nodo destino00068
Dim Camino As Boolean00069
'Dim B As Boolean 'doble flecha si o no00070
End Structure00071
00072
'Declara la estructura del objeto Nodo00073
Public Structure Nodo00074
Dim Texto As String 'etiqueta00075
00076
Dim EnArco As Long00077
Dim Estatus As Integer00078
Dim Distancia As Single00079
00080
'Dim Valor As Single 'valor del nodo00081
'Dim X As Single 'coordenadas00082
'Dim Y As Single00083
'Dim Z As Single00084
'Dim Col As Color 'color de relleno del nodo00085
'Dim Radio As Single 'radio del nodo00086
'Dim Grosor As Single 'trazo del nodo00087
End Structure00088
00089
'Totales de Nodos y Arcos00090
Public TotalNodos As Long00091
Public TotalArcos As Long00092
00093
'Crea las colecciones para ambos objetos00094
Public Nodos ( 1 ) As Nodo00095
Public Arcos ( 1 ) As Arco00096
00097
00098
Public Function Inicio ( ByVal NodoInicio As Integer , Optional ByVal NodoFin» As Integer = - 1 , Optional ByVal CCritico As Boolean = False )
00099
00100
'el parámetro es el nodo de inicio00101
'para el cálculo de la ruta mínima00102
'-------------------------------00103
'Avisar en caso de error00104
If NodoInicio < 0 Or NodoInicio > TotalNodos - 1 Then00105
RaiseEvent Fallo ( "El nodo inicial no pertenece al grafo." & vbCrLf &» "Consulte con el programador." )
00106
'salir en caso de error00107
Exit Function00108
End If00109
00110
'Avisar en caso de error00111
If NodoFin <> - 1 Then00112
If NodoFin < 0 Or NodoFin > TotalNodos - 1 Then00113
RaiseEvent Fallo ( "El nodo final no pertenece al grafo." &» vbCrLf & "Consulte con el programador." )
00114
'salir en caso de error00115
Exit Function00116
End If00117
End If00118
00119
00120
00121
'-------------------------------00122
'Chequear la integridad de las propiedades00123
If DatosIncorrectos = True Then Exit Function00124
'-------------------------------00125
00126
'Inicio cálculo de tiempo00127
Dim TInicio As Date = Now00128
00129
If CCritico = False Then00130
'-------------------------------00131
'Llamar al proceso de cálculo00132
'arbol mínimo00133
CaminoMinimo ( NodoInicio )00134
'-------------------------------00135
Else00136
'-------------------------------00137
'Llamar al proceso de cálculo00138
'arbol máximo00139
CaminoMaximo ( NodoInicio )00140
'-------------------------------00141
End If00142
00143
'fin cálculo de tiempo00144
Dim tiempoproceso As Long00145
tiempoproceso = DateDiff ( DateInterval . Second , TInicio , Now )00146
00147
00148
'Busca camino hacia atrás desde el nodo fin00149
If NodoFin <> - 1 Then00150
Dim Ndo As Integer00151
Ndo = NodoFin00152
00153
Do00154
If Nodos ( Ndo ) . EnArco = - 1 Then00155
'Exit Do 'camino incompleto00156
RaiseEvent Fallo ( "No existe un camino entre ese par de» nodos." )
00157
'salir en caso de error00158
Exit Function00159
End If00160
Arcos ( Nodos ( Ndo ) . EnArco ) . Camino = True00161
Ndo = Arcos ( Nodos ( Ndo ) . EnArco ) . Nd100162
Loop Until Ndo = NodoInicio00163
00164
End If00165
00166
00167
00168
'prepara los resultados para ser devueltos00169
'------------------------------------------------00170
Dim TextoResultado As String00171
Dim CosteTotal As Single = 000172
Dim i , j As Long00173
Dim MatrizSolucion ( TotalNodos - 1 , TotalNodos - 1 ) As Integer00174
00175
00176
If CCritico = False Then00177
If NodoFin <> - 1 Then00178
TextoResultado = "CAMINO MÍNIMO - ALGORITMO DE DIJKSTRA" &» vbCrLf
00179
Else00180
TextoResultado = "ÁRBOL MÍNIMO - ALGORITMO DE DIJKSTRA" &» vbCrLf
00181
End If00182
Else00183
If NodoFin <> - 1 Then00184
TextoResultado = "CAMINO CRÍTICO - ALGORITMO DE DIJKSTRA" &» vbCrLf
00185
Else00186
TextoResultado = "ÁRBOL MÁXIMO - ALGORITMO DE DIJKSTRA" &» vbCrLf
00187
End If00188
End If00189
00190
TextoResultado = TextoResultado &» "---------------------------------------" & vbCrLf
00191
TextoResultado = TextoResultado & "" & vbCrLf00192
00193
TextoResultado = TextoResultado & "Tiempo de proceso = " & tiempoproceso» & " segundos" & vbCrLf & vbCrLf
00194
TextoResultado = TextoResultado & "Arcos calculados desde el nodo» inicial (" & Nodos ( NodoInicio ) . Texto & ")"
00195
00196
If NodoFin <> - 1 Then00197
TextoResultado = TextoResultado & " hasta el nodo fin (" & Nodos (» NodoFin ) . Texto & ")"
00198
End If00199
TextoResultado = TextoResultado & ":" & vbCrLf & vbCrLf00200
00201
For i = 0 To TotalArcos - 100202
If Arcos ( i ) . EnRuta = True Then00203
If NodoFin <> - 1 Then00204
If Arcos ( i ) . Camino = True Then00205
'Marca sólo el camino00206
TextoResultado = TextoResultado & " * " & Nodos ( Arcos» ( i ) . Nd1 ) . Texto & " ----(" & Arcos ( i ) . Coste & ")---> "
» & Nodos ( Arcos ( i ) . Nd2 ) . Texto & vbCrLf
00207
MatrizSolucion ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = 100208
CosteTotal = CosteTotal + Arcos ( i ) . Coste00209
Else00210
End If00211
Else00212
'Marca todo el arbol00213
TextoResultado = TextoResultado & " " & Nodos ( Arcos ( i ) .» Nd1 ) . Texto & " ----(" & Arcos ( i ) . Coste & ")---> " & Nodos
» ( Arcos ( i ) . Nd2 ) . Texto & vbCrLf
00214
MatrizSolucion ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = 100215
End If00216
End If00217
Next i00218
00219
If NodoFin <> - 1 Then00220
TextoResultado = TextoResultado & vbCrLf & "Coste total = " &» CosteTotal & vbCrLf
00221
End If00222
00223
00224
If CCritico = False Then00225
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos con» coste mínimo:" & vbCrLf & vbCrLf
00226
Else00227
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos con» coste máximo:" & vbCrLf & vbCrLf
00228
End If00229
00230
TextoResultado = TextoResultado & "N1\N2" & vbTab00231
For i = 0 To TotalNodos - 100232
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00233
Next i00234
TextoResultado = TextoResultado & vbCrLf00235
00236
For i = 0 To UBound ( MatrizSolucion , 1 )00237
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00238
For j = 0 To UBound ( MatrizSolucion , 2 )00239
TextoResultado = TextoResultado & MatrizSolucion ( i , j ) & vbTab00240
Next j00241
TextoResultado = TextoResultado & vbCrLf00242
Next i00243
00244
00245
00246
'-------------------------------00247
'fin del proceso devuelve resultados00248
RaiseEvent Fin ( TextoResultado , MatrizSolucion )00249
'-------------------------------00250
End Function00251
00252
00253
Public Property MatrizNodos () As Array00254
'Lectura de propiedades00255
Get00256
'para devolver un valor desde la dll a la aplicación00257
00258
End Get00259
Set ( ByVal Value As Array )00260
'para poner un valor desde la aplicación a la dll00261
00262
Dim i As Long00263
'comprobar la integridad de los datos antes de proseguir00264
i = UBound ( Value )00265
If i > 0 Then00266
'dimensiona el total de nodos00267
TotalNodos = i + 100268
'toma los datos de nodos y los pone en la estructura00269
For i = 0 To UBound ( Value )00270
ReDim Preserve Nodos ( i )00271
Nodos ( i ) . Texto = Value ( i )00272
Next i00273
Else00274
'no hay suficientes nodos00275
RaiseEvent Fallo ( "Deben existir al menos dos Nodos y un Arco» para definir un grafo." )
00276
DatosIncorrectos = True00277
End If00278
00279
End Set00280
End Property00281
Public Property MatrizArcos () As Array00282
'Lectura de propiedades00283
Get00284
'para devolver un valor desde la dll a la aplicación00285
00286
End Get00287
Set ( ByVal Value As Array )00288
'para poner un valor desde la aplicación a la dll00289
Dim i As Long00290
Dim j As Long00291
00292
'comprobar la integridad de los datos antes de proseguir00293
i = UBound ( Value , 1 ) 'primera dimensión de la matriz00294
j = UBound ( Value , 2 ) 'segunda dimensión de la matriz00295
00296
If i = j And i = TotalNodos - 1 Then00297
'Recorre la matriz para tomar los datos y ponerlos en00298
'la estructura de arcos00299
TotalArcos = 000300
For i = 0 To TotalNodos - 100301
For j = 0 To TotalNodos - 100302
'el algoritmo de Dijkstra no debe tener pesos00303
'de arco menores que cero00304
If i <> j And Value ( i , j ) >= 0 Then00305
TotalArcos = TotalArcos + 100306
ReDim Preserve Arcos ( TotalArcos - 1 )00307
00308
Arcos ( TotalArcos - 1 ) . Nd1 = i00309
Arcos ( TotalArcos - 1 ) . Nd2 = j00310
Arcos ( TotalArcos - 1 ) . Coste = Value ( i , j )00311
End If00312
If i = j And Value ( i , j ) >= 0 Then00313
'arco sobre un mismo nodo no permitido00314
RaiseEvent Fallo ( "Se ha encontrado un arco sobre» sí mismo en el nodo (" & Nodos ( i ) . Texto & ")." &
» vbCrLf & "Esto no está permitido en el Algoritmo
» de Dijkstra." )
00315
DatosIncorrectos = True00316
End If00317
00318
Next j00319
Next i00320
00321
Else00322
'no hay suficientes arcos00323
RaiseEvent Fallo ( "Las dimensiones de la matriz de Arcos no» concuerdan con el total de nodos." )
00324
DatosIncorrectos = True00325
End If00326
If TotalArcos = 0 Then00327
'no hay suficientes arcos00328
RaiseEvent Fallo ( "Debe existir al menos un Arco entre dos Nodos» para definir un grafo." )
00329
DatosIncorrectos = True00330
End If00331
00332
End Set00333
End Property00334
00335
00336
Sub CaminoMinimo ( ByVal NdInicial As Integer )00337
Dim Candidatos As New Collection ()00338
Dim Indice As Integer00339
Dim MejorNd As Integer00340
Dim MejorDist As Single00341
Dim NuevaDist As Single00342
Dim Nd As Integer00343
Dim ANodo As Integer00344
Dim Arc As Integer00345
00346
'Resetea el camino mínimo00347
ResetCamino ()00348
00349
'Comienza el algoritmo poniendo el nodo de inicio en los candidatos00350
Candidatos . Add ( NdInicial )00351
00352
'El proceso termina cuando la lista de candidatos está vacia00353
Do While Candidatos . Count > 000354
'Busca el nodo de la colección con menor distancia total00355
'Ese será marcado como mejor nodo00356
MejorDist = cMaximo00357
For Indice = 1 To Candidatos . Count00358
NuevaDist = Nodos ( Candidatos ( Indice )) . Distancia00359
If NuevaDist < MejorDist Then00360
MejorDist = NuevaDist00361
MejorNd = Indice00362
End If00363
Next00364
'toma ese nodo como referencia00365
Nd = Candidatos ( MejorNd )00366
'antes de quitarlo de la colección00367
Candidatos . Remove ( MejorNd )00368
'y de marcarlo como procesado00369
Nodos ( Nd ) . Estatus = cProcesado00370
00371
'Rastrea todos los arcos00372
For Arc = 0 To UBound ( Arcos )00373
'en busca de arcos de origen el nodo actual00374
If Arcos ( Arc ) . Nd1 = Nd Then00375
'y que no sea un arco sobre el mismo nodo00376
If Arcos ( Arc ) . Nd2 <> Nd Then00377
'toma el nodo de destino00378
ANodo = Arcos ( Arc ) . Nd200379
00380
If Nodos ( ANodo ) . Estatus = cSinEstatus Then00381
Candidatos . Add ( ANodo )00382
00383
Nodos ( ANodo ) . Estatus = cCandidato00384
Nodos ( ANodo ) . Distancia = MejorDist + Arcos ( Arc ) .» Coste
00385
Nodos ( ANodo ) . EnArco = Arc00386
ElseIf Nodos ( ANodo ) . Estatus = cCandidato Then00387
NuevaDist = MejorDist + Arcos ( Arc ) . Coste00388
00389
If NuevaDist < Nodos ( ANodo ) . Distancia Then00390
Nodos ( ANodo ) . Distancia = NuevaDist00391
Nodos ( ANodo ) . EnArco = Arc00392
End If00393
End If00394
00395
End If00396
End If00397
Next Arc00398
Loop00399
00400
'subraya los arcos de la solución00401
Dim i As Long00402
For i = 0 To UBound ( Nodos )00403
If Not ( Nodos ( i ) . EnArco = - 1 ) Then Arcos ( Nodos ( i ) . EnArco ) . EnRuta =» True
00404
Next i00405
00406
End Sub00407
Sub CaminoMaximo ( ByVal NdInicial As Integer )00408
Dim Candidatos As New Collection ()00409
Dim Indice As Integer00410
Dim MejorNd As Integer00411
Dim MejorDist As Single00412
Dim NuevaDist As Single00413
Dim Nd As Integer00414
Dim ANodo As Integer00415
Dim Arc As Integer00416
00417
'Resetea el camino mínimo00418
ResetCamino ()00419
00420
'Comienza el algoritmo poniendo el nodo de inicio en los candidatos00421
Candidatos . Add ( NdInicial )00422
00423
'El proceso termina cuando la lista de candidatos está vacia00424
Do While Candidatos . Count > 000425
'Busca el nodo de la colección con mayor distancia total00426
'Ese será marcado como mejor nodo00427
MejorDist = cMinimo00428
For Indice = 1 To Candidatos . Count00429
NuevaDist = Nodos ( Candidatos ( Indice )) . Distancia00430
If NuevaDist >= MejorDist Then00431
MejorDist = NuevaDist00432
MejorNd = Indice00433
End If00434
Next00435
'toma ese nodo como referencia00436
Nd = Candidatos ( MejorNd )00437
'antes de quitarlo de la colección00438
Candidatos . Remove ( MejorNd )00439
'y de marcarlo como procesado00440
Nodos ( Nd ) . Estatus = cProcesado00441
00442
'Rastrea todos los arcos00443
For Arc = 0 To UBound ( Arcos )00444
'en busca de arcos de origen el nodo actual00445
If Arcos ( Arc ) . Nd1 = Nd Then00446
'y que no sea un arco sobre el mismo nodo00447
If Arcos ( Arc ) . Nd2 <> Nd Then00448
'toma el nodo de destino00449
ANodo = Arcos ( Arc ) . Nd200450
00451
If Nodos ( ANodo ) . Estatus = cSinEstatus Then00452
Candidatos . Add ( ANodo )00453
00454
Nodos ( ANodo ) . Estatus = cCandidato00455
Nodos ( ANodo ) . Distancia = MejorDist + Arcos ( Arc ) .» Coste
00456
Nodos ( ANodo ) . EnArco = Arc00457
ElseIf Nodos ( ANodo ) . Estatus = cCandidato Then00458
NuevaDist = MejorDist + Arcos ( Arc ) . Coste00459
00460
If NuevaDist >= Nodos ( ANodo ) . Distancia Then00461
Nodos ( ANodo ) . Distancia = NuevaDist00462
Nodos ( ANodo ) . EnArco = Arc00463
End If00464
End If00465
00466
End If00467
End If00468
Next Arc00469
Loop00470
00471
'subraya los arcos de la solución00472
Dim i As Long00473
For i = 0 To UBound ( Nodos )00474
If Not ( Nodos ( i ) . EnArco = - 1 ) Then Arcos ( Nodos ( i ) . EnArco ) . EnRuta =» True
00475
Next i00476
00477
End Sub00478
00479
Sub ResetCamino ()00480
'Inicializa los arrays para el cálculo del algoritmo00481
00482
Dim i As Long00483
For i = 0 To UBound ( Nodos )00484
Nodos ( i ) . EnArco = - 100485
Nodos ( i ) . Estatus = cSinEstatus00486
Nodos ( i ) . Distancia = 000487
Next i00488
00489
For i = 0 To UBound ( Arcos )00490
Arcos ( i ) . EnRuta = False00491
Arcos ( i ) . Camino = False00492
Next i00493
00494
End Sub00495
00496
00497
Protected Overrides Sub Finalize ()00498
MyBase . Finalize ()00499
End Sub00500
End Class00001
Public Class BellmanFord00002
Inherits System . Windows . Forms . UserControl00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'UserControl1 reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00033
'00034
'BellmanFord00035
'00036
Me . Name = "BellmanFord"00037
00038
End Sub00039
00040
# End Region00041
00042
Private Const cSinEstatus As Integer = 000043
'Private Const cCandidato As Integer = 100044
Private Const cProcesado As Integer = 200045
Private Const cMaximo As Single = 99999999999999999900046
Private Const cMinimo As Single = - 99999999999999999900047
00048
'Declaraciones de Eventos00049
Public Event Fin ( ByVal TextoRespuesta As String , ByVal MatrizArcosMinimos As» Array ) 'ver parámetros de solución
00050
Public Event Fallo ( ByVal TextoError As String )00051
'Declaraciones de Variables00052
Public DatosIncorrectos As Boolean = False00053
00054
'Declara la estructura del objeto Arco o relación entre nodos00055
Public Structure Arco00056
'Dim Texto As String 'etiqueta00057
'Dim Min As Single 'valor de mínimo00058
'Dim Max As Single 'valor de máximo00059
Dim Coste As Single 'valor de coste00060
00061
Dim Camino As Boolean00062
'Dim Col As Color 'color del arco00063
'Dim Grosor As Single 'trazo del arco00064
Dim Nd1 As Integer 'nodo origen00065
Dim Nd2 As Integer 'nodo destino00066
00067
'Dim Camino As Boolean00068
'Dim B As Boolean 'doble flecha si o no00069
End Structure00070
00071
'Declara la estructura del objeto Nodo00072
Public Structure Nodo00073
Dim Texto As String 'etiqueta00074
00075
Dim Precedente As Long00076
Dim Estatus As Integer00077
Dim Distancia As Single00078
00079
'Dim Valor As Single 'valor del nodo00080
'Dim X As Single 'coordenadas00081
'Dim Y As Single00082
'Dim Z As Single00083
'Dim Col As Color 'color de relleno del nodo00084
'Dim Radio As Single 'radio del nodo00085
'Dim Grosor As Single 'trazo del nodo00086
End Structure00087
00088
'Totales de Nodos y Arcos00089
Public TotalNodos As Long00090
Public TotalArcos As Long00091
00092
'Crea las colecciones para ambos objetos00093
Public Nodos ( 1 ) As Nodo00094
Public Arcos ( 1 ) As Arco00095
00096
Public Property MatrizNodos () As Array00097
'Lectura de propiedades00098
Get00099
'para devolver un valor desde la dll a la aplicación00100
00101
End Get00102
Set ( ByVal Value As Array )00103
'para poner un valor desde la aplicación a la dll00104
DatosIncorrectos = False00105
Dim i As Long00106
'comprobar la integridad de los datos antes de proseguir00107
i = UBound ( Value )00108
If i > 0 Then00109
'dimensiona el total de nodos00110
TotalNodos = i + 100111
'toma los datos de nodos y los pone en la estructura00112
For i = 0 To UBound ( Value )00113
ReDim Preserve Nodos ( i )00114
Nodos ( i ) . Texto = Value ( i )00115
Next i00116
Else00117
'no hay suficientes nodos00118
RaiseEvent Fallo ( "Deben existir al menos dos Nodos y un Arco» para definir un grafo." )
00119
DatosIncorrectos = True00120
End If00121
00122
End Set00123
End Property00124
Public Property MatrizArcos () As Array00125
'Lectura de propiedades00126
Get00127
'para devolver un valor desde la dll a la aplicación00128
00129
End Get00130
Set ( ByVal Value As Array )00131
'para poner un valor desde la aplicación a la dll00132
Dim i As Long00133
Dim j As Long00134
DatosIncorrectos = False00135
'comprobar la integridad de los datos antes de proseguir00136
i = UBound ( Value , 1 ) 'primera dimensión de la matriz00137
j = UBound ( Value , 2 ) 'segunda dimensión de la matriz00138
00139
If i = j And i = TotalNodos - 1 Then00140
'Recorre la matriz para tomar los datos y ponerlos en00141
'la estructura de arcos00142
TotalArcos = 000143
For i = 0 To TotalNodos - 100144
For j = 0 To TotalNodos - 100145
'el algoritmo de BellmanFord puede tener pesos00146
'de arco menores que cero00147
'para indicar que no existe arco se usará la00148
'cMaximo= 99999999999999999900149
'cMinimo = -99999999999999999900150
If i <> j And Value ( i , j ) < cMaximo And Value ( i , j ) >» cMinimo Then
00151
TotalArcos = TotalArcos + 100152
ReDim Preserve Arcos ( TotalArcos - 1 )00153
00154
Arcos ( TotalArcos - 1 ) . Nd1 = i00155
Arcos ( TotalArcos - 1 ) . Nd2 = j00156
Arcos ( TotalArcos - 1 ) . Coste = Value ( i , j )00157
End If00158
If i = j Then00159
'arco sobre un mismo nodo no permitido00160
'RaiseEvent Fallo("Se ha encontrado un arco sobre» sí mismo en el nodo (" & Nodos(i).Texto & ")." &
» vbCrLf & "Esto no está permitido en el Algoritmo
» de BellmanFord.")
00161
'DatosIncorrectos = True00162
End If00163
00164
Next j00165
Next i00166
00167
Else00168
'no hay suficientes arcos00169
RaiseEvent Fallo ( "Las dimensiones de la matriz de Arcos no» concuerdan con el total de nodos." )
00170
DatosIncorrectos = True00171
End If00172
If TotalArcos = 0 Then00173
'no hay suficientes arcos00174
RaiseEvent Fallo ( "Debe existir al menos un Arco entre dos Nodos» para definir un grafo." )
00175
DatosIncorrectos = True00176
End If00177
00178
End Set00179
End Property00180
00181
Public Function Inicio ( ByVal NodoInicio As Integer , Optional ByVal NodoFin» As Integer = - 1 , Optional ByVal Maximo As Boolean = False )
00182
00183
'el parámetro es el nodo de inicio00184
'para el cálculo de la ruta mínima00185
'-------------------------------00186
'Avisar en caso de error00187
If NodoInicio < 0 Or NodoInicio > TotalNodos - 1 Then00188
RaiseEvent Fallo ( "El nodo inicial no pertenece al grafo." & vbCrLf &» "Consulte con el programador." )
00189
'salir en caso de error00190
Exit Function00191
End If00192
00193
'Avisar en caso de error00194
If NodoFin <> - 1 Then00195
If NodoFin < 0 Or NodoFin > TotalNodos - 1 Then00196
RaiseEvent Fallo ( "El nodo final no pertenece al grafo." &» vbCrLf & "Consulte con el programador." )
00197
'salir en caso de error00198
Exit Function00199
End If00200
End If00201
00202
00203
00204
'Inicio cálculo de tiempo00205
Dim TInicio As Date = Now00206
00207
00208
'-------------------------------00209
'Llamar al proceso de cálculo00210
'arbol mínimo00211
CaminoMinimo ( NodoInicio , NodoFin , Maximo )00212
'-------------------------------00213
00214
00215
If DatosIncorrectos = True Then00216
00217
'TextoResultado = TextoResultado & "NO SE HA ENCONTRADO SOLUCIÓN >» "
00218
'TextoResultado = TextoResultado & "Nodos no conectados o» existencia de lazo" & vbCrLf
00219
00220
RaiseEvent Fallo ( "No se encuentra solución." & vbCrLf & "Los nodos» no están conectados o existe un lazo." )
00221
DatosIncorrectos = False00222
Exit Function00223
End If00224
00225
00226
'fin cálculo de tiempo00227
Dim tiempoproceso As Long00228
tiempoproceso = DateDiff ( DateInterval . Second , TInicio , Now )00229
00230
'prepara los resultados para ser devueltos00231
'------------------------------------------------00232
Dim TextoResultado As String00233
Dim CosteTotal As Single = 000234
Dim i , j As Long00235
Dim MatrizSolucion ( TotalNodos - 1 , TotalNodos - 1 ) As Integer00236
00237
00238
If Maximo = False Then00239
TextoResultado = "CAMINO MÍNIMO - ALGORITMO DE BELLMAN-FORD" &» vbCrLf
00240
Else00241
TextoResultado = "CAMINO MÁXIMO - ALGORITMO DE BELLMAN-FORD" &» vbCrLf
00242
End If00243
00244
TextoResultado = TextoResultado &» "-----------------------------------------" & vbCrLf
00245
TextoResultado = TextoResultado & "" & vbCrLf00246
00247
TextoResultado = TextoResultado & "Tiempo de proceso = " & tiempoproceso» & " segundos" & vbCrLf & vbCrLf
00248
00249
TextoResultado = TextoResultado & "Arcos calculados desde el nodo» inicial (" & Nodos ( NodoInicio ) . Texto & ")"
00250
TextoResultado = TextoResultado & " hasta el nodo fin (" & Nodos ( NodoFin» ) . Texto & ")"
00251
00252
TextoResultado = TextoResultado & ":" & vbCrLf & vbCrLf00253
00254
For i = 0 To TotalArcos - 100255
00256
If Arcos ( i ) . Camino = True Then00257
'Marca el camino00258
TextoResultado = TextoResultado & " * " & Nodos ( Arcos ( i ) . Nd1 )» . Texto & " ----(" & Arcos ( i ) . Coste & ")---> " & Nodos ( Arcos ( i
» ) . Nd2 ) . Texto & vbCrLf
00259
MatrizSolucion ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = 100260
CosteTotal = CosteTotal + Arcos ( i ) . Coste00261
00262
End If00263
00264
Next i00265
00266
TextoResultado = TextoResultado & vbCrLf & "Coste total = " & CosteTotal» & vbCrLf
00267
00268
00269
If Maximo = False Then00270
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos con» coste mínimo:" & vbCrLf & vbCrLf
00271
Else00272
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos con» coste máximo:" & vbCrLf & vbCrLf
00273
End If00274
00275
TextoResultado = TextoResultado & "N1\N2" & vbTab00276
For i = 0 To TotalNodos - 100277
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00278
Next i00279
TextoResultado = TextoResultado & vbCrLf00280
00281
For i = 0 To UBound ( MatrizSolucion , 1 )00282
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00283
For j = 0 To UBound ( MatrizSolucion , 2 )00284
TextoResultado = TextoResultado & MatrizSolucion ( i , j ) & vbTab00285
Next j00286
TextoResultado = TextoResultado & vbCrLf00287
Next i00288
00289
00290
00291
00292
00293
'-------------------------------00294
'fin del proceso devuelve resultados00295
RaiseEvent Fin ( TextoResultado , MatrizSolucion )00296
'-------------------------------00297
End Function00298
00299
00300
Sub CaminoMinimo ( ByVal NodoInicio As Integer , ByVal NodoFin As Integer ,» ByVal Maximo As Boolean )
00301
00302
'Inicializa el algoritmo00303
ResetCamino ( NodoInicio , Maximo )00304
00305
Dim i , j As Integer00306
Dim Arc As Integer00307
Dim Contador As Integer00308
Dim Ndo , k As Integer00309
00310
Contador = 100311
00312
Do00313
00314
For Arc = 0 To TotalArcos - 100315
i = Arcos ( Arc ) . Nd100316
j = Arcos ( Arc ) . Nd200317
00318
If Maximo = False Then00319
If Nodos ( i ) . Distancia + Arcos ( Arc ) . Coste < Nodos ( j ) .» Distancia Then
00320
Nodos ( j ) . Distancia = Nodos ( i ) . Distancia + Arcos ( Arc ) .» Coste
00321
Nodos ( j ) . Precedente = i00322
End If00323
Else00324
If Nodos ( i ) . Distancia + Arcos ( Arc ) . Coste > Nodos ( j ) .» Distancia Then
00325
Nodos ( j ) . Distancia = Nodos ( i ) . Distancia + Arcos ( Arc ) .» Coste
00326
Nodos ( j ) . Precedente = i00327
End If00328
End If00329
00330
Next Arc00331
00332
Contador = Contador + 100333
Loop Until Contador = TotalNodos00334
If PotencialFactible ( Maximo ) = False Then00335
DatosIncorrectos = True00336
Else00337
'-----------------00338
Ndo = NodoFin00339
Dim fin As Boolean = False00340
Do00341
Nodos ( Ndo ) . Estatus = cProcesado00342
'Busca arco con nodo precedente00343
For k = 0 To TotalArcos - 100344
If Arcos ( k ) . Nd1 = Nodos ( Ndo ) . Precedente And Arcos ( k ) . Nd2 =» Ndo Then
00345
Arcos ( k ) . Camino = True00346
Exit For00347
End If00348
Next k00349
00350
Ndo = Nodos ( Ndo ) . Precedente00351
00352
If Ndo = - 1 Then fin = True00353
If fin = False Then00354
If Nodos ( Ndo ) . Estatus = cProcesado Then00355
fin = True00356
End If00357
End If00358
00359
If fin Then00360
'no hay solución completa00361
DatosIncorrectos = True00362
'salir en caso de error00363
Exit Do00364
End If00365
Loop Until Ndo = NodoInicio00366
End If00367
00368
00369
00370
End Sub00371
00372
00373
Function PotencialFactible ( ByVal maximo As Boolean ) As Boolean00374
00375
Dim i , j , arc As Integer00376
Dim factible As Boolean00377
factible = True00378
00379
For arc = 0 To TotalArcos - 100380
i = Arcos ( arc ) . Nd100381
j = Arcos ( arc ) . Nd200382
00383
If maximo = False Then00384
00385
If Nodos ( i ) . Distancia + Arcos ( arc ) . Coste >= Nodos ( j ) . Distancia» Then
00386
factible = True00387
Else00388
factible = False00389
Exit For00390
End If00391
Else00392
If Nodos ( i ) . Distancia + Arcos ( arc ) . Coste <= Nodos ( j ) . Distancia» Then
00393
factible = True00394
Else00395
factible = False00396
Exit For00397
End If00398
End If00399
Next arc00400
00401
Return factible00402
00403
End Function00404
00405
Sub ResetCamino ( ByVal NodoInicio As Integer , ByVal Maximo As Boolean )00406
'Inicializa los arrays para el cálculo del algoritmo00407
00408
Dim i As Long00409
For i = 0 To UBound ( Nodos )00410
If i = NodoInicio Then00411
Nodos ( i ) . Precedente = 000412
Nodos ( i ) . Distancia = 000413
Else00414
Nodos ( i ) . Precedente = - 100415
If Maximo = False Then00416
Nodos ( i ) . Distancia = cMaximo00417
Else00418
Nodos ( i ) . Distancia = cMinimo00419
End If00420
End If00421
Nodos ( i ) . Estatus = cSinEstatus00422
Next i00423
00424
For i = 0 To UBound ( Arcos )00425
Arcos ( i ) . Camino = False00426
Next i00427
00428
End Sub00429
00430
Protected Overrides Sub Finalize ()00431
MyBase . Finalize ()00432
End Sub00433
End Class00001
Public Class Kruskal00002
Inherits System . Windows . Forms . UserControl00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'UserControl1 reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00033
'00034
'Kruskal00035
'00036
Me . Name = "Kruskal"00037
00038
End Sub00039
00040
# End Region00041
'Declaraciones de Eventos00042
Public Event Fin ( ByVal TextoRespuesta As String , ByVal MatrizArcosMinimos As» Array ) 'ver parámetros de solución
00043
Public Event Fallo ( ByVal TextoError As String )00044
'Declaraciones de Variables00045
Public DatosIncorrectos As Boolean = False00046
00047
Private Const cSinEstatus As Integer = 000048
'Private Const cCandidato As Integer = 100049
'Private Const cProcesado As Integer = 200050
Private Const cMaximo As Single = 99999999999999999900051
Private Const cMinimo As Single = - 99999999999999999900052
00053
00054
00055
'Declara la estructura del objeto Arco o relación entre nodos00056
Public Structure Arco00057
'Dim Texto As String 'etiqueta00058
'Dim Min As Single 'valor de mínimo00059
'Dim Max As Single 'valor de máximo00060
Dim Coste As Single 'valor de coste00061
00062
Dim Camino As Boolean00063
'Dim Col As Color 'color del arco00064
'Dim Grosor As Single 'trazo del arco00065
Dim Nd1 As Integer 'nodo origen00066
Dim Nd2 As Integer 'nodo destino00067
00068
'Dim Camino As Boolean00069
'Dim B As Boolean 'doble flecha si o no00070
End Structure00071
00072
'Declara la estructura del objeto Nodo00073
Public Structure Nodo00074
Dim Texto As String 'etiqueta00075
00076
'Dim Precedente As Long00077
Dim Estatus As Integer00078
'Dim Distancia As Single00079
00080
'Dim Valor As Single 'valor del nodo00081
'Dim X As Single 'coordenadas00082
'Dim Y As Single00083
'Dim Z As Single00084
'Dim Col As Color 'color de relleno del nodo00085
'Dim Radio As Single 'radio del nodo00086
'Dim Grosor As Single 'trazo del nodo00087
End Structure00088
00089
'Totales de Nodos y Arcos00090
Public TotalNodos As Long00091
Public TotalArcos As Long00092
00093
'Crea las colecciones para ambos objetos00094
Public Nodos ( 1 ) As Nodo00095
Public Arcos ( 1 ) As Arco00096
00097
Public Property MatrizNodos () As Array00098
'Lectura de propiedades00099
Get00100
'para devolver un valor desde la dll a la aplicación00101
00102
End Get00103
Set ( ByVal Value As Array )00104
'para poner un valor desde la aplicación a la dll00105
DatosIncorrectos = False00106
Dim i As Long00107
'comprobar la integridad de los datos antes de proseguir00108
i = UBound ( Value )00109
If i > 0 Then00110
'dimensiona el total de nodos00111
TotalNodos = i + 100112
'toma los datos de nodos y los pone en la estructura00113
For i = 0 To UBound ( Value )00114
ReDim Preserve Nodos ( i )00115
Nodos ( i ) . Texto = Value ( i )00116
Nodos ( i ) . Estatus = cSinEstatus00117
Next i00118
Else00119
'no hay suficientes nodos00120
RaiseEvent Fallo ( "Deben existir al menos dos Nodos y un Arco» para definir un grafo." )
00121
DatosIncorrectos = True00122
End If00123
00124
End Set00125
End Property00126
Public Property MatrizArcos () As Array00127
'Lectura de propiedades00128
Get00129
'para devolver un valor desde la dll a la aplicación00130
00131
End Get00132
Set ( ByVal Value As Array )00133
'para poner un valor desde la aplicación a la dll00134
Dim i As Long00135
Dim j As Long00136
DatosIncorrectos = False00137
'comprobar la integridad de los datos antes de proseguir00138
i = UBound ( Value , 1 ) 'primera dimensión de la matriz00139
j = UBound ( Value , 2 ) 'segunda dimensión de la matriz00140
00141
If i = j And i = TotalNodos - 1 Then00142
'Recorre la matriz para tomar los datos y ponerlos en00143
'la estructura de arcos00144
TotalArcos = 000145
For i = 0 To TotalNodos - 100146
For j = 0 To TotalNodos - 100147
'el algoritmo de Kruskal puede tener pesos00148
'de arco menores que cero00149
'para indicar que no existe arco se usará la00150
'cMaximo= 99999999999999999900151
'cMinimo = -99999999999999999900152
If i <> j And Value ( i , j ) < cMaximo And Value ( i , j ) >» cMinimo Then
00153
TotalArcos = TotalArcos + 100154
ReDim Preserve Arcos ( TotalArcos - 1 )00155
00156
Arcos ( TotalArcos - 1 ) . Nd1 = i00157
Arcos ( TotalArcos - 1 ) . Nd2 = j00158
Arcos ( TotalArcos - 1 ) . Coste = Value ( i , j )00159
End If00160
'If i = j Then00161
'arco sobre un mismo nodo no permitido00162
'RaiseEvent Fallo("Se ha encontrado un arco sobre sí» mismo en el nodo (" & Nodos(i).Texto & ")." & vbCrLf
» & "Esto no está permitido en el Algoritmo de
» Kruskal.")
00163
'DatosIncorrectos = True00164
'End If00165
00166
Next j00167
Next i00168
00169
Else00170
'no hay suficientes arcos00171
RaiseEvent Fallo ( "Las dimensiones de la matriz de Arcos no» concuerdan con el total de nodos." )
00172
DatosIncorrectos = True00173
End If00174
If TotalArcos = 0 Then00175
'no hay suficientes arcos00176
RaiseEvent Fallo ( "Debe existir al menos un Arco entre dos Nodos» para definir un grafo." )
00177
DatosIncorrectos = True00178
End If00179
00180
End Set00181
End Property00182
Public Function Inicio ( ByVal maximo As Boolean )00183
00184
00185
00186
'Inicio cálculo de tiempo00187
Dim TInicio As Date = Now00188
00189
00190
'-------------------------------00191
'Llamar al proceso de cálculo00192
'arbol mínimo00193
ArbolMinimo ( maximo )00194
'-------------------------------00195
00196
00197
00198
'fin cálculo de tiempo00199
Dim tiempoproceso As Long00200
tiempoproceso = DateDiff ( DateInterval . Second , TInicio , Now )00201
00202
00203
'prepara los resultados para ser devueltos00204
'------------------------------------------------00205
Dim TextoResultado As String00206
Dim CosteTotal As Single = 000207
Dim i , j As Long00208
Dim MatrizSolucion ( TotalNodos - 1 , TotalNodos - 1 ) As Integer00209
00210
00211
If maximo = False Then00212
TextoResultado = "ÁRBOL DE VALOR TOTAL MÍNIMO - ALGORITMO DE» KRUSKAL" & vbCrLf
00213
Else00214
TextoResultado = "ÁRBOL DE VALOR TOTAL MÁXIMO - ALGORITMO DE» KRUSKAL" & vbCrLf
00215
00216
End If00217
00218
TextoResultado = TextoResultado &» "--------------------------------------------------" & vbCrLf
00219
TextoResultado = TextoResultado & "" & vbCrLf00220
00221
TextoResultado = TextoResultado & "Tiempo de proceso = " & tiempoproceso» & " segundos" & vbCrLf & vbCrLf
00222
00223
00224
For i = 0 To TotalArcos - 100225
00226
If Arcos ( i ) . Camino = True Then00227
'Marca el camino00228
TextoResultado = TextoResultado & " * " & Nodos ( Arcos ( i ) . Nd1 )» . Texto & " ----(" & Arcos ( i ) . Coste & ")---> " & Nodos ( Arcos ( i
» ) . Nd2 ) . Texto & vbCrLf
00229
MatrizSolucion ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = 100230
CosteTotal = CosteTotal + Arcos ( i ) . Coste00231
00232
End If00233
00234
Next i00235
00236
TextoResultado = TextoResultado & vbCrLf & "Coste total = " & CosteTotal» & vbCrLf
00237
If maximo = False Then00238
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos del» árbol con coste mínimo:" & vbCrLf & vbCrLf
00239
Else00240
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos del» árbol con coste máximo:" & vbCrLf & vbCrLf
00241
End If00242
00243
TextoResultado = TextoResultado & "N1\N2" & vbTab00244
For i = 0 To TotalNodos - 100245
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00246
Next i00247
TextoResultado = TextoResultado & vbCrLf00248
00249
For i = 0 To UBound ( MatrizSolucion , 1 )00250
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00251
For j = 0 To UBound ( MatrizSolucion , 2 )00252
TextoResultado = TextoResultado & MatrizSolucion ( i , j ) & vbTab00253
Next j00254
TextoResultado = TextoResultado & vbCrLf00255
Next i00256
00257
00258
00259
00260
'-------------------------------00261
'fin del proceso devuelve resultados00262
RaiseEvent Fin ( TextoResultado , MatrizSolucion )00263
'-------------------------------00264
End Function00265
00266
Sub ArbolMinimo ( ByVal maximo As Boolean )00267
00268
'Comienza Algoritmo de Kruskal00269
00270
00271
Dim OrdenArco ( TotalArcos - 1 ) As Long00272
Dim ArcoOrdenado ( TotalArcos - 1 ) As Boolean00273
Dim i , j , k As Integer00274
Dim minCoste As Single00275
Dim minArco As Long00276
Dim arbol As Integer00277
00278
'inicializa variables00279
For i = 0 To TotalArcos - 100280
ArcoOrdenado ( i ) = False00281
OrdenArco ( i ) = - 100282
Arcos ( i ) . Camino = False00283
Next i00284
00285
'ordena arcos en de menor a mayor00286
For i = 0 To TotalArcos - 100287
If maximo = False Then00288
minCoste = cMaximo 'maximo valor posible00289
Else00290
minCoste = cMinimo 'maximo valor posible00291
End If00292
00293
minArco = - 100294
00295
'busca mínimo00296
For j = 0 To TotalArcos - 100297
If ArcoOrdenado ( j ) = False Then00298
00299
If maximo = False Then00300
If Arcos ( j ) . Coste <= minCoste Then00301
minCoste = Arcos ( j ) . Coste00302
minArco = j00303
End If00304
Else00305
If Arcos ( j ) . Coste >= minCoste Then00306
minCoste = Arcos ( j ) . Coste00307
minArco = j00308
End If00309
00310
End If00311
End If00312
Next j00313
00314
OrdenArco ( i ) = minArco00315
ArcoOrdenado ( minArco ) = True00316
00317
Next i00318
arbol = 000319
00320
Dim n1 , n2 As Integer00321
Dim a1 , a2 As Integer00322
'recorre todos los arcos en orden de menor a mayor00323
'buscando aquellos cuyos nodos no están ya cubiertos00324
For i = 0 To TotalArcos - 100325
00326
j = OrdenArco ( i )00327
n1 = Arcos ( j ) . Nd100328
n2 = Arcos ( j ) . Nd200329
'se crea un arbol nuevo00330
If Nodos ( n1 ) . Estatus = Nodos ( n2 ) . Estatus And Nodos ( n2 ) . Estatus =» cSinEstatus Then
00331
arbol = arbol + 100332
00333
Nodos ( n1 ) . Estatus = arbol00334
Nodos ( n1 ) . Estatus = arbol00335
Arcos ( j ) . Camino = True00336
00337
End If00338
00339
'se añade un nodo suelto a un arbol00340
If Nodos ( n1 ) . Estatus <> Nodos ( n2 ) . Estatus And ( Nodos ( n1 ) . Estatus =» cSinEstatus Or Nodos ( n2 ) . Estatus = cSinEstatus ) Then
00341
00342
If Nodos ( n1 ) . Estatus = cSinEstatus Then00343
Nodos ( n1 ) . Estatus = Nodos ( n2 ) . Estatus00344
End If00345
If Nodos ( n2 ) . Estatus = cSinEstatus Then00346
Nodos ( n2 ) . Estatus = Nodos ( n1 ) . Estatus00347
End If00348
Arcos ( j ) . Camino = True00349
00350
End If00351
00352
'se fusionan dos arboles00353
If Nodos ( n1 ) . Estatus <> Nodos ( n2 ) . Estatus And ( Nodos ( n1 ) . Estatus <>» cSinEstatus And Nodos ( n2 ) . Estatus <> cSinEstatus ) Then
00354
a1 = Nodos ( n1 ) . Estatus00355
a2 = Nodos ( n2 ) . Estatus00356
Arcos ( j ) . Camino = True00357
00358
For k = 0 To TotalArcos - 100359
If Nodos ( Arcos ( k ) . Nd1 ) . Estatus = a2 Then00360
Nodos ( Arcos ( k ) . Nd1 ) . Estatus = a100361
End If00362
If Nodos ( Arcos ( k ) . Nd2 ) . Estatus = a2 Then00363
Nodos ( Arcos ( k ) . Nd2 ) . Estatus = a100364
End If00365
Next k00366
00367
End If00368
00369
00370
Next i00371
00372
End Sub00373
00374
00375
End Class00001
Public Class Prim00002
Inherits System . Windows . Forms . UserControl00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'UserControl1 reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00033
components = New System . ComponentModel . Container ()00034
End Sub00035
00036
# End Region00037
'Declaraciones de Eventos00038
Public Event Fin ( ByVal TextoRespuesta As String , ByVal MatrizArcosMinimos As» Array ) 'ver parámetros de solución
00039
Public Event Fallo ( ByVal TextoError As String )00040
'Declaraciones de Variables00041
Public DatosIncorrectos As Boolean = False00042
00043
Private Const cSinEstatus As Integer = 000044
Private Const cCandidato As Integer = 100045
Private Const cProcesado As Integer = 200046
Private Const cMaximo As Single = 99999999999999999900047
Private Const cMinimo As Single = - 99999999999999999900048
00049
00050
00051
'Declara la estructura del objeto Arco o relación entre nodos00052
Public Structure Arco00053
'Dim Texto As String 'etiqueta00054
'Dim Min As Single 'valor de mínimo00055
'Dim Max As Single 'valor de máximo00056
Dim Coste As Single 'valor de coste00057
00058
Dim Camino As Boolean00059
'Dim Col As Color 'color del arco00060
'Dim Grosor As Single 'trazo del arco00061
Dim Nd1 As Integer 'nodo origen00062
Dim Nd2 As Integer 'nodo destino00063
00064
'Dim Camino As Boolean00065
'Dim B As Boolean 'doble flecha si o no00066
End Structure00067
00068
'Declara la estructura del objeto Nodo00069
Public Structure Nodo00070
Dim Texto As String 'etiqueta00071
00072
'Dim Precedente As Long00073
Dim Estatus As Integer00074
'Dim Distancia As Single00075
Dim ConArco As Boolean00076
00077
'Dim Valor As Single 'valor del nodo00078
'Dim X As Single 'coordenadas00079
'Dim Y As Single00080
'Dim Z As Single00081
'Dim Col As Color 'color de relleno del nodo00082
'Dim Radio As Single 'radio del nodo00083
'Dim Grosor As Single 'trazo del nodo00084
End Structure00085
00086
'Totales de Nodos y Arcos00087
Public TotalNodos As Long00088
Public TotalArcos As Long00089
00090
'Crea las colecciones para ambos objetos00091
Public Nodos ( 1 ) As Nodo00092
Public Arcos ( 1 ) As Arco00093
Public MArcos ( 1 , 1 ) As Single00094
00095
Public Property MatrizNodos () As Array00096
'Lectura de propiedades00097
Get00098
'para devolver un valor desde la dll a la aplicación00099
00100
End Get00101
Set ( ByVal Value As Array )00102
'para poner un valor desde la aplicación a la dll00103
DatosIncorrectos = False00104
Dim i As Long00105
'comprobar la integridad de los datos antes de proseguir00106
i = UBound ( Value )00107
If i > 0 Then00108
'dimensiona el total de nodos00109
TotalNodos = i + 100110
'toma los datos de nodos y los pone en la estructura00111
For i = 0 To UBound ( Value )00112
ReDim Preserve Nodos ( i )00113
Nodos ( i ) . Texto = Value ( i )00114
Next i00115
Else00116
'no hay suficientes nodos00117
RaiseEvent Fallo ( "Deben existir al menos dos Nodos y un Arco» para definir un grafo." )
00118
DatosIncorrectos = True00119
End If00120
00121
End Set00122
End Property00123
Public Property MatrizArcos () As Array00124
'Lectura de propiedades00125
Get00126
'para devolver un valor desde la dll a la aplicación00127
00128
End Get00129
Set ( ByVal Value As Array )00130
'para poner un valor desde la aplicación a la dll00131
Dim i As Long00132
Dim j As Long00133
DatosIncorrectos = False00134
'comprobar la integridad de los datos antes de proseguir00135
i = UBound ( Value , 1 ) 'primera dimensión de la matriz00136
j = UBound ( Value , 2 ) 'segunda dimensión de la matriz00137
00138
If i = j And i = TotalNodos - 1 Then00139
'Recorre la matriz para tomar los datos y ponerlos en00140
'la estructura de arcos00141
TotalArcos = 000142
For i = 0 To TotalNodos - 100143
For j = 0 To TotalNodos - 100144
'el algoritmo de Prim puede tener pesos00145
'de arco menores que cero00146
'para indicar que no existe arco se usará la00147
'cMaximo= 99999999999999999900148
'cMinimo = -99999999999999999900149
If i <> j And Value ( i , j ) < cMaximo And Value ( i , j ) >» cMinimo Then
00150
TotalArcos = TotalArcos + 100151
ReDim Preserve Arcos ( TotalArcos - 1 )00152
00153
Arcos ( TotalArcos - 1 ) . Nd1 = i00154
Arcos ( TotalArcos - 1 ) . Nd2 = j00155
Arcos ( TotalArcos - 1 ) . Coste = Value ( i , j )00156
End If00157
'If i = j Then00158
'arco sobre un mismo nodo no permitido00159
'RaiseEvent Fallo("Se ha encontrado un arco sobre sí» mismo en el nodo (" & Nodos(i).Texto & ")." & vbCrLf
» & "Esto no está permitido en el Algoritmo de Prim.")
00160
'DatosIncorrectos = True00161
'End If00162
00163
Next j00164
Next i00165
00166
Else00167
'no hay suficientes arcos00168
RaiseEvent Fallo ( "Las dimensiones de la matriz de Arcos no» concuerdan con el total de nodos." )
00169
DatosIncorrectos = True00170
End If00171
If TotalArcos = 0 Then00172
'no hay suficientes arcos00173
RaiseEvent Fallo ( "Debe existir al menos un Arco entre dos Nodos» para definir un grafo." )
00174
DatosIncorrectos = True00175
End If00176
00177
End Set00178
End Property00179
Public Function Inicio ( ByVal maximo As Boolean )00180
00181
00182
00183
'Inicio cálculo de tiempo00184
Dim TInicio As Date = Now00185
00186
00187
'-------------------------------00188
'Llamar al proceso de cálculo00189
'arbol mínimo00190
ArbolMinimo ( maximo )00191
'-------------------------------00192
00193
00194
00195
'fin cálculo de tiempo00196
Dim tiempoproceso As Long00197
tiempoproceso = DateDiff ( DateInterval . Second , TInicio , Now )00198
00199
00200
'prepara los resultados para ser devueltos00201
'------------------------------------------------00202
Dim TextoResultado As String00203
Dim CosteTotal As Single = 000204
Dim i , j As Long00205
Dim MatrizSolucion ( TotalNodos - 1 , TotalNodos - 1 ) As Integer00206
00207
00208
If maximo = False Then00209
TextoResultado = "ÁRBOL DE VALOR TOTAL MÍNIMO - ALGORITMO DE PRIM" &» vbCrLf
00210
Else00211
TextoResultado = "ÁRBOL DE VALOR TOTAL MÁXIMO - ALGORITMO DE PRIM" &» vbCrLf
00212
00213
End If00214
00215
TextoResultado = TextoResultado &» "--------------------------------------------------" & vbCrLf
00216
TextoResultado = TextoResultado & "" & vbCrLf00217
00218
TextoResultado = TextoResultado & "Tiempo de proceso = " & tiempoproceso» & " segundos" & vbCrLf & vbCrLf
00219
00220
00221
For i = 0 To TotalArcos - 100222
00223
If Arcos ( i ) . Camino = True Then00224
'Marca el camino00225
TextoResultado = TextoResultado & " * " & Nodos ( Arcos ( i ) . Nd1 )» . Texto & " ----(" & Arcos ( i ) . Coste & ")---> " & Nodos ( Arcos ( i
» ) . Nd2 ) . Texto & vbCrLf
00226
MatrizSolucion ( Arcos ( i ) . Nd1 , Arcos ( i ) . Nd2 ) = 100227
CosteTotal = CosteTotal + Arcos ( i ) . Coste00228
00229
End If00230
00231
Next i00232
00233
TextoResultado = TextoResultado & vbCrLf & "Coste total = " & CosteTotal» & vbCrLf
00234
If maximo = False Then00235
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos del» árbol con coste mínimo:" & vbCrLf & vbCrLf
00236
Else00237
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos del» árbol con coste máximo:" & vbCrLf & vbCrLf
00238
End If00239
00240
TextoResultado = TextoResultado & "N1\N2" & vbTab00241
For i = 0 To TotalNodos - 100242
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00243
Next i00244
TextoResultado = TextoResultado & vbCrLf00245
00246
For i = 0 To UBound ( MatrizSolucion , 1 )00247
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00248
For j = 0 To UBound ( MatrizSolucion , 2 )00249
TextoResultado = TextoResultado & MatrizSolucion ( i , j ) & vbTab00250
Next j00251
TextoResultado = TextoResultado & vbCrLf00252
Next i00253
00254
'-------------------------------00255
'fin del proceso devuelve resultados00256
RaiseEvent Fin ( TextoResultado , MatrizSolucion )00257
'-------------------------------00258
End Function00259
00260
Sub ArbolMinimo ( ByVal maximo As Boolean )00261
00262
'Comienza Algoritmo de Prim00263
Dim i , k , a As Integer00264
Dim n1 , n2 As Long00265
00266
'Inicializa00267
For i = 0 To TotalNodos - 100268
Nodos ( i ) . ConArco = False00269
Nodos ( i ) . Estatus = cSinEstatus00270
Next i00271
00272
00273
'busca nodos con arco00274
For i = 0 To TotalArcos - 100275
Nodos ( Arcos ( i ) . Nd1 ) . ConArco = True00276
Nodos ( Arcos ( i ) . Nd2 ) . ConArco = True00277
Arcos ( i ) . Camino = False00278
Next i00279
00280
'cuenta nodos con arco00281
Dim TotalNodosArco As Long = 000282
For i = 0 To TotalNodos - 100283
If Nodos ( i ) . ConArco = True Then00284
TotalNodosArco = TotalNodosArco + 100285
End If00286
Next i00287
00288
'inicializa primer nodo00289
'aunque realmente se puede empezar por cualquier nodo00290
'primer nodo es el nodo 1 del arco cero00291
k = Arcos ( 0 ) . Nd100292
Nodos ( k ) . Estatus = cProcesado00293
00294
Dim nodossel As Long = 100295
Dim min As Single00296
00297
Do While nodossel < TotalNodosArco00298
k = - 100299
If maximo = False Then00300
min = cMaximo00301
Else00302
min = cMinimo00303
End If00304
00305
For a = 0 To TotalArcos - 100306
If Arcos ( a ) . Camino = False Then00307
n1 = Arcos ( a ) . Nd100308
n2 = Arcos ( a ) . Nd200309
00310
If ( Nodos ( n1 ) . Estatus = cProcesado And Nodos ( n2 ) . Estatus =» cSinEstatus ) Or ( Nodos ( n2 ) . Estatus = cProcesado And
» Nodos ( n1 ) . Estatus = cSinEstatus ) Then
00311
If maximo = False Then00312
If Arcos ( a ) . Coste < min Then00313
min = Arcos ( a ) . Coste00314
k = a00315
End If00316
Else00317
If Arcos ( a ) . Coste > min Then00318
min = Arcos ( a ) . Coste00319
k = a00320
End If00321
End If00322
End If00323
End If00324
Next a00325
00326
If k <> - 1 Then00327
Arcos ( k ) . Camino = True00328
Nodos ( Arcos ( k ) . Nd1 ) . Estatus = cProcesado00329
Nodos ( Arcos ( k ) . Nd2 ) . Estatus = cProcesado00330
nodossel = nodossel + 100331
End If00332
Loop00333
End Sub00334
00335
End Class00001
Public Class FordFulkerson00002
Inherits System . Windows . Forms . UserControl00003
00004
# Region " Código generado por el Diseñador de Windows Forms "00005
00006
Public Sub New ()00007
MyBase . New ()00008
00009
'El Diseñador de Windows Forms requiere esta llamada.00010
InitializeComponent ()00011
00012
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00013
00014
End Sub00015
00016
'UserControl1 reemplaza a Dispose para limpiar la lista de componentes.00017
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00018
If disposing Then00019
If Not ( components Is Nothing ) Then00020
components . Dispose ()00021
End If00022
End If00023
MyBase . Dispose ( disposing )00024
End Sub00025
00026
'Requerido por el Diseñador de Windows Forms00027
Private components As System . ComponentModel . IContainer00028
00029
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00030
'Puede modificarse utilizando el Diseñador de Windows Forms.00031
'No lo modifique con el editor de código.00032
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00033
components = New System . ComponentModel . Container00034
End Sub00035
00036
# End Region00037
'Declaraciones de Eventos00038
Public Event Fin ( ByVal TextoRespuesta As String , ByVal MatrizArcosMinimos As» Array ) 'ver parámetros de solución
00039
Public Event Fallo ( ByVal TextoError As String )00040
'Declaraciones de Variables00041
Public DatosIncorrectos As Boolean = False00042
00043
Private Const cSinEstatus As Integer = 000044
Private Const cCandidato As Integer = 100045
Private Const cProcesado As Integer = 200046
Private Const cMaximo As Single = 99999999999999999900047
Private Const cMinimo As Single = - 99999999999999999900048
00049
00050
00051
00052
00053
00054
'Declara la estructura del objeto Arco o relación entre nodos00055
Public Structure Arco00056
'Dim Texto As String 'etiqueta00057
Dim Min As Single 'valor de mínimo00058
Dim Max As Single 'valor de máximo00059
'Dim Coste As Single 'valor de coste00060
00061
Dim Camino As Boolean00062
'Dim Col As Color 'color del arco00063
'Dim Grosor As Single 'trazo del arco00064
Dim Nd1 As Integer 'nodo origen00065
Dim Nd2 As Integer 'nodo destino00066
00067
'Dim Camino As Boolean00068
'Dim B As Boolean 'doble flecha si o no00069
End Structure00070
00071
'Declara la estructura del objeto Nodo00072
Public Structure Nodo00073
Dim Texto As String 'etiqueta00074
00075
'Dim Precedente As Long00076
Dim Estatus As Integer00077
'Dim Distancia As Single00078
00079
'Dim Valor As Single 'valor del nodo00080
'Dim X As Single 'coordenadas00081
'Dim Y As Single00082
'Dim Z As Single00083
'Dim Col As Color 'color de relleno del nodo00084
'Dim Radio As Single 'radio del nodo00085
'Dim Grosor As Single 'trazo del nodo00086
End Structure00087
00088
'Totales de Nodos y Arcos00089
Public TotalNodos As Long00090
Public TotalArcos As Long00091
00092
'Crea las colecciones para ambos objetos00093
Public Nodos ( 1 ) As Nodo00094
Public Arcos ( 1 ) As Arco00095
00096
'Matriz de capacidades y matriz de flujos00097
Public Capacidad ( 0 , 0 ) As Single00098
Public Flujo ( 0 , 0 ) As Single00099
Public FlujoMaximo As Single00100
00101
Public Cola () As Integer00102
Public Estado () As Integer00103
Public Pred () As Integer00104
00105
Public Primero , Ultimo As Integer00106
00107
00108
Public Property MatrizNodos () As Array00109
'Lectura de propiedades00110
Get00111
'para devolver un valor desde la dll a la aplicación00112
00113
End Get00114
Set ( ByVal Value As Array )00115
'para poner un valor desde la aplicación a la dll00116
DatosIncorrectos = False00117
Dim i As Long00118
'comprobar la integridad de los datos antes de proseguir00119
i = UBound ( Value )00120
If i > 0 Then00121
'dimensiona el total de nodos00122
TotalNodos = i + 100123
'toma los datos de nodos y los pone en la estructura00124
For i = 0 To UBound ( Value )00125
ReDim Preserve Nodos ( i )00126
Nodos ( i ) . Texto = Value ( i )00127
Nodos ( i ) . Estatus = cSinEstatus00128
Next i00129
Else00130
'no hay suficientes nodos00131
RaiseEvent Fallo ( "Deben existir al menos dos Nodos y un Arco» para definir un grafo." )
00132
DatosIncorrectos = True00133
End If00134
00135
End Set00136
End Property00137
Public Property MatrizArcos () As Array00138
'Lectura de propiedades00139
Get00140
'para devolver un valor desde la dll a la aplicación00141
00142
End Get00143
Set ( ByVal Value As Array )00144
'para poner un valor desde la aplicación a la dll00145
Dim i As Long00146
Dim j As Long00147
DatosIncorrectos = False00148
'comprobar la integridad de los datos antes de proseguir00149
i = UBound ( Value , 1 ) 'primera dimensión de la matriz00150
j = UBound ( Value , 2 ) 'segunda dimensión de la matriz00151
00152
If i = j And i = TotalNodos - 1 Then00153
'Recorre la matriz para tomar los datos y ponerlos en00154
'la estructura de arcos00155
00156
ReDim Capacidad ( i , j )00157
ReDim Flujo ( i , j )00158
'Capacidad = Value00159
00160
ReDim Cola ( i + 2 ) 'totalnodos+200161
ReDim Estado ( i ) 'totalnodos00162
ReDim Pred ( i ) 'totalnodos00163
00164
00165
TotalArcos = 000166
For i = 0 To TotalNodos - 100167
For j = 0 To TotalNodos - 100168
'el algoritmo de FordFulkerson no puede tener» capacidades
00169
'de arco menores que cero00170
'para indicar que no existe arco se usará la00171
'cMaximo= 99999999999999999900172
'cMinimo = -99999999999999999900173
00174
00175
If i <> j And Value ( i , j ) < cMaximo And Value ( i , j ) >» cMinimo Then
00176
TotalArcos = TotalArcos + 100177
ReDim Preserve Arcos ( TotalArcos - 1 )00178
00179
Arcos ( TotalArcos - 1 ) . Nd1 = i00180
Arcos ( TotalArcos - 1 ) . Nd2 = j00181
00182
'no se permiten capacidades negativas00183
If Value ( i , j ) >= 0 Then00184
Arcos ( TotalArcos - 1 ) . Max = Value ( i , j )00185
Capacidad ( i , j ) = Value ( i , j )00186
Else00187
Arcos ( TotalArcos - 1 ) . Max = 000188
Capacidad ( i , j ) = 000189
End If00190
End If00191
If i = j Then00192
'arco sobre un mismo nodo no permitido00193
Capacidad ( i , j ) = 000194
End If00195
00196
Next j00197
Next i00198
00199
Else00200
'no hay suficientes arcos00201
RaiseEvent Fallo ( "Las dimensiones de la matriz de Arcos no» concuerdan con el total de nodos." )
00202
DatosIncorrectos = True00203
End If00204
If TotalArcos = 0 Then00205
'no hay suficientes arcos00206
RaiseEvent Fallo ( "Debe existir al menos un Arco entre dos Nodos» para definir un grafo." )
00207
DatosIncorrectos = True00208
End If00209
00210
End Set00211
End Property00212
00213
Public Function Inicio ( ByVal NodoInicio As Long , ByVal NodoFin As Long ,» ByVal maximo As Boolean )
00214
00215
'Inicio cálculo de tiempo00216
Dim TInicio As Date = Now00217
00218
'-------------------------------00219
'Llamar al proceso de cálculo00220
'arbol mínimo00221
AlgoritmoFlujoMaximo ( NodoInicio , NodoFin , maximo )00222
'-------------------------------00223
00224
'fin cálculo de tiempo00225
Dim tiempoproceso As Long00226
tiempoproceso = DateDiff ( DateInterval . Second , TInicio , Now )00227
00228
00229
'prepara los resultados para ser devueltos00230
'------------------------------------------------00231
Dim TextoResultado As String00232
Dim CosteTotal As Single = 000233
Dim i , j As Long00234
Dim MatrizSolucion ( TotalNodos - 1 , TotalNodos - 1 ) As Integer00235
00236
'Pone la matriz de flujo en la matriz solución00237
For i = 0 To TotalNodos - 100238
For j = 0 To TotalNodos - 100239
MatrizSolucion ( i , j ) = Flujo ( i , j )00240
Next j00241
Next i00242
00243
If maximo = False Then00244
TextoResultado = "ÁRBOL DE FLUJO MÍNIMO - ALGORITMO DE FORD» FULKERSON" & vbCrLf
00245
Else00246
TextoResultado = "ÁRBOL DE FLUJO MÁXIMO - ALGORITMO DE FORD» FULKERSON" & vbCrLf
00247
End If00248
00249
TextoResultado = TextoResultado &» "---------------------------------------------------" & vbCrLf
00250
TextoResultado = TextoResultado & "" & vbCrLf00251
00252
TextoResultado = TextoResultado & "Tiempo de proceso = " & tiempoproceso» & " segundos" & vbCrLf & vbCrLf
00253
00254
00255
'For i = 0 To TotalArcos - 100256
00257
'If Arcos(i).Camino = True Then00258
'Marca el camino00259
'TextoResultado = TextoResultado & " * " & Nodos(Arcos(i).Nd1).Texto» & " ----(" & Arcos(i).Min & ")---> " & Nodos(Arcos(i).Nd2).Texto &
» vbCrLf
00260
'MatrizSolucion(Arcos(i).Nd1, Arcos(i).Nd2) = 100261
'CosteTotal = CosteTotal + Arcos(i).Min00262
00263
'End If00264
00265
'Next i00266
00267
00268
'Flujos00269
TextoResultado = TextoResultado & vbCrLf & "Flujo máximo = " &» FlujoMaximo & vbCrLf
00270
If maximo = False Then00271
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos con» flujo mínimo:" & vbCrLf & vbCrLf
00272
Else00273
TextoResultado = TextoResultado & vbCrLf & "Matriz de Arcos con» flujo máximo:" & vbCrLf & vbCrLf
00274
End If00275
00276
TextoResultado = TextoResultado & "N1\N2" & vbTab00277
For i = 0 To TotalNodos - 100278
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00279
Next i00280
TextoResultado = TextoResultado & vbCrLf00281
00282
For i = 0 To UBound ( MatrizSolucion , 1 )00283
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00284
For j = 0 To UBound ( MatrizSolucion , 2 )00285
TextoResultado = TextoResultado & MatrizSolucion ( i , j ) & vbTab00286
Next j00287
TextoResultado = TextoResultado & vbCrLf00288
Next i00289
00290
'Capacidades residuales00291
TextoResultado = TextoResultado & vbCrLf & "Matriz de Capacidades» Residuales:" & vbCrLf & vbCrLf
00292
00293
TextoResultado = TextoResultado & "N1\N2" & vbTab00294
For i = 0 To TotalNodos - 100295
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00296
Next i00297
TextoResultado = TextoResultado & vbCrLf00298
00299
For i = 0 To UBound ( MatrizSolucion , 1 )00300
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00301
For j = 0 To UBound ( MatrizSolucion , 2 )00302
TextoResultado = TextoResultado & ( Capacidad ( i , j ) -» MatrizSolucion ( i , j )) & vbTab
00303
Next j00304
TextoResultado = TextoResultado & vbCrLf00305
Next i00306
00307
'-------------------------------00308
'fin del proceso devuelve resultados00309
RaiseEvent Fin ( TextoResultado , MatrizSolucion )00310
'-------------------------------00311
End Function00312
00313
Sub AlgoritmoFlujoMaximo ( ByVal NodoInicio As Long , ByVal NodoFin As Long ,» ByVal maximo As Boolean )
00314
00315
'Inicializa la matriz de flujo00316
Dim i , j , u As Long00317
For i = 0 To TotalNodos - 100318
For j = 0 To TotalNodos - 100319
Flujo ( i , j ) = 000320
Next j00321
Next i00322
00323
'Inicializa Flujo máximo00324
FlujoMaximo = 000325
00326
Dim incremento As Single00327
00328
'Algoritmo principal00329
While CaminoAumento ( NodoInicio , NodoFin )00330
00331
'Determina la cantidad en la que se puede incrementar el flujo00332
incremento = cMaximo00333
u = TotalNodos - 100334
Do While Pred ( u ) >= 000335
incremento = Minimo ( incremento , Capacidad ( Pred ( u ), u ) - Flujo (» Pred ( u ), u ))
00336
u = Pred ( u )00337
Loop00338
00339
'Ahora incrementa el flujo00340
u = TotalNodos - 100341
Do While Pred ( u ) >= 000342
Flujo ( Pred ( u ), u ) = Flujo ( Pred ( u ), u ) + incremento00343
Flujo ( u , Pred ( u )) = Flujo ( u , Pred ( u )) - incremento00344
u = Pred ( u )00345
Loop00346
00347
FlujoMaximo = FlujoMaximo + incremento00348
00349
End While00350
'Fin00351
Beep ()00352
End Sub00353
00354
Function CaminoAumento ( ByVal NodoInicio As Long , ByVal NodoFin As Long )00355
Dim u , v As Integer00356
00357
For u = 0 To TotalNodos - 100358
Estado ( u ) = cSinEstatus00359
Next u00360
00361
Primero = 000362
Ultimo = 000363
00364
EnCola ( NodoInicio )00365
Pred ( NodoInicio ) = - 100366
00367
While Primero <> Ultimo00368
u = FueraCola ()00369
00370
'busca todos los nodos adyacentes v sin estatus00371
'si la capacidad de u a v en la red residual es positiva00372
'entonces pone en la cola v00373
00374
For v = 0 To TotalNodos - 100375
If Estado ( v ) = cSinEstatus And ( Capacidad ( u , v ) - Flujo ( u , v ))» > 0 Then
00376
EnCola ( v )00377
Pred ( v ) = u00378
End If00379
Next v00380
End While00381
00382
'si el estado del nodo final es procesado00383
'significa que se ha encontrado00384
If Estado ( NodoFin ) = cProcesado Then00385
Return True00386
Else00387
Return False00388
End If00389
00390
End Function00391
Sub EnCola ( ByVal x As Integer )00392
Cola ( Ultimo ) = x00393
Ultimo = Ultimo + 100394
Estado ( x ) = cCandidato00395
End Sub00396
Function FueraCola () As Integer00397
Dim x As Integer00398
x = Cola ( Primero )00399
Primero = Primero + 100400
Estado ( x ) = cProcesado00401
Return x00402
End Function00403
Function Minimo ( ByVal x As Single , ByVal y As Single ) As Single00404
If x < y Then Return x00405
If y <= x Then Return y00406
End Function00407
End Class00001
Public Class FloydWarshall00002
00003
Inherits System . Windows . Forms . UserControl00004
00005
# Region " Código generado por el Diseñador de Windows Forms "00006
00007
Public Sub New ()00008
MyBase . New ()00009
00010
'El Diseñador de Windows Forms requiere esta llamada.00011
InitializeComponent ()00012
00013
'Agregar cualquier inicialización después de la llamada a» InitializeComponent()
00014
00015
End Sub00016
00017
'UserControl1 reemplaza a Dispose para limpiar la lista de componentes.00018
Protected Overloads Overrides Sub Dispose ( ByVal disposing As Boolean )00019
If disposing Then00020
If Not ( components Is Nothing ) Then00021
components . Dispose ()00022
End If00023
End If00024
MyBase . Dispose ( disposing )00025
End Sub00026
00027
'Requerido por el Diseñador de Windows Forms00028
Private components As System . ComponentModel . IContainer00029
00030
'NOTA: el Diseñador de Windows Forms requiere el siguiente procedimiento00031
'Puede modificarse utilizando el Diseñador de Windows Forms.00032
'No lo modifique con el editor de código.00033
< System . Diagnostics . DebuggerStepThrough ()> Private Sub InitializeComponent ()00034
components = New System . ComponentModel . Container00035
End Sub00036
00037
# End Region00038
'Declaraciones de Eventos00039
Public Event Fin ( ByVal TextoRespuesta As String , ByVal MatrizArcosMinimos As» Array ) 'ver parámetros de solución
00040
Public Event Fallo ( ByVal TextoError As String )00041
'Declaraciones de Variables00042
Public DatosIncorrectos As Boolean = False00043
00044
'Private Const cSinEstatus As Integer = 000045
'Private Const cCandidato As Integer = 100046
'Private Const cProcesado As Integer = 200047
Private Const cMaximo As Single = 99999999999999999900048
Private Const cMinimo As Single = - 99999999999999999900049
00050
00051
'Declara la estructura del objeto Arco o relación entre nodos00052
Public Structure Arco00053
'Dim Texto As String 'etiqueta00054
'Dim Min As Single 'valor de mínimo00055
'Dim Max As Single 'valor de máximo00056
Dim Coste As Single 'valor de coste00057
00058
Dim Camino As Boolean00059
'Dim Col As Color 'color del arco00060
'Dim Grosor As Single 'trazo del arco00061
Dim Nd1 As Integer 'nodo origen00062
Dim Nd2 As Integer 'nodo destino00063
00064
'Dim Camino As Boolean00065
'Dim B As Boolean 'doble flecha si o no00066
End Structure00067
00068
'Declara la estructura del objeto Nodo00069
Public Structure Nodo00070
Dim Texto As String 'etiqueta00071
00072
'Dim Precedente As Long00073
'Dim Estatus As Integer00074
'Dim Distancia As Single00075
00076
'Dim Valor As Single 'valor del nodo00077
'Dim X As Single 'coordenadas00078
'Dim Y As Single00079
'Dim Z As Single00080
'Dim Col As Color 'color de relleno del nodo00081
'Dim Radio As Single 'radio del nodo00082
'Dim Grosor As Single 'trazo del nodo00083
End Structure00084
00085
'Totales de Nodos y Arcos00086
Public TotalNodos As Long00087
Public TotalArcos As Long00088
00089
'Crea las colecciones para ambos objetos00090
Public Nodos ( 1 ) As Nodo00091
Public Arcos ( 1 ) As Arco00092
00093
'Matriz de caminos y distancias00094
Public Distancias ( 0 , 0 ) As Single00095
Public Caminos ( 0 , 0 ) As Long00096
00097
00098
Public Ciclo As Boolean00099
00100
00101
Public Property MatrizNodos () As Array00102
'Lectura de propiedades00103
Get00104
'para devolver un valor desde la dll a la aplicación00105
End Get00106
Set ( ByVal Value As Array )00107
'para poner un valor desde la aplicación a la dll00108
DatosIncorrectos = False00109
Dim i As Long00110
'comprobar la integridad de los datos antes de proseguir00111
i = UBound ( Value )00112
If i > 0 Then00113
'dimensiona el total de nodos00114
TotalNodos = i + 100115
'toma los datos de nodos y los pone en la estructura00116
For i = 0 To UBound ( Value )00117
ReDim Preserve Nodos ( i )00118
Nodos ( i ) . Texto = Value ( i )00119
Next i00120
Else00121
'no hay suficientes nodos00122
RaiseEvent Fallo ( "Deben existir al menos dos Nodos y un Arco» para definir un grafo." )
00123
DatosIncorrectos = True00124
End If00125
End Set00126
End Property00127
Public Property MatrizArcos () As Array00128
'Lectura de propiedades00129
Get00130
'para devolver un valor desde la dll a la aplicación00131
00132
End Get00133
Set ( ByVal Value As Array )00134
'para poner un valor desde la aplicación a la dll00135
Dim i As Long00136
Dim j As Long00137
DatosIncorrectos = False00138
'comprobar la integridad de los datos antes de proseguir00139
i = UBound ( Value , 1 ) 'primera dimensión de la matriz00140
j = UBound ( Value , 2 ) 'segunda dimensión de la matriz00141
00142
If i = j And i = TotalNodos - 1 Then00143
'Recorre la matriz para tomar los datos y ponerlos en00144
'la estructura de arcos00145
00146
ReDim Distancias ( i , j )00147
ReDim Caminos ( i , j )00148
00149
TotalArcos = 000150
For i = 0 To TotalNodos - 100151
For j = 0 To TotalNodos - 100152
'el algoritmo de FloyWarshall puede tener costes00153
'de arco menores que cero00154
'para indicar que no existe arco se usará la00155
'cMaximo= 99999999999999999900156
'cMinimo = -99999999999999999900157
'según corresponda maximizar o minimizar00158
Distancias ( i , j ) = Value ( i , j )00159
00160
If i <> j And Value ( i , j ) < cMaximo And Value ( i , j ) >» cMinimo Then
00161
TotalArcos = TotalArcos + 100162
ReDim Preserve Arcos ( TotalArcos - 1 )00163
00164
Arcos ( TotalArcos - 1 ) . Nd1 = i00165
Arcos ( TotalArcos - 1 ) . Nd2 = j00166
00167
'si se permiten costes negativos00168
'If Value(i, j) = cMaximo Then00169
Arcos ( TotalArcos - 1 ) . Coste = Value ( i , j )00170
00171
'Else00172
'Arcos(TotalArcos - 1).Coste = 000173
'Distancias(i, j) = 000174
'End If00175
End If00176
00177
If i = j Then00178
'arco sobre un mismo nodo no permitido00179
Distancias ( i , j ) = 000180
End If00181
00182
Next j00183
Next i00184
00185
Else00186
'no hay suficientes arcos00187
RaiseEvent Fallo ( "Las dimensiones de la matriz de Arcos no» concuerdan con el total de nodos." )
00188
DatosIncorrectos = True00189
End If00190
If TotalArcos = 0 Then00191
'no hay suficientes arcos00192
RaiseEvent Fallo ( "Debe existir al menos un Arco entre dos Nodos» para definir un grafo." )
00193
DatosIncorrectos = True00194
End If00195
00196
End Set00197
End Property00198
00199
Public Function Inicio ( ByVal maximo As Boolean )00200
00201
'Inicio cálculo de tiempo00202
Dim TInicio As Date = Now00203
00204
'-------------------------------00205
'Llamar al proceso de cálculo00206
'cámino mínimo/máximo entre todos los pares de nodos00207
Algoritmo ( maximo )00208
'-------------------------------00209
00210
'fin cálculo de tiempo00211
Dim tiempoproceso As Long00212
tiempoproceso = DateDiff ( DateInterval . Second , TInicio , Now )00213
00214
'prepara los resultados para ser devueltos00215
'------------------------------------------------00216
Dim TextoResultado As String00217
Dim CosteTotal As Single = 000218
Dim i , j , k As Long00219
Dim MatrizSolucion ( TotalNodos - 1 , TotalNodos - 1 ) As Integer00220
00221
'Pone la matriz de flujo en la matriz solución00222
For i = 0 To TotalNodos - 100223
For j = 0 To TotalNodos - 100224
MatrizSolucion ( i , j ) = 0 'ATENCIÓN!!!!00225
Next j00226
Next i00227
00228
If maximo = False Then00229
TextoResultado = "ÁRBOL DE CAMINOS MÍNIMOS - ALGORITMO DE FLOYD» WARSHALL" & vbCrLf
00230
Else00231
TextoResultado = "ÁRBOL DE CAMINOS MÁXIMOS - ALGORITMO DE FLOYD» WARSHALL" & vbCrLf
00232
End If00233
00234
TextoResultado = TextoResultado &» "------------------------------------------------------" & vbCrLf
00235
TextoResultado = TextoResultado & "" & vbCrLf00236
00237
TextoResultado = TextoResultado & "Tiempo de proceso = " & tiempoproceso» & " segundos" & vbCrLf & vbCrLf
00238
00239
00240
For i = 0 To TotalNodos - 100241
For j = 0 To TotalNodos - 100242
For k = 0 To TotalArcos - 100243
If Arcos ( k ) . Nd1 = i And Arcos ( k ) . Nd2 = j Then00244
If Caminos ( i , j ) <> - 1 Then00245
'Marca el camino00246
MatrizSolucion ( Caminos ( i , j ), j ) = 100247
End If00248
Exit For00249
End If00250
Next k00251
Next j00252
Next i00253
00254
00255
00256
If maximo = False Then00257
TextoResultado = TextoResultado & vbCrLf & "Matriz de Distancias» mínimas:" & vbCrLf & vbCrLf
00258
Else00259
TextoResultado = TextoResultado & vbCrLf & "Matriz de Distancias» máximas:" & vbCrLf & vbCrLf
00260
End If00261
00262
TextoResultado = TextoResultado & "N1\N2" & vbTab00263
For i = 0 To TotalNodos - 100264
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00265
Next i00266
TextoResultado = TextoResultado & vbCrLf00267
00268
For i = 0 To UBound ( MatrizSolucion , 1 )00269
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00270
For j = 0 To UBound ( MatrizSolucion , 2 )00271
TextoResultado = TextoResultado & Distancias ( i , j ) & vbTab00272
Next j00273
TextoResultado = TextoResultado & vbCrLf00274
Next i00275
00276
'Matriz de caminos00277
TextoResultado = TextoResultado & vbCrLf & "Matriz de Caminos:" & vbCrLf» & vbCrLf
00278
00279
TextoResultado = TextoResultado & "N1\N2" & vbTab00280
For i = 0 To TotalNodos - 100281
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00282
Next i00283
TextoResultado = TextoResultado & vbCrLf00284
00285
For i = 0 To UBound ( MatrizSolucion , 1 )00286
TextoResultado = TextoResultado & Nodos ( i ) . Texto & vbTab00287
For j = 0 To UBound ( MatrizSolucion , 2 )00288
If Caminos ( i , j ) <> - 1 Then00289
TextoResultado = TextoResultado & Nodos ( Caminos ( i , j )) .» Texto & vbTab
00290
Else00291
TextoResultado = TextoResultado & "-" & vbTab00292
End If00293
Next j00294
TextoResultado = TextoResultado & vbCrLf00295
Next i00296
00297
'listado de todos los caminos00298
TextoResultado = TextoResultado & vbCrLf & "Listado de Caminos:" &» vbCrLf & vbCrLf
00299
00300
Dim cadena As String00301
00302
For i = 0 To TotalNodos - 100303
For j = 0 To TotalNodos - 100304
00305
cadena = Nodos ( i ) . Texto & " --(" & Distancias ( i , j ) & ")--> " &» Nodos ( j ) . Texto
00306
cadena = cadena & " = " & Ruta ( i , j , True )00307
TextoResultado = TextoResultado & cadena & vbCrLf00308
00309
Next j00310
Next i00311
00312
00313
'-------------------------------00314
'fin del proceso devuelve resultados00315
RaiseEvent Fin ( TextoResultado , MatrizSolucion )00316
'-------------------------------00317
End Function00318
Function Algoritmo ( ByVal maximo As Boolean )00319
00320
Dim i , j , k As Long00321
Dim n As Single00322
Dim ciclo As Boolean00323
00324
'Inicia la matriz de caminos Pi00325
For i = 0 To TotalNodos - 100326
For j = 0 To TotalNodos - 100327
00328
If Distancias ( i , j ) = cMaximo Or Distancias ( i , j ) = cMinimo Or» ( i = j ) Then
00329
Caminos ( i , j ) = - 1 'valor nulo00330
Else00331
Caminos ( i , j ) = i00332
End If00333
00334
Next j00335
Next i00336
00337
ciclo = False00338
00339
k = 000340
While ( k <= TotalNodos - 1 ) And ( Not ciclo )00341
For i = 0 To TotalNodos - 100342
If Distancias ( i , k ) <> cMaximo And Distancias ( i , k ) <> cMinimo» Then
00343
For j = 0 To TotalNodos - 100344
If Distancias ( k , j ) <> cMaximo And Distancias ( k , j ) <» > cMinimo Then
00345
00346
If maximo = False Then00347
n = Distancias ( i , k ) + Distancias ( k , j )00348
If Distancias ( i , j ) > n Then00349
Distancias ( i , j ) = n00350
Caminos ( i , j ) = Caminos ( k , j )00351
End If00352
End If00353
00354
If maximo = True Then00355
n = Distancias ( i , k ) + Distancias ( k , j )00356
If Distancias ( i , j ) < n Then00357
Distancias ( i , j ) = n00358
Caminos ( i , j ) = Caminos ( k , j )00359
End If00360
End If00361
00362
End If00363
Next j00364
End If00365
If maximo = False Then00366
ciclo = ciclo Or ( Distancias ( i , i ) < 0 )00367
End If00368
If maximo = True Then00369
ciclo = ciclo Or ( Distancias ( i , i ) > 0 )00370
End If00371
Next i00372
00373
k = k + 100374
End While00375
00376
End Function00377
Function Ruta ( ByVal i As Long , ByVal j As Long , ByVal reset As Boolean ) As» String
00378
'Devuelve una cadena de texto con la ruta de i a j00379
00380
Static cadena As String00381
If reset = True Then cadena = ""00382
00383
If i = j Then00384
If cadena . Length > 0 Then cadena = cadena & ", "00385
cadena = cadena & Nodos ( i ) . Texto00386
Else00387
If Caminos ( i , j ) = - 1 Then00388
cadena = cadena & "no existe camino"00389
Return cadena00390
End If00391
00392
Ruta ( i , Caminos ( i , j ), False )00393
If cadena . Length > 0 Then cadena = cadena & ", "00394
cadena = cadena & Nodos ( j ) . Texto00395
Return cadena00396
00397
End If00398
00399
End Function00400
End Class