Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 ?

share|improve this question
1  
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. –  Simon Woods Oct 16 '13 at 20:21
    
@SimonWoods You are ahead of me by 30 seconds :) –  ybeltukov Oct 16 '13 at 20:25
    
@ybeltukov, you got my upvote for taking the trouble to write a proper answer :-) –  Simon Woods Oct 16 '13 at 20:28
add comment

1 Answer 1

up vote 4 down vote accepted

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:

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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