I'm developing a code where I get graphs with over 10K nodes. These graphs have a particular relationship between clustering and degree that I need to save for future analysis. The problem is when I use EdgeList and then save the list in a Mathematica file (.nb), when I recall it, the size of some communities are different to the ones showed by the graph. The following sizes are obtained after change the graph by the EdgeList

Community = FindGraphCommunities[g];
aux = Length[#] & /@ FindGraphCommunities[g]
{1845, 1656, 1536, 1419, 1206, 441, 349, 342, 210, 205, 168, 126, 
          113, 103, 73, 58, 57, 45, 40, 8}

Then I use EdgeList[g], click on Show full Output and copy the entire cell and save it into the file.nb. When I call again the graph g3 from the file.nb it gives me the following sizes

g = g3;
Community = FindGraphCommunities[g];
aux = Length[#] & /@ FindGraphCommunities[g]
 {1884, 1766, 1720, 1364, 643, 420, 420, 394, 266, 218, 211, 159, 117, 
        101, 93, 76, 29, 28, 24, 21, 20, 16, 10}

I don't know what happen there, could be the command EdgeList or something behind...Then I try to save the graph by Exporting it as a gml file and after 10 minutes it was still running... So, do you have any suggestion for this, how can I export efficiently this information or do I have to wait for the exportation in gml format?

  • $\begingroup$ You have been a user for 9 months and still don't format your code properly. Please, refer to the documentation centre for code formatting practices. $\endgroup$
    – Sektor
    Commented Mar 8, 2014 at 14:40
  • 1
    $\begingroup$ @Jotasmall you already asked 3 question, and received good answers for all of them. Yet you did not except a single answer. Do you understand how to do it? $\endgroup$ Commented Mar 8, 2014 at 19:39
  • $\begingroup$ Nope, could you explain me? $\endgroup$
    – Jotasmall
    Commented Mar 12, 2014 at 16:35

1 Answer 1


Graph will not be unique unless you specify some other properties. Here VertexList order is important. Compare:

g = RandomGraph[{10^4, 10^6}];

FindGraphCommunities[g] == FindGraphCommunities[Graph[EdgeList[g]]]    


FindGraphCommunities[g] == FindGraphCommunities[Graph[VertexList[g], EdgeList[g]]]    


So now when you know how to get it right I'd also advise to compress VertexList and EdgeList with Compress or...

...save it as compressed AdjacencyMatrix:

g = RandomGraph[{10^4, 10^6}];    
cam = Compress[AdjacencyMatrix[g]];

g == AdjacencyGraph[Uncompress[cam]]


g === AdjacencyGraph[Uncompress[cam]]


cam is a string you can save in a notebook or a text file. FindGraphCommunities will also give same answer.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.