Graph colouring: Difference between revisions

(Add Ex4)
Line 214:
('Ex2', "1-6 1-7 1-8 2-5 2-7 2-8 3-5 3-6 3-8 4-5 4-6 4-7"),
('Ex3', "1-4 1-6 1-8 3-2 3-6 3-8 5-2 5-4 5-8 7-2 7-4 7-6"),
('Ex4', "1-6 7-1 8-1 5-2 2-7 2-8 3-5 6-3 3-8 4-5 4-6 4-7"),
]:
g = Graph(name, connections)
Line 260 ⟶ 261:
#Nodes: 8
#Edges: 12
#Colours: 2</pre>
 
Ex4
1-6: Colour: 0, 1
1-7: Colour: 0, 1
1-8: Colour: 0, 1
2-5: Colour: 2, 0
2-7: Colour: 2, 1
2-8: Colour: 2, 1
3-5: Colour: 2, 0
3-6: Colour: 2, 1
3-8: Colour: 2, 1
4-5: Colour: 2, 0
4-6: Colour: 2, 1
4-7: Colour: 2, 1
#Nodes: 8
#Edges: 12
#Colours: 3</pre>
 
Python dicts preserve insertion order and Ex2/Ex3 edges are traced in a similar way which could be the cause of exactly the same colours used for Ex2 and Ex3. The wp article must use an earlier version of Python/different ordering of edge definitions.
 
Ex4 changes the order of nodes enough to affect the number of colours used.
Anonymous user