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.
In[37]:= g = Graph[{4->3, 5->3, 5->4, 6->1, 6->2, 6->4, 6->5}]

Out[37]= Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 6 -> 4, 6 -> 5}]

I created a graph as show above and while trying to import combinatorica package, I get the following error

In[38]:= << Combinatorica`;

General::compat: 
   Combinatorica Graph and Permutations functionality has been superseded by
    preloaded functionaliy. The package now being loaded may conflict with
    this. Please see the Compatibility Guide for details.

I don't know what's going on here, but while trying to find the chromatic number using the following command, it gives the subsequent following error.

In[43]:= CN = ChromaticNumber[g]

First::normal: Nonatomic expression expected at position 1 in First[All].

First::normal: Nonatomic expression expected at position 1 in First[All].

Part::partw: Part 2 of First[All] does not exist.

First::normal: Nonatomic expression expected at position 1 in First[All].

General::stop: Further output of First::normal
     will be suppressed during this calculation.

Part::partw: Part 2 of First[All] does not exist.

Part::partw: Part 2 of First[All] does not exist.

General::stop: Further output of Part::partw
     will be suppressed during this calculation.

Range::range: Range specification in 
    Range[V[Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 6 -> 4, 6 -> 5}]]]
     does not have appropriate bounds.

Table::iterb: Iterator {Combinatorica`Private`i$318, 
     V[Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 6 -> 4, 6 -> 5}]]} does
     not have appropriate bounds.

Join::heads: Heads Combinatorica`Private`Double and Table at positions 1 and 2
     are expected to be the same.

Join::heads: Heads Combinatorica`Private`Double and Table at positions 1 and 2
     are expected to be the same.

Join::heads: Heads Combinatorica`Private`Double and List at positions 1 and 2
     are expected to be the same.

General::stop: Further output of Join::heads
     will be suppressed during this calculation.

Table::iterb: Iterator {V[Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 
        6 -> 4, 6 -> 5}]]} does not have appropriate bounds.

Transpose::nmtx: 
   The first two levels of the one-dimensional list {} cannot be transposed.

Transpose::nmtx: 
   The first two levels of the one-dimensional list {} cannot be transposed.

Part::pspec: Part specification 
    {4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 6 -> 4, 6 -> 5}
     is neither an integer nor a list of integers.

Part::pspec: Part specification 
    Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 6 -> 4, 6 -> 5}][[2]]
     is neither an integer nor a list of integers.

Table::iterb: Iterator {V[Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 
        6 -> 4, 6 -> 5}]]} does not have appropriate bounds.

General::stop: Further output of Table::iterb
     will be suppressed during this calculation.

Part::pspec: Part specification Combinatorica`Private`Double[]
     is neither an integer nor a list of integers.

General::stop: Further output of Part::pspec
     will be suppressed during this calculation.

Range::range: Range specification in 
    Range[1 + Table[0, {V[Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 
            6 -> 4, 6 -> 5}]]}][[Combinatorica`Private`Double[],0]]] does not
     have appropriate bounds.

Complement::heads: 
   Heads Part and Range at positions 2 and 1 are expected to be the same.

Out[43]= Table[Complement[Range[1 + 

>       Table[0, {V[Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 6 -> 4, 

>             6 -> 5}]]}][[Combinatorica`Private`Double[],0]]], 

>     Table[0, {V[Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 6 -> 4, 

>           6 -> 5}]]}][[Combinatorica`Private`Double[],0]]], 

>    {V[Graph[{4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 6 -> 4, 6 -> 5}]]}]

Did I go wrong somewhere ?

please help.

share|improve this question
    
btw, I'm using Ubuntu 12.04 OS, and running MathKernel in Terminal –  tsndiffopera Sep 10 '12 at 16:53
add comment

migrated from stackoverflow.com Sep 10 '12 at 20:35

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 6 down vote accepted

Start a fresh Mma session and type

Needs["GraphUtilities`"];

g = {4 -> 3, 5 -> 3, 5 -> 4, 6 -> 1, 6 -> 2, 6 -> 4, 6 -> 5}
<< Combinatorica`
ShowGraph[g1 = ToCombinatoricaGraph[g]]
ChromaticNumber[g1]

There are a lot of name conflicts between the System` context and Combinatorica.

share|improve this answer
    
awesome sir. You made my day. Million Thanks to you. Even I had a doubt that there could be a conflict between the two packages, but couldn't resolve it. You've made it. Thanks again for this. :) –  tsndiffopera Sep 10 '12 at 17:43
1  
But EdgeList@g1 gives {{1, 2}, {3, 1}, {3, 2}, {4, 1}, {4, 3}, {4, 5}, {4, 6}}, which is the wrong answer, and for this reason I have never trusted ToCombinatoricaGraph. (EdgeList@g gives {{4, 3}, {5, 3}, {5, 4}, {6, 1}, {6, 2}, {6, 4}, {6, 5}} ). I prefer to generate a CombinatoricaGraph using FromOrderedPairs (to again raise one of my favourite rants). In this case it makes no difference (but how can we be certain with independently checking?): ChromaticNumber@FromOrderedPairs@EdgeList@g also gives 3. –  TomD Sep 28 '12 at 8:46
    
@TomD Why don't you post an answer? I'll upvote it! –  belisarius Sep 28 '12 at 8:58
    
@TomD : +1 for that comment. It teaches me something which I didn't knew :) –  tsndiffopera Sep 29 '12 at 9:46
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.