title: R igraph graph density, diameter, eccentricity and shortest path
body: <p>I hope someone can help me out.</p>
  
  <p>I have an undirected graph g with n=2071 nodes and m=9023 edges.
  I calculated the graph density in R using the igraph package and got the following:</p>
  
  <pre><code>&gt; graph.density(g,loop=FALSE)
  [1] 0.00210475
  </code></pre>
  
  <p>However, using the formula for graph density, i.e. density = mean degree / (n-1), I got the following:</p>
  
  <pre><code>&gt; mean(degree(g))/(vcount(g)-1)
  [1] 0.0042095
  </code></pre>
  
  <p>Why does graph.density() give me a different (is it wrong?) answer?</p>
  
  <p>Another question, doesn't the maximum eccentricity = diameter = maximum shortest path of the graph? Or am I confusing the concepts?
  Calculating in R using the igraph package, I got the following:</p>
  
  <pre><code>&gt; max(shortest.paths(g,mode="all"))
  [1] 17
  &gt; diameter(g,directed=FALSE,unconnected=FALSE,weights=NULL)
  [1] 17
  &gt; max(eccentricity(g,mode="all"))
  [1] 8
  </code></pre>
  
  <p>I used Gephi to double check and I got the diameter=8.
  Why is there a disparity between the values?</p>
  
  <p>Also, I found an almost similar question asked before (<a href="https://stackoverflow.com/questions/13466530/igraph-radius-and-diameter">igraph radius and diameter</a>), but it does not quite ask/answer what I want. It says that the bug has been fixed.</p>