GithubHelp home page GithubHelp logo

mhenderson / listcolouring Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 115 KB

List colouring in Python with NetworkX.

Home Page: https://listcolouring.readthedocs.io/en/latest/

License: MIT License

Python 95.40% Makefile 4.60%
graph-colouring graphs networkx python

listcolouring's Introduction

listcolouring

List colouring in Python with NetworkX.

import networkx as nx
import matplotlib.pyplot as plt

import listcolouring
from listcolouring import list_init, greedy_list_edge_colouring, print_list_edge_colouring

G = nx.petersen_graph()

G = list_init(G, range(0, 10), 3, 0)
G = greedy_list_edge_colouring(G)
    
options = {'with_labels': True, 'node_color': "white"}
colors = nx.get_edge_attributes(G,'colour').values()
nx.draw_shell(G, nlist = [range(5, 10), range(5)], edge_color = colors, **options)

plt.savefig("img/petersen-shell.png", format = "PNG"

listcolouring's People

Contributors

mhenderson avatar

Watchers

 avatar

listcolouring's Issues

old code

import networkx as nx

G = nx.petersen_graph()

d = nx.coloring.greedy_color(G, strategy="largest_first")

print(G.nodes)
print(G.edges)

G[0][1]["colour"] = 4

print(G[0][1])
print(G[0])

print(d)

G[0][1]["permissible"] = {1, 2, 3}
print(G[0][1])

print(G[0][1]["colour"] in G[0][1]["permissible"])

GL = nx.line_graph(G)

print(GL)

print(nx.inverse_line_graph(GL))

print(GL.nodes)
print(GL.edges)`

Add docstrings.

Turn existing comments into docstrings and add docstring for other functions.

Lists have a fixed size of 3.

There's two aspects to this issue.

One is just that 3 is hard-coded when generating a random list assignment.

But we would also like to have lists of various sizes.

Allow partial colourings.

At least it probably should be the case that the main loop iterates over only those edges with a colour of None. That way we can attempt to greedily finish colouring a partially coloured graph.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.