-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement greedy node list colouring.
- Loading branch information
1 parent
b0ee9b7
commit dd9a3e0
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import networkx as nx | ||
|
||
import listcolouring | ||
from listcolouring import greedy_list_node_colouring | ||
|
||
def test_greedy_list_node_colouring(): | ||
G = nx.complete_graph(3) | ||
permissible_dict = {0: [0, 1], 1: [1, 2], 2: [2, 3]} | ||
nx.set_node_attributes(G, permissible_dict, "permissible") | ||
nx.set_node_attributes(G, None, "colour") | ||
G = greedy_list_node_colouring(G) | ||
assert G.nodes[0]["colour"] == 0 | ||
assert G.nodes[1]["colour"] == 1 | ||
assert G.nodes[2]["colour"] == 2 |