⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 自己编的
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Minimuum Spanning Tree"
   ClientHeight    =   6135
   ClientLeft      =   60
   ClientTop       =   465
   ClientWidth     =   10200
   LinkTopic       =   "Form1"
   ScaleHeight     =   6135
   ScaleWidth      =   10200
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command_Generate 
      Caption         =   "Generate Tree"
      Enabled         =   0   'False
      Height          =   495
      Left            =   7200
      TabIndex        =   0
      Top             =   2520
      Width           =   1815
   End
   Begin VB.CommandButton Command_change 
      Caption         =   "change the weight"
      Height          =   495
      Left            =   7200
      TabIndex        =   18
      Top             =   1560
      Width           =   1815
   End
   Begin VB.PictureBox Picture1 
      Height          =   4455
      Left            =   720
      ScaleHeight     =   4395
      ScaleWidth      =   5715
      TabIndex        =   1
      Top             =   600
      Width           =   5775
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   15
         Left            =   1800
         TabIndex        =   11
         Tag             =   "51"
         Top             =   960
         Width           =   90
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   12
         Left            =   3480
         TabIndex        =   10
         Tag             =   "21"
         Top             =   960
         Width           =   90
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   16
         Left            =   2640
         TabIndex        =   9
         Tag             =   "61"
         Top             =   1320
         Width           =   90
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   34
         Left            =   2760
         TabIndex        =   8
         Tag             =   "43"
         Top             =   3360
         Width           =   90
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   36
         Left            =   3360
         TabIndex        =   7
         Tag             =   "63"
         Top             =   2640
         Width           =   90
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   46
         Left            =   2160
         TabIndex        =   6
         Tag             =   "64"
         Top             =   2640
         Width           =   90
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   45
         Left            =   1320
         TabIndex        =   5
         Tag             =   "54"
         Top             =   2400
         Width           =   90
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   56
         Left            =   1920
         TabIndex        =   4
         Tag             =   "65"
         Top             =   1800
         Width           =   90
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   26
         Left            =   3480
         TabIndex        =   3
         Tag             =   "62"
         Top             =   1680
         Width           =   90
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "0"
         Height          =   180
         Index           =   23
         Left            =   4080
         TabIndex        =   2
         Tag             =   "32"
         Top             =   2280
         Width           =   90
      End
      Begin VB.Label Label12 
         Alignment       =   2  'Center
         AutoSize        =   -1  'True
         Caption         =   "A"
         Height          =   180
         Index           =   1
         Left            =   2655
         TabIndex        =   12
         Top             =   600
         Width           =   105
      End
      Begin VB.Shape Shape6 
         Height          =   375
         Left            =   2520
         Shape           =   3  'Circle
         Top             =   480
         Width           =   375
      End
      Begin VB.Shape Shape1 
         Height          =   375
         Left            =   4200
         Shape           =   3  'Circle
         Top             =   1440
         Width           =   375
      End
      Begin VB.Label Label10 
         Alignment       =   2  'Center
         AutoSize        =   -1  'True
         Caption         =   "B"
         Height          =   180
         Index           =   2
         Left            =   4335
         TabIndex        =   14
         Top             =   1560
         Width           =   105
      End
      Begin VB.Shape Shape3 
         Height          =   375
         Left            =   1440
         Shape           =   3  'Circle
         Top             =   3240
         Width           =   375
      End
      Begin VB.Shape Shape2 
         Height          =   375
         Left            =   960
         Shape           =   3  'Circle
         Top             =   1440
         Width           =   375
      End
      Begin VB.Shape Shape4 
         Height          =   375
         Left            =   3720
         Shape           =   3  'Circle
         Top             =   3240
         Width           =   375
      End
      Begin VB.Shape Shape5 
         Height          =   375
         Left            =   2640
         Shape           =   3  'Circle
         Top             =   1920
         Width           =   375
      End
      Begin VB.Line Line1 
         Index           =   34
         Tag             =   "43"
         X1              =   3720
         X2              =   1800
         Y1              =   3480
         Y2              =   3480
      End
      Begin VB.Line Line1 
         Index           =   46
         Tag             =   "64"
         X1              =   1680
         X2              =   2640
         Y1              =   3240
         Y2              =   2160
      End
      Begin VB.Line Line1 
         Index           =   45
         Tag             =   "54"
         X1              =   1560
         X2              =   1200
         Y1              =   3240
         Y2              =   1800
      End
      Begin VB.Line Line1 
         Index           =   15
         Tag             =   "51"
         X1              =   1200
         X2              =   2520
         Y1              =   1440
         Y2              =   720
      End
      Begin VB.Line Line1 
         Index           =   16
         Tag             =   "61"
         X1              =   2760
         X2              =   2760
         Y1              =   1920
         Y2              =   840
      End
      Begin VB.Line Line1 
         Index           =   12
         Tag             =   "21"
         X1              =   4200
         X2              =   2880
         Y1              =   1440
         Y2              =   720
      End
      Begin VB.Line Line1 
         Index           =   36
         Tag             =   "63"
         X1              =   3840
         X2              =   3000
         Y1              =   3240
         Y2              =   2160
      End
      Begin VB.Line Line1 
         Index           =   56
         Tag             =   "65"
         X1              =   1320
         X2              =   2640
         Y1              =   1680
         Y2              =   2040
      End
      Begin VB.Line Line1 
         Index           =   26
         Tag             =   "62"
         X1              =   3000
         X2              =   4200
         Y1              =   2040
         Y2              =   1680
      End
      Begin VB.Label Label7 
         Alignment       =   2  'Center
         AutoSize        =   -1  'True
         Caption         =   "E"
         Height          =   180
         Index           =   5
         Left            =   1095
         TabIndex        =   17
         Top             =   1560
         Width           =   105
      End
      Begin VB.Label Label8 
         Alignment       =   2  'Center
         AutoSize        =   -1  'True
         Caption         =   "D"
         Height          =   180
         Index           =   4
         Left            =   1575
         TabIndex        =   16
         Top             =   3360
         Width           =   105
      End
      Begin VB.Label Label9 
         Alignment       =   2  'Center
         AutoSize        =   -1  'True
         Caption         =   "C"
         Height          =   180
         Index           =   3
         Left            =   3855
         TabIndex        =   15
         Top             =   3360
         Width           =   105
      End
      Begin VB.Label Label11 
         Alignment       =   2  'Center
         AutoSize        =   -1  'True
         Caption         =   "F"
         Height          =   180
         Index           =   6
         Left            =   2775
         TabIndex        =   13
         Top             =   2040
         Width           =   105
      End
      Begin VB.Line Line1 
         Index           =   23
         Tag             =   "32"
         X1              =   3960
         X2              =   4320
         Y1              =   3240
         Y2              =   1800
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Dim i, j, k, n, min As Integer
Dim Graph(1 To 6, 1 To 6) As Integer
Dim lowcost(6), closest(6) As Integer

Private Sub Command_change_Click()

For i = 1 To 6
    For j = 1 To 6
        Graph(i, j) = 100
    Next j
Next i


Graph(1, 2) = Int(Rnd(Rnd) * 10 + 1)
Graph(2, 1) = Graph(1, 2)
Label13(12).Caption = Graph(1, 2)
Line1(12).BorderColor = &H80000008
Line1(12).BorderWidth = 1
Graph(1, 6) = Int(Rnd(Rnd) * 10 + 1)
Graph(6, 1) = Graph(1, 6)
Label13(16).Caption = Graph(1, 6)
Line1(16).BorderColor = &H80000008
Line1(16).BorderWidth = 1
Graph(1, 5) = Int(Rnd(Rnd) * 10 + 1)
Graph(5, 1) = Graph(1, 5)
Label13(15).Caption = Graph(1, 5)
Line1(15).BorderColor = &H80000008
Line1(15).BorderWidth = 1
Graph(3, 2) = Int(Rnd(Rnd) * 10 + 1)
Graph(2, 3) = Graph(3, 2)
Label13(23).Caption = Graph(3, 2)
Line1(23).BorderColor = &H80000008
Line1(23).BorderWidth = 1
Graph(6, 2) = Int(Rnd(Rnd) * 10 + 1)
Graph(2, 6) = Graph(6, 2)
Label13(26).Caption = Graph(6, 2)
Line1(26).BorderColor = &H80000008
Line1(26).BorderWidth = 1
Graph(3, 4) = Int(Rnd(Rnd) * 10 + 1)
Graph(4, 3) = Graph(3, 4)
Label13(34).Caption = Graph(3, 4)
Line1(34).BorderColor = &H80000008
Line1(34).BorderWidth = 1
Graph(3, 6) = Int(Rnd(Rnd) * 10 + 1)
Graph(6, 3) = Graph(3, 6)
Label13(36).Caption = Graph(3, 6)
Line1(36).BorderColor = &H80000008
Line1(36).BorderWidth = 1
Graph(6, 4) = Int(Rnd(Rnd) * 10 + 1)
Graph(4, 6) = Graph(6, 4)
Label13(46).Caption = Graph(6, 4)
Line1(46).BorderColor = &H80000008
Line1(46).BorderWidth = 1
Graph(5, 4) = Int(Rnd(Rnd) * 10 + 1)
Graph(4, 5) = Graph(5, 4)
Label13(45).Caption = Graph(5, 4)
Line1(45).BorderColor = &H80000008
Line1(45).BorderWidth = 1
Graph(5, 6) = Int(Rnd(Rnd) * 10 + 1)
Graph(6, 5) = Graph(5, 6)
Label13(56).Caption = Graph(5, 6)
Line1(56).BorderColor = &H80000008
Line1(56).BorderWidth = 1
    n = 6
    For i = 2 To n
        lowcost(i) = Graph(1, i)
        closest(i) = 1
    Next i
    lowcost(1) = 0
Command_Generate.Enabled = True
End Sub

Private Sub Command_Generate_Click()
    For i = 2 To n
        min = 1000
        k = 0
        For j = 2 To n
            If ((lowcost(j) < min) And (lowcost(j) <> 0)) Then
                min = lowcost(j)
                k = j
            End If
        Next j

        If k > closest(k) Then
            Line1(closest(k) * 10 + k).BorderColor = &HFF&
            Line1(closest(k) * 10 + k).BorderWidth = 2
        Else
            Line1(k * 10 + closest(k)).BorderColor = &HFF&
            Line1(k * 10 + closest(k)).BorderWidth = 2
        End If
        lowcost(k) = 0
        
        For j = 2 To n
            If (Graph(k, j) < lowcost(j)) Then
        
                lowcost(j) = Graph(k, j)
                closest(j) = k
            End If
        Next j
    Next i
Command_Generate.Enabled = False
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -