Custom graph distribution

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]

plot