Current location - Education and Training Encyclopedia - Resume - Please write its adjacency matrix for undirected weighted graph: the following 1, and find its minimum spanning tree according to prim algorithm;
Please write its adjacency matrix for undirected weighted graph: the following 1, and find its minimum spanning tree according to prim algorithm;
1. adjacency matrix

A B C D E F G H

A 0 4 3-

B 4 0 5 5 9 - -

C 3 5 0 5 - - - 5

D - 5 5 0 7 6 5 4

e-9703--

F - - - 6 3 0 2

g---5206

H - - 5 4 - - 6 0

2. adjacency list

B.C.

A, China, Germany and Britain

C| A B D H

English, French, English, French and French.

Europe Britain

F| E D G

G| D F H

H| C D G

3.prim algorithm finds its minimum spanning tree.

Select the origin as.

1.A-C

2.A-B

|

C

3.A-B

|

C-D

4.A-B

|

C-D-H

5.A-B

|

C-D-H

|

G

7.A-B

|

C-D-H

|

G

|

Faying

Total distance: 26

4.Kruskar algorithm finds its minimum spanning tree.

1. English-French

2. English-French

A-C

3. English-French

A-C

D-H

4. English-French

D-H

B-A-C

5.B-A-C

G-D-H

English-French

6.B-A-C-H-D-G

English-French

7.B-A-C-H-D-G-F-E

Total distance: 26

I hope this helps.