# Get histogram of number of vertices per component of graph H

I have a huge graph with ~8k vertices and ~1k components. I want a histogram showing the number of vertices for each component. How do I do this?

EDIT: I'm trying ubpdqn's approach, but not gettting the expected results. Here are the details of my graph and the resulting histogram:

H = ExampleData[{"NetworkGraph", "HighEnergyTheoryCollaborations"}]

Histogram[Length /@ ConnectedComponents[H], LabelingFunction -> Above, BaseStyle -> 20]


Result:

-
I'm using google but cannot find functions that do what I want. I do ConnectedComponents[G] and I get the labels of all vertices, grouped in components. I do Length@ConnectedComponents[G] and I get the number of components. Not sure where to go from here. – sdkbj May 6 '14 at 11:39
This question appears to be off-topic because it the underlying problem is in the OP'sdata and not in Mathematica. – m_goldberg May 6 '14 at 12:58
@Öskå " If you remove it" remove what exactly? – sdkbj May 6 '14 at 13:10
You could use Histogram[Log /@ Length /@ ConnectedComponents[H], LabelingFunction -> Above] – Dr. belisarius May 6 '14 at 13:14
Your result looks perfectly correct to me. It says simply that most of the connected components are quite small. You should probably accept the answer given by @ubpdqn. – Mark McClure May 6 '14 at 14:01

Here is a toy example:

Generate toy graph

g = Graph[
UndirectedEdge @@@
RandomSample[Subsets[Union[RandomInteger[{1, 1000}, 1000]], {2}],
200]];


Mine:

Histogram can be obtained by mapping Length to ConnectedComponents:

Histogram[Length /@ ConnectedComponents[g], LabelingFunction -> Above,
BaseStyle -> 20]


-
I tried this approach but getting strange result. I added to my question. – sdkbj May 6 '14 at 12:40