mcxrand(1)
mcxrand(1) π
okay bestie, welcome to mcxrand(1) β it's a USER COMMANDS situation and it's honestly kind of iconic. it does random shuffling, removal, addition, and perturbation of edges of graphs. yes that's a lot of verbs. she contains multitudes. π¦
β¨ NAME β¨
mcxrand β random shuffling, removal, addition, and perturbation of edges of graphs. periodt.
πΈ SYNOPSIS πΈ
mcxrand [options]
mcxrand -gen K -add N -new-g-mean f # random graph on K nodes, N edges
mcxrand -imx <name> -remove N -add N # remove then add edges
mcxrand -imx <name> -shuffle N # shuffle N edge pairs
mcxrand -imx <name> -noise-radius f # add noise to add weights
mcxrand -pa N/m # preferential attachment generation
mcxrand [-imx <fname> (input matrix)] [-o <fname> (output matrix to
<fname>)] [--write-binary (write output in binary format)] [-gen <num>
(generate new graph)] [-pa <N>/<m> (preferential attachment)] [-remove
<num> (remove <num> edges)] [-add <num> (add <num> edges not yet
present)] [-shuffle <num> (shuffle edge pair <num> times)] [-icl <fname>
(shuffle nodes preserving cluster sizes)] [-h (print synopsis, exit)]
[--apropos (print synopsis, exit)] [--version (print version, exit)]
π DESCRIPTION π
so, real talk: this utility is a recent addition to the mcl suite and the schemes explained below will likely be evolved, simplified, and extended with future releases. it's giving new kid with main character energy, not giving final form. π
the --shuffle, -gen and -pa options can be deemed stable and robust. the options that determine edge weight perturbation and generation are likely to be subject to revision in the future. lowkey beta-coded, but we move.
the input graph/matrix, if specified with the -imx option, has to be in mcl matrix/graph format. you can use label input instead by preprocessing the label input with mcxload(1), i.e.
mcxload -abc <label-file> | mcxrand [options]
refer to mcxio(5) for a description of these two input formats. by default mcxrand reads from STDIN. change this with the -imx option. π
mcxrand can randomly remove and add edges to a graph, or add gaussian noise to the edge weights of a graph. it can also shuffle edge pairs while preserving the degree sequence of the graph. in removal mode (-remove <num>) and in addition mode (-add <num>) mcxrand enforces arc symmetry by only working with edges w(i,j) where i < j and symmetrifying the result and adding any loops that were present in the input graph just before the output stage. symmetry slay. β¨
in perturbation mode (-noise-radius, with no other mode specified) the input can be any graph. no format drama, we're chill.
shuffle mode (-shuffle <num>) requires an undirected graph but will only fail when it picks an arc for which the arc in the reverse direction is not present. this means it may or may not fail on directed input depending on the random choices. it does not check equality of the two arc weights and randomly picks one to represent the edge weight. so likeβ¦ it might work, it might not, it's a vibe check every single time. π
edge removal, edge creation, and edge perturbation are applied in this order if both are specified. edge shuffling presently cannot be combined with one of the previous modes. sorry bestie, shuffle does NOT play well with others rn.
a random graph can be generated with -gen k, which specifies the number of nodes the graph should have. it is equivalent with passing (the file name of) an empty graph of the same dimensions as the argument to -imx. same energy, different paperwork.
when adding (i.e. creating) edges, the default is to use the uniform distribution for new edge weights ranging in some interval. the default interval is [0,1] and can be modified using the -edge-min min and -edge-max max options. a Gaussian edge weight distribution can be obtained by specifying -new-g-mean num. the standard deviation is by default 1.0 and can be altered with -new-g-sdev num. currently the edge weights are generated within the interval [mean-radius, mean+radius] where radius is specified with -new-g-radius. they are further selected to lie within the interval [L,R] if and only if -new-g-min L and -new-g-max R have been specified. math girlies rise. π₯
for both uniform and Gaussian edge creation the edge weights can be skewed towards either side of the distribution with -skew c. skewing is applied by mapping the edge weights to the interval [0,1], applying the function x^c, and remapping the resulting number. for values c<1 this skews the edge weights towards the right bound and for values c>1 this skews the edge weights towards the left bound. this is a rather crude approach that will likely be changed in the future. she's crunchy but she works. π
edge weights can be perturbed by specifying -noise-radius radius. this sets the maximum perturbation allowed. noise is generated with a standard deviation that is by default set to 0.5 and can be altered using -noise-sdev num. values are generated in the interval [-fac*sdev, fac*sdev] where fac is set with -noise-range fac. this interval is mapped to the interval [-radius, radius] before the resulting value is added to the actual edge weight. this becomes the new value. if an interval [L,R] is explicitly specified using -edge-min L and -edge-max R then the new value will be accepted only if it lies within the interval, otherwise the edge will not be perturbed. no notes, that's the whole rule. π
π OPTIONS π
-imx <fname>(input matrix) β the file name for input. STDIN is assumed if neither-imxnor-gen numis specified. she'll just start reading from STDIN, no invitation needed. π«Ά-o <fname>(output matrix to<fname>) β the file to write the transformed matrix to.--write-binary(write output in binary format) β write the output matrix in native binary format. raw bytes, no cap. π-shuffle <num>(shuffle edge pair<num>times) β shuffle edge pair<num>times. an edge shuffle acts on two randomly chosen edges edgesw(a,b)andw(c,d)where all the nodes must be different. if either none of the edges inw(a,c),w(b,d)or none of the edges inw(a,d),w(b,c)exists the original two edges are removed and is replaced by an edge pair for which both edges did not exist before. genuinely unhinged behaviour, we love her. π-icl <fname>(shuffle nodes preserving cluster sizes) β use this option to generate a random clustering with the exact same cluster size distribution as the input clustering.-pa <N>/<m>(preferential attachment) β this generates a random graph using preferential attachment. in this model new nodes are sequentially added to a graph. each new node is connected with<m>of the existing nodes (including nodes previously added), where the likelihood of picking an existing node is proportional to the edge degree of that node. during construction multiple edges between two nodes are allowed (each with weight one), and these are collapsed by adding their weights before output. rich get richer, honestly a whole social commentary. β-remove <num>(remove<num>edges) β remove this many edges from the input graph.-add <num>(add<num>edges not yet present) β create this many new edges. new ones only, no duplicates, she's picky like that.-gen <num>(node number) β use in conjunction with-addto generate a random graph on<num>nodes.
π¦ SEE ALSO π¦
mcxio(5), and mclfamily(7) for an overview of all the documentation and the utilities in the mcl family. go read the whole family tree bestie, iykyk. π§
ok that's the whole page!! you ate. now go shuffle some edges responsibly. πΈ
this has been mcxrand 22-282, dated 9 Oct 2022, from the mcxrand(1) manual β mwah, ily, byeee πβ¨π
π¦ where this page comes from
- debian bookworm: mcl 1:22-282+ds-2 Β· GPL-3.0-or-later
- debian trixie: mcl 1:22-282+ds-4 Β· GPL-3.0-or-later
- ubuntu noble: mcl 1:22-282+ds-2 Β· GPL-3.0-or-later
- ubuntu questing: mcl 1:22-282+ds-4
- ubuntu resolute: mcl 1:22-282+ds-4build1 Β· GPL-3.0-or-later
- ubuntu stonking: mcl 1:22-282+ds-4build1 Β· GPL-3.0-or-later
- Copyright (c) 2022 Stijn van Dongen
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms