6
$\begingroup$

I am trying to use the Combinatorica package in a Mathematica version 9 in the following code :

graph = {{0, 1, 0, 0, 1}, {1, 0, 1, 0, 0}, {0, 1, 0, 1, 0}, {0, 0, 1, 
    0, 1}, {1, 0, 0, 1, 0}};    
Needs["Combinatorica`"]   
ChromaticNumber[AdjacencyGraph[graph]]

The output for this code is

ChromaticNumber[<graph>]

I think Mathematica does not recognize the function ChromaticNumber. The compatibility guide here does not list the function too. How do I use this function ?

$\endgroup$
  • 1
    $\begingroup$ The problem is that AdjacencyGraph returns a Graph object, which is different from the way graphs are represented in Combinatorica. Try ChromaticNumber[FromAdjacencyMatrix[graph]] instead. $\endgroup$ – Simon Woods Oct 16 '13 at 20:21
  • $\begingroup$ @SimonWoods You are ahead of me by 30 seconds :) $\endgroup$ – ybeltukov Oct 16 '13 at 20:25
  • $\begingroup$ @ybeltukov, you got my upvote for taking the trouble to write a proper answer :-) $\endgroup$ – Simon Woods Oct 16 '13 at 20:28
  • $\begingroup$ The IGraph/M package has IGChromaticNumber. It's much faster than Combinatorica's implementation and works with built-in Graph objects. $\endgroup$ – Szabolcs May 10 '18 at 18:00
6
$\begingroup$

You need to use old-style Graph functionality after loading Combinatorica`

Needs["Combinatorica`"];

graph = {{0, 1, 0, 0, 1}, {1, 0, 1, 0, 0}, {0, 1, 0, 1, 0}, {0, 0, 1, 
0, 1}, {1, 0, 0, 1, 0}};

ChromaticNumber[FromAdjacencyMatrix[graph]]

3

See also:

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.