Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement first permissible or none strategy for node colouring. #35

Merged

Conversation

MHenderson
Copy link
Owner

Add function first_permissible_or_none_node(G, u) with tests. Tests currently failing.

===================================================== FAILURES =====================================================
_______________________________________ test_first_permissible_or_none_node ________________________________________

    def test_first_permissible_or_none_node():
        G = nx.complete_graph(3)
        permissible_dict = {0: [0, 1], 1: [1, 2], 2: [2, 3]}
        nx.set_node_attributes(G, permissible_dict, "permissible")
>       assert first_permissible_or_none_node(G, 0) == 0

tests/test_first-permissible-or-none-node.py:10:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
listcolouring/__init__.py:59: in first_permissible_or_none_node
    X = colours_on_neighbours(G, u)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

G = <networkx.classes.graph.Graph object at 0x7de7bd8d4920>, n = 0

    def colours_on_neighbours(G, n):
        """The set of all colours on neighbours of a node n in a graph G."""
>       return(set([nx.get_node_attributes(G, "colour")[m] for m in G.neighbors(n)]))
E       KeyError: 1

listcolouring/__init__.py:34: KeyError
============================================= short test summary info ==============================================
FAILED tests/test_first-permissible-or-none-node.py::test_first_permissible_or_none_node - KeyError: 1
=========================================== 1 failed, 3 passed in 0.18s ============================================
make: *** [Makefile:5: test] Error 1

@MHenderson MHenderson self-assigned this Nov 7, 2024
@MHenderson MHenderson linked an issue Nov 7, 2024 that may be closed by this pull request
nx.set_node_attributes(G, permissible_dict, "permissible")
assert first_permissible_or_none_node(G, 0) == 0
assert first_permissible_or_none_node(G, 1) == 1
assert first_permissible_or_node_node(G, 2) == 2
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name is wrong _node_node instead of _none_node.

@MHenderson
Copy link
Owner Author

This problem is caused by not having a colour attribute for nodes.

@MHenderson MHenderson marked this pull request as ready for review November 14, 2024 09:52
@MHenderson MHenderson merged commit b0ee9b7 into main Nov 14, 2024
2 checks passed
@MHenderson MHenderson deleted the 31-implement-first-permissible-colouring-strategy-for-nodes branch November 14, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement first permissible colouring strategy for nodes
1 participant