Version Control Systems, such as Git and Mercurial, manage the history of a project as a Directed Acyclic Graph encoding the various divergences and synchronizations happening in its life cycle. A popular workflow in the industry, called the feature branch workflow, constrains these graphs to be of a particular shape: a unique main branch, and non-interfering feature branches. Here we focus on the uniform random generation of those graphs with n vertices, including k on the main branch, for which we provide three algorithms, for three different use-cases. The first, based on rejection, is efficient when aiming for small values of k (more precisely whenever k = O($\sqrt$ n)). The second takes as input any number k of commits in the main branch, but requires costly precalculation. The last one is a Boltzmann generator and enables us to generate very large graphs while targeting a constant k/n ratio. All these algorithms are linear in the size of their outputs.
翻译:版本控制系统(如Git和Mercurial)将项目历史管理为有向无环图,编码了项目生命周期中发生的各种分叉与同步操作。业界流行的特性分支工作流要求这些图具有特定形态:唯一的主分支和非干扰的特性分支。本文聚焦于包含n个顶点(其中k个顶点位于主分支)的此类图的均匀随机生成问题,针对三种不同应用场景提出了三种算法:第一种基于拒绝采样,适用于k值较小的情况(具体而言当k=O($\sqrt$ n)时效率较高);第二种可接受主分支任意提交数k作为输入,但需要昂贵的预计算;第三种为玻尔兹曼生成器,能够在保持恒定k/n比值的同时生成超大规模图。所有算法的运行时间均与输出规模呈线性关系。