Digraph+Games

I want to produce a randomly-constructed fully-connected undirected graph. My method adds an edge at random, then tests if everything is connected yet. For visibility, working results get dumped out on the Transcript. Code and operation will be demonstrated in class 2011.11.4

I wanted to capture this "lucky" result as I can't count on reproducing it. code (The first 46 checks looked just like this) -- edgeCount=46 allConnected? attached 1: O @O <<<< 0: <<<< unvisited 25: ABCDEFGHIJKLMNPQRSTUVWXYZ aNode edges isEmpty

-- edgeCount=47 allConnected? attached 1: O @O <<<< 0: <<<< unvisited 25: ABCDEFGHIJKLMNPQRSTUVWXYZ attached 2: OR @R <<<< 0: <<<< unvisited 24: ABCDEFGHIJKLMNPQSTUVWXYZ attached 7: IORSTWX @X <<<< 4: ISTW <<<< unvisited 19: ABCDEFGHJKLMNPQUVYZ attached 9: ILMORSTWX @I <<<< 5: LMSTW <<<< unvisited 17: ABCDEFGHJKNPQUVYZ attached 14: BEHIKLMORSTUWX @L <<<< 9: BEHKMSTUW <<<< unvisited 12: ACDFGJNPQVYZ attached 15: BEHIJKLMORSTUWX @W <<<< 9: BEHJKMSTU <<<< unvisited 11: ACDFGNPQVYZ attached 18: BEGHIJKLMNOPRSTUWX @N <<<< 11: BEGHJKMPSTU <<<< unvisited 8: ACDFQVYZ attached 20: BCEFGHIJKLMNOPRSTUWX @E <<<< 12: BCFGHJKMPSTU <<<< unvisited 6: ADQVYZ attached 20: BCEFGHIJKLMNOPRSTUWX @H <<<< 11: BCFGJKMPSTU <<<< unvisited 6: ADQVYZ attached 21: BCDEFGHIJKLMNOPRSTUWX @D <<<< 11: BCFGJKMPSTU <<<< unvisited 5: AQVYZ attached 22: BCDEFGHIJKLMNOPRSTUVWX @S <<<< 11: BCFGJKMPTUV <<<< unvisited 4: AQYZ attached 23: BCDEFGHIJKLMNOPQRSTUVWX @M <<<< 11: BCFGJKPQTUV <<<< unvisited 3: AYZ attached 24: ABCDEFGHIJKLMNOPQRSTUVWX @A <<<< 11: BCFGJKPQTUV <<<< unvisited 2: YZ attached 24: ABCDEFGHIJKLMNOPQRSTUVWX @P <<<< 10: BCFGJKQTUV <<<< unvisited 2: YZ attached 24: ABCDEFGHIJKLMNOPQRSTUVWX @Q <<<< 9: BCFGJKTUV <<<< unvisited 2: YZ attached 24: ABCDEFGHIJKLMNOPQRSTUVWX @B <<<< 8: CFGJKTUV <<<< unvisited 2: YZ attached 25: ABCDEFGHIJKLMNOPQRSTUVWXY @Y <<<< 8: CFGJKTUV <<<< unvisited 1: Z attached 25: ABCDEFGHIJKLMNOPQRSTUVWXY @G <<<< 7: CFJKTUV <<<< unvisited 1: Z attached 26: ABCDEFGHIJKLMNOPQRSTUVWXYZ @Z <<<< 7: CFJKTUV <<<< unvisited 0: attached 26: ABCDEFGHIJKLMNOPQRSTUVWXYZ @T <<<< 6: CFJKUV <<<< unvisited 0: attached 26: ABCDEFGHIJKLMNOPQRSTUVWXYZ @U <<<< 5: CFJKV <<<< unvisited 0: attached 26: ABCDEFGHIJKLMNOPQRSTUVWXYZ @V <<<< 4: CFJK <<<< unvisited 0: attached 26: ABCDEFGHIJKLMNOPQRSTUVWXYZ @C <<<< 3: FJK <<<< unvisited 0: attached 26: ABCDEFGHIJKLMNOPQRSTUVWXYZ @F <<<< 2: JK <<<< unvisited 0: attached 26: ABCDEFGHIJKLMNOPQRSTUVWXYZ @J <<<< 1: K <<<< unvisited 0: attached 26: ABCDEFGHIJKLMNOPQRSTUVWXYZ @K <<<< 0: <<<< unvisited 0: allConnected: true -- edgeCount=47

code Squeak code shown in class on Friday is here: You may study it, laugh at it, or load into your own Squeak image.

Using a different check for connectedness which prints the partitions as they merge: code +++ @V<->@S 2 #1    {(A)(B)(C)(D)(E)(F)(G)(H)(I)(J)(K)(L)(M)(N)(O)(P)(Q)(R)(SV)(T)(U)(W)(X)(Y)(Z)} +++ @Q<->@T 8 #2    {(A)(B)(C)(D)(E)(F)(G)(H)(I)(J)(K)(L)(M)(N)(O)(P)(QT)(R)(SV)(U)(W)(X)(Y)(Z)} +++ @J<->@E 18 #3    {(A)(B)(C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)} +++ @S<->@N 14 #16    {(AIPQTY)(B)(CEJRUW)(D)(FMZ)(G)(H)(K)(L)(NSV)(O)(X)} +++ @W<->@X 28 #17    {(AIPQTY)(B)(CEJRUWX)(D)(FMZ)(G)(H)(K)(L)(NSV)(O)} +++ @D<->@B 6 #18    {(AIPQTY)(BD)(CEJRUWX)(FMZ)(G)(H)(K)(L)(NSV)(O)} +++ @O<->@Q 29 #19    {(AIOPQTY)(BD)(CEJRUWX)(FMZ)(G)(H)(K)(L)(NSV)} +++ @R<->@M 42 #20    {(AIOPQTY)(BD)(CEFJMRUWXZ)(G)(H)(K)(L)(NSV)} +++ @Y<->@A 15 #21    {(AIOPQTY)(BD)(CEFJMRUWXZ)(G)(H)(K)(L)(NSV)} +++ @N<->@V 51 #22    {(AIOPQTY)(BD)(CEFJMRUWXZ)(G)(H)(K)(L)(NSV)} +++ @W<->@N 42 #23    {(AIOPQTY)(BD)(CEFJMNRSUVWXZ)(G)(H)(K)(L)} +++ @Z<->@O 49 #24    {(ACEFIJMNOPQRSTUVWXYZ)(BD)(G)(H)(K)(L)} +++ @C<->@H 29 #25    {(ACEFHIJMNOPQRSTUVWXYZ)(BD)(G)(K)(L)} +++ @P<->@I 39 #26    {(ACEFHIJMNOPQRSTUVWXYZ)(BD)(G)(K)(L)} +++ @O<->@L 17 #27    {(ACEFHIJLMNOPQRSTUVWXYZ)(BD)(G)(K)} +++ @I<->@U 43 #28    {(ACEFHIJLMNOPQRSTUVWXYZ)(BD)(G)(K)} +++ @L<->@P 10 #29    {(ACEFHIJLMNOPQRSTUVWXYZ)(BD)(G)(K)} +++ @Y<->@G 6 #30    {(ACEFGHIJLMNOPQRSTUVWXYZ)(BD)(K)} +++ @C<->@N 2 #31    {(ACEFGHIJLMNOPQRSTUVWXYZ)(BD)(K)} +++ @T<->@V 16 #32    {(ACEFGHIJLMNOPQRSTUVWXYZ)(BD)(K)} +++ @J<->@G 9 #33    {(ACEFGHIJLMNOPQRSTUVWXYZ)(BD)(K)} +++ @B<->@W 32 #34    {(ABCDEFGHIJLMNOPQRSTUVWXYZ)(K)} +++ @K<->@Z 28 #35    {(ABCDEFGHIJKLMNOPQRSTUVWXYZ)}-- edgeCount=35

@A @Y<->@A 15 @Y<->@A 21 @T<->@A 43 @A<->@I 48 @B @D<->@B 6 @B<->@W 32 @C @C<->@N 2 @C<->@H 29 @U<->@C 30 @C<->@J 38 @C<->@W 51 @D @D<->@B 6 @E @J<->@E 15 @J<->@E 18 @W<->@E 39 @F @F<->@M 5 @Z<->@F 32 @G @Y<->@G 6 @J<->@G 9 @H @C<->@H 29 @I @P<->@I 39 @I<->@U 43 @A<->@I 48 @J @J<->@G 9 @J<->@E 15 @J<->@E 18 @C<->@J 38 @K @K<->@Z 28 @L @L<->@P 10 @O<->@L 17 @M @F<->@M 5 @R<->@M 42 @N @C<->@N 2 @S<->@N 14 @W<->@N 42 @N<->@V 51 @O @O<->@L 17 @O<->@Q 29 @Z<->@O 49 @P @L<->@P 10 @T<->@P 14 @P<->@I 39 @Q @Q<->@T 8 @O<->@Q 29 @R @W<->@R 41 @R<->@M 42 @S @V<->@S 2 @S<->@N 14 @T @Q<->@T 8 @T<->@P 14 @T<->@V 16 @T<->@A 43 @U @U<->@C 30 @I<->@U 43 @V @V<->@S 2 @T<->@V 16 @N<->@V 51 @W @W<->@X 28 @B<->@W 32 @W<->@E 39 @W<->@R 41 @W<->@N 42 @C<->@W 51 @X @W<->@X 28 @Y @Y<->@G 6 @Y<->@A 15 @Y<->@A 21 @Z @K<->@Z 28 @Z<->@F 32 @Z<->@O 49

MinimalSpanningTree uses these edges: 1: @C<->@N 2 2: @V<->@S 2 3: @F<->@M 5 4: @D<->@B 6 5: @Y<->@G 6 6: @Q<->@T 8 7: @J<->@G 9 8: @L<->@P 10 9: @S<->@N 14 10: @T<->@P 14 11: @J<->@E 15 12: @Y<->@A 15 13: @T<->@V 16 14: @O<->@L 17 15: @W<->@X 28 16: @K<->@Z 28 17: @C<->@H 29 18: @U<->@C 30 19: @B<->@W 32 20: @Z<->@F 32 21: @C<->@J 38 22: @P<->@I 39 23: @W<->@E 39 24: @W<->@R 41 25: @R<->@M 42

code Here is the changed code needed to show that instead:

The minimum number of edges which can connect 26 lattered nodes is 25. It is unlimited on the top. But here are a few values from experimental adding edges until it is completely connected: code -- edgeCount=45 -- edgeCount=45 -- edgeCount=52 -- edgeCount=56 -- edgeCount=55 -- edgeCount=41 -- edgeCount=63 -- edgeCount=30 -- edgeCount=65 -- edgeCount=33 -- edgeCount=35 -- edgeCount=35 -- edgeCount=53 -- edgeCount=42 -- edgeCount=38 -- edgeCount=77 -- edgeCount=43 -- edgeCount=70 -- edgeCount=44 -- edgeCount=34 -- edgeCount=40 -- edgeCount=81 -- edgeCount=43 -- edgeCount=46 -- edgeCount=54 -- edgeCount=43 -- edgeCount=38 -- edgeCount=31 -- edgeCount=37 -- edgeCount=42 -- edgeCount=45 -- edgeCount=47 -- edgeCount=46 -- edgeCount=61 -- edgeCount=52 -- edgeCount=47 -- edgeCount=59 -- edgeCount=28 -- edgeCount=81 -- edgeCount=78 -- edgeCount=68 -- edgeCount=40

code code

134 : 134 133 : 132 : 131 : 130 : 129 : 128 : 127 : 126 : 125 : 124 : 123 : 122 : 121 : 120 : 119 : 118 : 117 : 117 116 : 115 : 115 114 : 113 : 113 112 : 111 : 110 : 109 : 108 : 108 107 : 106 : 106 106 106 105 : 104 : 104 103 : 102 : 101 : 100 : 99 : 98 : 98 97 : 96 : 96 95 : 95 95 94 : 93 : 93 92 : 92 91 : 91 91 90 : 90 90 89 : 89 88 : 87 : 87 87 86 : 86 86 86 85 : 85 84 : 84 84 84 83 : 83 83 83 83 83 82 : 82 82 82 82 82 81 : 81 81 81 81 80 : 80 80 80 79 : 79 79 79 79 78 : 78 78 78 78 78 78 78 77 : 77 77 77 77 77 77 76 : 76 76 76 76 75 : 75 75 74 : 74 74 74 74 73 : 73 73 73 73 73 73 73 73 72 : 72 72 72 72 72 71 : 71 71 71 70 : 70 70 70 70 70 70 70 70 69 : 69 69 69 69 69 69 69 69 68 : 68 68 68 68 68 68 68 68 68 68 68 67 : 67 67 67 67 67 67 67 67 67 67 67 67 66 : 66 66 66 66 66 66 66 66 66 66 65 : 65 65 65 65 65 65 65 65 65 64 : 64 64 64 64 64 64 64 64 64 64 64 64 64 63 : 63 63 63 63 63 63 63 63 63 63 63 63 62 : 62 62 62 62 62 62 62 62 62 62 62 62 62 62 61 : 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 60 : 60 60 60 60 60 60 60 60 60 60 60 59 : 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 59 58 : 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 57 : 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 56 : 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 55 : 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 54 : 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 53 : 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 53 52 : 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 51 : 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 50 : 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 49 : 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 48 : 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 47 : 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 46 : 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 45 : 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 44 : 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 43 : 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 42 : 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 41 : 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 40 : 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 39 : 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 38 : 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 37 : 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 36 : 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 35 : 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 34 : 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 33 : 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 32 : 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 31 : 31 31 31 31 31 31 31 31 31 31 31 31 31 30 : 30 30 30 30 30 30 30 30 30 30 30 30 30 30 29 : 29 29 29 29 29 29 29 29 29 28 : 28 28 28 28 28 27 : 27 27 27 26 : 25 : 25 count: 1000   avg: 50.204    median: 47.0

code