Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  Sektor Mar 8 at 14:40
1  
@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? –  Vitaliy Kaurov Mar 8 at 19:39
    
Nope, could you explain me? –  Jotasmall Mar 12 at 16:35
add comment

1 Answer 1

up vote 6 down vote accepted

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]]]    

False

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

True

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]]

True

g === AdjacencyGraph[Uncompress[cam]]

True

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

share|improve this answer
1  
Nice answer. +1, and a shadow-accept ;=} –  rasher Mar 8 at 23:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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