4
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.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Sai Nikhil
  • 141
  • 5

1 Answers1

8

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.

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
  • 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. :) –  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. – user1066 Sep 28 '12 at 08:46
  • @TomD Why don't you post an answer? I'll upvote it! – Dr. belisarius Sep 28 '12 at 08:58
  • @TomD : +1 for that comment. It teaches me something which I didn't knew :) – Sai Nikhil Sep 29 '12 at 09:46