Run Breadth-first search separately in every component of the undirected graph. Give a starting vertex colour zero and each newly discovered neighbour the opposite colour. Reject if an edge joins two vertices with the same assigned colour; otherwise accept after all components have been explored.
If the algorithm accepts, its assignments constitute a graph colouring with two colours. If it rejects, the two search-tree paths and the conflicting edge contain an odd cycle, on which alternating two colours cannot close consistently. Equivalently, a valid graph colouring with two colours fixes the parity of every path from a component's root, so the detected conflict is impossible in a two-colourable graph. The Breadth-first search work is with adjacency lists. Therefore
This is also the two-colourability criterion for bipartite graphs.
Factor the proposed polynomial:
In particular,
By the two-colourability criterion for bipartite graphs, every finite bipartite graph has at least one proper two-colouring, so its chromatic polynomial is positive at . Therefore cannot be the chromatic polynomial of a bipartite graph.
It is nevertheless a chromatic polynomial. Start with the complete graph , whose vertices may be coloured in
ways, and attach one leaf to any vertex. After the triangle is coloured, the leaf has available colours. The chromatic polynomial after attaching a leaf therefore gives