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比值为常数时生成超大规模图。所有算法的时间复杂度均与其输出规模呈线性关系。