0

I have a random graph in R, I use method erdos.renyi.game to generate random graph and I want to generate a line graph for output, my output will be degree distribution of my graph.

my code:

library(igraph)
graph <- erdos.renyi.game(n=100, 0.2, type = c("gnp"), directed=FALSE, loops=FALSE)
d <- degree.distribution(graph)
plot(d)

but my output is Dot plot.!

talat
  • 68,970
  • 21
  • 126
  • 157
Digicom
  • 154
  • 1
  • 2
  • 12

1 Answers1

2

For a line plot you need to use:

plot(d,type="l")

The default for the plot() function is the dotplot.

If all you want is to get a graph of the degree distribution, you can use hist(degree(graph)). The function degree.distribution() gives you a vector of the relative frequencies of degrees. You can get a histogram showing the distribution of degree values by calling degree() and feeding it into hist().

For overlaying a normal curve over your graph, see this question.

Community
  • 1
  • 1
Kenji
  • 571
  • 4
  • 20
  • Yes, but i want to a normal distribution of random graph. i have not solution for that. – Digicom Nov 18 '14 at 13:59
  • Have you tried `hist(degree(graph))`? `degree.distribution()` gives you a vector of the relative frequencies of degrees. You can get a histogram showing the distribution of degree values by calling `degree()` and feeding it into `hist()` – Kenji Nov 18 '14 at 14:10
  • It is good, too.But i have a compare normal distribution with degree distribution of my graph and a Dot plot to it. – Digicom Nov 19 '14 at 03:00