Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/vizing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import constraint as ct
import networkx as nx

def node_list_colouring_problem(G):
"""
Expand All @@ -22,9 +23,7 @@ def node_list_colouring_solution(G):
:return A properly list-coloured graph.
"""
P = node_list_colouring_problem(G)
S = P.getSolution()
for node in S:
G.nodes[node]['colour'] = S[node]
nx.set_node_attributes(G, P.getSolution(), name = 'colour')
return(G)

def edge_list_colouring_problem(G, directed = False):
Expand Down Expand Up @@ -56,9 +55,7 @@ def edge_list_colouring_solution(G, directed = False):
:return A properly edge list-coloured graph.
"""
P = edge_list_colouring_problem(G, directed)
S = P.getSolution()
for edge in G.edges():
G.edges()[edge]['colour'] = S[edge]
nx.set_edge_attributes(G, P.getSolution(), 'colour')
return(G)

def total_list_colouring_problem(G):
Expand Down