|
| 1 | +Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32 |
| 2 | +Type "copyright", "credits" or "license()" for more information. |
| 3 | +>>> ================================ RESTART ================================ |
| 4 | +>>> |
| 5 | +enter the number of nodes in the graph |
| 6 | +10 |
| 7 | +enter the Node no:1's key |
| 8 | +a |
| 9 | +enter the Node no:2's key |
| 10 | +b |
| 11 | +enter the Node no:3's key |
| 12 | +c |
| 13 | +enter the Node no:4's key |
| 14 | +d |
| 15 | +enter the Node no:5's key |
| 16 | +e |
| 17 | +enter the Node no:6's key |
| 18 | +f |
| 19 | +enter the Node no:7's key |
| 20 | +g |
| 21 | +enter the Node no:8's key |
| 22 | +h |
| 23 | +enter the Node no:9's key |
| 24 | +i |
| 25 | +enter the Node no:10's key |
| 26 | +j |
| 27 | +enter the number of edges in the graph |
| 28 | +21 |
| 29 | +For the Edge no:1 |
| 30 | +of the 2 nodes involved in this edge |
| 31 | +enter the first Node's key |
| 32 | +a |
| 33 | + |
| 34 | +enter the second Node's key |
| 35 | +b |
| 36 | + |
| 37 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 38 | +9 |
| 39 | +For the Edge no:2 |
| 40 | +of the 2 nodes involved in this edge |
| 41 | +enter the first Node's key |
| 42 | +a |
| 43 | + |
| 44 | +enter the second Node's key |
| 45 | +c |
| 46 | + |
| 47 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 48 | +9 |
| 49 | +For the Edge no:3 |
| 50 | +of the 2 nodes involved in this edge |
| 51 | +enter the first Node's key |
| 52 | +a |
| 53 | + |
| 54 | +enter the second Node's key |
| 55 | +f |
| 56 | + |
| 57 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 58 | +8 |
| 59 | +For the Edge no:4 |
| 60 | +of the 2 nodes involved in this edge |
| 61 | +enter the first Node's key |
| 62 | +a |
| 63 | + |
| 64 | +enter the second Node's key |
| 65 | +j |
| 66 | + |
| 67 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 68 | +18 |
| 69 | +For the Edge no:5 |
| 70 | +of the 2 nodes involved in this edge |
| 71 | +enter the first Node's key |
| 72 | +b |
| 73 | + |
| 74 | +enter the second Node's key |
| 75 | +c |
| 76 | + |
| 77 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 78 | +3 |
| 79 | +For the Edge no:6 |
| 80 | +of the 2 nodes involved in this edge |
| 81 | +enter the first Node's key |
| 82 | +b |
| 83 | + |
| 84 | +enter the second Node's key |
| 85 | +e |
| 86 | + |
| 87 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 88 | +6 |
| 89 | +For the Edge no:7 |
| 90 | +of the 2 nodes involved in this edge |
| 91 | +enter the first Node's key |
| 92 | +c |
| 93 | + |
| 94 | +enter the second Node's key |
| 95 | +e |
| 96 | + |
| 97 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 98 | +4 |
| 99 | +For the Edge no:8 |
| 100 | +of the 2 nodes involved in this edge |
| 101 | +enter the first Node's key |
| 102 | +c |
| 103 | + |
| 104 | +enter the second Node's key |
| 105 | +d |
| 106 | + |
| 107 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 108 | +2 |
| 109 | +For the Edge no:9 |
| 110 | +of the 2 nodes involved in this edge |
| 111 | +enter the first Node's key |
| 112 | +c |
| 113 | + |
| 114 | +enter the second Node's key |
| 115 | +f |
| 116 | + |
| 117 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 118 | +9 |
| 119 | +For the Edge no:10 |
| 120 | +of the 2 nodes involved in this edge |
| 121 | +enter the first Node's key |
| 122 | +d |
| 123 | + |
| 124 | +enter the second Node's key |
| 125 | +e |
| 126 | + |
| 127 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 128 | +2 |
| 129 | +For the Edge no:11 |
| 130 | +of the 2 nodes involved in this edge |
| 131 | +enter the first Node's key |
| 132 | +d |
| 133 | + |
| 134 | +enter the second Node's key |
| 135 | +f |
| 136 | + |
| 137 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 138 | +8 |
| 139 | +For the Edge no:12 |
| 140 | +of the 2 nodes involved in this edge |
| 141 | +enter the first Node's key |
| 142 | +d |
| 143 | + |
| 144 | +enter the second Node's key |
| 145 | +g |
| 146 | + |
| 147 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 148 | +9 |
| 149 | +For the Edge no:13 |
| 150 | +of the 2 nodes involved in this edge |
| 151 | +enter the first Node's key |
| 152 | +e |
| 153 | + |
| 154 | +enter the second Node's key |
| 155 | +g |
| 156 | + |
| 157 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 158 | +9 |
| 159 | +For the Edge no:14 |
| 160 | +of the 2 nodes involved in this edge |
| 161 | +enter the first Node's key |
| 162 | +f |
| 163 | + |
| 164 | +enter the second Node's key |
| 165 | +g |
| 166 | + |
| 167 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 168 | +7 |
| 169 | +For the Edge no:15 |
| 170 | +of the 2 nodes involved in this edge |
| 171 | +enter the first Node's key |
| 172 | +f |
| 173 | + |
| 174 | +enter the second Node's key |
| 175 | +i |
| 176 | + |
| 177 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 178 | +9 |
| 179 | +For the Edge no:16 |
| 180 | +of the 2 nodes involved in this edge |
| 181 | +enter the first Node's key |
| 182 | +f |
| 183 | + |
| 184 | +enter the second Node's key |
| 185 | +j |
| 186 | + |
| 187 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 188 | +10 |
| 189 | +For the Edge no:17 |
| 190 | +of the 2 nodes involved in this edge |
| 191 | +enter the first Node's key |
| 192 | +g |
| 193 | + |
| 194 | +enter the second Node's key |
| 195 | +i |
| 196 | + |
| 197 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 198 | +5 |
| 199 | +For the Edge no:18 |
| 200 | +of the 2 nodes involved in this edge |
| 201 | +enter the first Node's key |
| 202 | +g |
| 203 | + |
| 204 | +enter the second Node's key |
| 205 | +h |
| 206 | + |
| 207 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 208 | +4 |
| 209 | +For the Edge no:19 |
| 210 | +of the 2 nodes involved in this edge |
| 211 | +enter the first Node's key |
| 212 | +h |
| 213 | + |
| 214 | +enter the second Node's key |
| 215 | +i |
| 216 | + |
| 217 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 218 | +1 |
| 219 | +For the Edge no:20 |
| 220 | +of the 2 nodes involved in this edge |
| 221 | +enter the first Node's key |
| 222 | +h |
| 223 | + |
| 224 | +enter the second Node's key |
| 225 | +j |
| 226 | + |
| 227 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 228 | +4 |
| 229 | +For the Edge no:21 |
| 230 | +of the 2 nodes involved in this edge |
| 231 | +enter the first Node's key |
| 232 | +i |
| 233 | + |
| 234 | +enter the second Node's key |
| 235 | +j |
| 236 | + |
| 237 | +enter the cost (or weight) of this edge (or arc) - an integer |
| 238 | +3 |
| 239 | +enter the maximum weight possible for any of edges in the graph |
| 240 | +20 |
| 241 | + |
| 242 | +The edges with thier unsorted weights are |
| 243 | +{('g', 'e'): [9], ('b', 'c'): [3], ('e', 'd'): [2], ('h', 'i'): [1], ('d', 'e'): [2], ('i', 'h'): [1], ('f', 'd'): [8], ('c', 'b'): [3], ('e', 'c'): [4], ('a', 'b'): [9], ('g', 'd'): [9], ('c', 'f'): [9], ('f', 'a'): [8], ('e', 'g'): [9], ('d', 'f'): [8], ('d', 'g'): [9], ('c', 'a'): [9], ('h', 'j'): [4], ('e', 'b'): [6], ('i', 'g'): [5], ('d', 'c'): [2], ('c', 'e'): [4], ('g', 'h'): [4], ('b', 'a'): [9], ('i', 'j'): [3], ('j', 'h'): [4], ('a', 'f'): [8], ('j', 'a'): [18], ('i', 'f'): [9], ('f', 'j'): [10], ('c', 'd'): [2], ('h', 'g'): [4], ('f', 'c'): [9], ('g', 'i'): [5], ('j', 'f'): [10], ('g', 'f'): [7], ('j', 'i'): [3], ('b', 'e'): [6], ('f', 'g'): [7], ('a', 'c'): [9], ('a', 'j'): [18], ('f', 'i'): [9]} |
| 244 | + |
| 245 | +After sorting |
| 246 | +[(('h', 'i'), [1]), (('i', 'h'), [1]), (('e', 'd'), [2]), (('d', 'e'), [2]), (('d', 'c'), [2]), (('c', 'd'), [2]), (('b', 'c'), [3]), (('c', 'b'), [3]), (('i', 'j'), [3]), (('j', 'i'), [3]), (('e', 'c'), [4]), (('h', 'j'), [4]), (('c', 'e'), [4]), (('g', 'h'), [4]), (('j', 'h'), [4]), (('h', 'g'), [4]), (('i', 'g'), [5]), (('g', 'i'), [5]), (('e', 'b'), [6]), (('b', 'e'), [6]), (('g', 'f'), [7]), (('f', 'g'), [7]), (('f', 'd'), [8]), (('f', 'a'), [8]), (('d', 'f'), [8]), (('a', 'f'), [8]), (('g', 'e'), [9]), (('a', 'b'), [9]), (('g', 'd'), [9]), (('c', 'f'), [9]), (('e', 'g'), [9]), (('d', 'g'), [9]), (('c', 'a'), [9]), (('b', 'a'), [9]), (('i', 'f'), [9]), (('f', 'c'), [9]), (('a', 'c'), [9]), (('f', 'i'), [9]), (('f', 'j'), [10]), (('j', 'f'), [10]), (('j', 'a'), [18]), (('a', 'j'), [18])] |
| 247 | + |
| 248 | + |
| 249 | +In the graph with these vertex's |
| 250 | +['a', 'c', 'b', 'e', 'd', 'g', 'f', 'i', 'h', 'j'] |
| 251 | + |
| 252 | + With these edges between the vertexes given above, we obtain a Minimal Spanning Tree |
| 253 | + |
| 254 | +{('b', 'c'): [3], ('g', 'f'): [7], ('e', 'd'): [2], ('h', 'i'): [1], ('g', 'h'): [4], ('f', 'd'): [8], ('f', 'a'): [8], ('d', 'c'): [2], ('i', 'j'): [3]} |
| 255 | + |
| 256 | + Please note this is a dictionary with key as the weight of the edge and value as the key's of the two vertex's involved in this edge |
| 257 | +>>> |
0 commit comments