I'm working on modernizing Rosetta Code's infrastructure. Starting with communications. Please accept this time-limited open invite to RC's Slack.. --Michael Mol (talk) 20:59, 30 May 2020 (UTC)

Talk:Graph colouring

From Rosetta Code

Thanks for open source[edit]

I am investigating a few graph algorithms hence this task. The ASCII diagrams of graphs came from this Perl CPAN module:


Graphviz doesn't do ASCII output so would be difficult to add its output to RC.
--Paddy3118 (talk) 20:31, 10 March 2020 (UTC)

Any tougher problems?[edit]

Are there any ready-made problems knocking about which might (frinst) give exhaustive search pause for thought? --Pete Lomax (talk) 22:37, 14 March 2020 (UTC)

If you mean larger data sets you may take a look at here, I haven't tried yet but did take a peek at one sample and it seems ready to be used. Hope this helps. --Hkdtam (talk) 03:39, 15 March 2020 (UTC)
Hmm, 317,080 nodes and 1,049,866 edges (for the example you peeked at) is far more than I would ever have imagined... --Pete Lomax (talk)
317,080 nodes and 1,049,866 edges in 114 colours according to the Python prog. --Paddy3118 (talk) 10:00, 16 March 2020 (UTC)
amazon0601: Directed 403,394 nodes, 3,387,388 edges read in. Needed 11 colours.
Reading the gzip file needed the following changes to the class:
from gzip import open as gzopen
class Graph:
def __init__(self, fname, directed=False):
self.name = fname
g = self.graph = defaultdict(list) # maps vertex to direct connections
with (gzopen(fname, 'rt') if fname.endswith('.gz')
else open(fname)) as f:
edges = odd = 0
for n, line in enumerate(f, start=1):
ln = line.strip().split()
if ln[0].startswith('#'):
if len(ln) != 2:
odd +=1
n1, n2 = (int(x) for x in ln)
if not directed:
g[n2].append(n1) # Each the neighbour of the other
edges += 1
print(f"FILE {fname}:\n #Nodes: {len(g)}\n #Edges: {edges}")
print(f" #(Lines): {n}")
print(f" #(Odd): {odd}\n")
--Paddy3118 (talk) 11:42, 16 March 2020 (UTC)