I am working with random graphs a lot. It's quite easy to describe random graph using, adjacency matrix or just a list of edges. However I am thinking that I might benefit from describing random graphs with something similar to graph distributions already presented in Mathematica.

Here is the question:

  • how to implement a custom distribution?
  • does it makes sense at all to do such a thing?

2 Answers 2


tl;dr Currently, this part of Mathematica is not designed to be extensible.

A few months ago I looked into how GraphPropertyDistribution and related functions are implemented, and whether they are extensible. As you may know, there are some limited ways to read the definition of some built-in symbols.

My goal was to integrate IGraph/M with functions such as RandomGraph, GraphPropertyDistribution, etc. I expected that at least automated numerical computation with graph property distribution may work, and I hoped that I would be able to add symbolic definitions for special cases.

What I found is this:

  • There are internal checks on what is a proper graph distribution or graph property. Therefore it is not sufficient to add on extra definitions to top-level symbols. It would be necessary to "register" new distributions/properties internally.

  • Much of the internal implementation of this functionality is not only ReadProtected, but also Locked (and therefore unmodifiable).

Conclusion: I do not think it is worth bothering (or safe) to extend these symbols.

Instead, define your own functions for each sub-functionality that you need. For example, IGraph/M has functions for sampling from certain random graph models (e.g. IGDegreeSequenceGame). These do only sampling and nothing else.


With regard to custom distribution, see something about ProbabilityDistribution in the documentation.

Here is an example of what can be done:

pd = ProbabilityDistribution[Sqrt[2]/Pi/(1 + x^4), {x, -Infinity, Infinity}]; 
Plot[PDF[pd, x], {x, -4, 4}, Filling -> Axis]


  • 7
    $\begingroup$ The OP is talking about implementing custom distributions on graphs (e.g. BernoulliGraphDistribution[] or PriceGraphDistribution[]) and not probability distributions proper. I'm not sure why this has upvotes... $\endgroup$ Commented Aug 5, 2017 at 12:57

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.