Connected components of a graph

I am trying to find the number of connected components of numerous named graphs within Combinatorica. The obvious answer seems to be:

Length[GraphData[G,"ConnectedComponents"]]

but this fails. What am I doing wrong?

Does this property only work when the number of connected components is >= 2?

• Please give a complete and runnable example which fails. What is "G"? Also, GraphData is not part of Combinatorica. Do not load Combinatorica for this. Nov 16 '13 at 18:23
• I am using version 9 of Mathematica. Has the use of Combinatorica changed from earlier versions? I have been using GraphData with Combinatorica for a long time. Nov 16 '13 at 18:31
• GraphData is not part of Combinatorica, and to my knowledge it has never been. It is a built-in function introduced in version 8. Nov 16 '13 at 18:33
• I have to correct myself, GraphData was introduced in version 6, but it was a built-in, not part of Combinatorica. In version 8 and version 9 it returns the new Graph objects that were introduced in version 8. These are not directly compatible with Combinatorica. While it is still possible to use Combinatorica, and even convert these built-in graphs to Combinatorica's format, great care has to be taken to choose the correct function from the correct context for each operation. So unless you know you need Combinatorica, I recommend you don't load it to avoid accidental problems. Nov 16 '13 at 18:38
• GraphData["PappusGraph", "Properties"] shows that this graph has no property called "ConnectedComponents" in version 9. It has GraphData["PappusGraph", "ConnectedComponentCount"] which returns 1. Nov 16 '13 at 18:39

Needs["Combinatorica"]