I have a mathematica generated network which I would like to fit into a power-law using R igraph package but i don't know which export format to use .

Many thanks.

  • $\begingroup$ I've never used igraph, or R, but this post indicates you can simply import an edge list as a simple 2-column tab-separated file. For example, temp = RandomGraph[{5, 8}]; Export["test.dat", List @@@ EdgeList[temp]] will give such a file. $\endgroup$
    – Jason B.
    Commented Dec 22, 2016 at 19:23
  • $\begingroup$ Identify which formats the R igraph package can read and then see if Mathematica can export any of those formats. There are several Mathematical Data Formats that are supported and many others in the Importing and Exporting guide. $\endgroup$
    – Edmund
    Commented Dec 22, 2016 at 19:43
  • $\begingroup$ @JasonB . Thank you very much. $\endgroup$ Commented Dec 22, 2016 at 20:13
  • $\begingroup$ @Edmund.Thank you very much. $\endgroup$ Commented Dec 22, 2016 at 20:14

1 Answer 1


Update: IGraph/M now has a standards-compliant GraphML exporter. It produces files that will load in R/igraph without problems.

IGExport["mygraph.graphml", g]

The GraphML files produced by the built-in Export function are not standard-compliant and will not load in many other programs.

I don't have experience with this, but you can still compare Mathematica format's with R/igraph's:

From http://igraph.org/r/doc/read_graph.html:

format Character constant giving the file format. Right now as_edgelist, pajek, graphml, gml, ncol, lgl, dimacs and graphdb are supported, the default is edgelist.

From http://reference.wolfram.com/language/guide/MathematicalDataFormats.html:

Not every format is fully supported.

Of the formats that Mathematica has built-in support for, I recommend using GML. As of M11.2, this seems to have the most robust implementation.

  • $\begingroup$ @Szabolcs.Thank you very much. Also may I please ask you whether there is an equivalent of this function."plf = power.law.fit(degree_dist, impelementation = "plfit") in M/Igraph? $\endgroup$ Commented Dec 22, 2016 at 20:12
  • $\begingroup$ @PureFunction No, I didn't include it because Mathematica already had ParetoDistribution and ZipfDistribution, which you can use with FindDistributionParameters or EstimatedDistribution. $\endgroup$
    – Szabolcs
    Commented Dec 23, 2016 at 7:36
  • $\begingroup$ @Szabolcs.Thanks you very much. $\endgroup$ Commented Dec 23, 2016 at 21:55

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.