First time here? Check out the FAQ!

Ask Your Question
1

chromatic polynomial graph with loops

asked 5 years ago

luis gravatar image

updated 2 years ago

tmonteil gravatar image

Since there are no proper colorings of graphs with loops, their chromatic polynomial should be zero.

SageMath 8.6 however seems to ignore the loops and returns a nonzero chromatic polynomial for the graph on one vertex with one loop edge.

sage: Graph([[1, 1]], multiedges=True, loops=True).chromatic_polynomial()
x
Preview: (hide)

Comments

This indeed looks like a bug. Thanks for reporting!

Would you like to open a ticket for it on the Sage Trac server?

Would you like to suggest a fix? The relevant file is

(If not, I can take care of it.)

slelievre gravatar imageslelievre ( 5 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

slelievre gravatar image

This indeed looks like a bug.

As a workaround, test whether the graph has loops before computing the chromatic polynomial.

sage: G = Graph([[1, 1]], multiedges=True, loops=True)
sage: G.has_loops()
True

Fixing the bug should just amount to special-casing graphs with loops (testing for loops as above) and including a doctest (to prevent the bug from reappearing).

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 5 years ago

Seen: 324 times

Last updated: Jun 06 '19