• <small id='kDsWR'></small><noframes id='kDsWR'>

    <tfoot id='kDsWR'></tfoot>

      <i id='kDsWR'><tr id='kDsWR'><dt id='kDsWR'><q id='kDsWR'><span id='kDsWR'><b id='kDsWR'><form id='kDsWR'><ins id='kDsWR'></ins><ul id='kDsWR'></ul><sub id='kDsWR'></sub></form><legend id='kDsWR'></legend><bdo id='kDsWR'><pre id='kDsWR'><center id='kDsWR'></center></pre></bdo></b><th id='kDsWR'></th></span></q></dt></tr></i><div id='kDsWR'><tfoot id='kDsWR'></tfoot><dl id='kDsWR'><fieldset id='kDsWR'></fieldset></dl></div>
    1. <legend id='kDsWR'><style id='kDsWR'><dir id='kDsWR'><q id='kDsWR'></q></dir></style></legend>

      • <bdo id='kDsWR'></bdo><ul id='kDsWR'></ul>

        理解 boost::disjoint_sets

        时间:2023-07-20
        <tfoot id='06Trm'></tfoot>

            <tbody id='06Trm'></tbody>

              • <i id='06Trm'><tr id='06Trm'><dt id='06Trm'><q id='06Trm'><span id='06Trm'><b id='06Trm'><form id='06Trm'><ins id='06Trm'></ins><ul id='06Trm'></ul><sub id='06Trm'></sub></form><legend id='06Trm'></legend><bdo id='06Trm'><pre id='06Trm'><center id='06Trm'></center></pre></bdo></b><th id='06Trm'></th></span></q></dt></tr></i><div id='06Trm'><tfoot id='06Trm'></tfoot><dl id='06Trm'><fieldset id='06Trm'></fieldset></dl></div>
                <legend id='06Trm'><style id='06Trm'><dir id='06Trm'><q id='06Trm'></q></dir></style></legend>
                  <bdo id='06Trm'></bdo><ul id='06Trm'></ul>

                  <small id='06Trm'></small><noframes id='06Trm'>

                  本文介绍了理解 boost::disjoint_sets的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要使用 boost::disjoint_sets,但文档是我不清楚.有人能解释一下每个模板参数的含义吗,或者给出一个创建 disjoint_sets 的小示例代码?

                  I need to use boost::disjoint_sets, but the documentation is unclear to me. Can someone please explain what each template parameter means, and perhaps give a small example code for creating a disjoint_sets?

                  根据要求,我使用 disjoint_sets 来实现 Tarjan 的离线最不常见祖先算法, 即 - 值类型应为 vertex_descriptor.

                  As per the request, I am using disjoint_sets to implement Tarjan's off-line least common ancestors algorithm, i.e - the value type should be vertex_descriptor.

                  推荐答案

                  我能从文档中了解到什么:

                  What I can understand from the documentation :

                  Disjoint 需要将等级和父级(在森林树中)与每个元素相关联.例如,由于您可能想要处理任何类型的数据,因此您可能并不总是想要为父级使用映射:使用整数数组就足够了.您还需要每个元素的排名(联合查找所需的排名).

                  Disjoint need to associate a rank and a parent (in the forest tree) to each element. Since you might want to work with any kind of data you may,for example, not always want to use a map for the parent: with integer an array is sufficient. You also need a rank foe each element (the rank needed for the union-find).

                  你需要两个属性":

                  • one 将一个整数关联到每个元素(第一个模板参数),排名
                  • 一个将元素与另一个元素相关联(第二个模板参数),父亲

                  举个例子:

                  std::vector<int>  rank (100);
                  std::vector<int>  parent (100);
                  boost::disjoint_sets<int*,int*> ds(&rank[0], &parent[0]);
                  

                  数组用于&rank[0], &parent[0],模板中的类型为int*

                  Arrays are used &rank[0], &parent[0] to the type in the template is int*

                  对于更复杂的示例(使用地图),您可以查看 Ugo 的答案.

                  For a more complex example (using maps) you can look at Ugo's answer.

                  您只是为算法提供了两种结构来存储他需要的数据(等级/父级).

                  You are just giving to the algorithm two structures to store the data (rank/parent) he needs.

                  这篇关于理解 boost::disjoint_sets的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:跨平台等价于windows事件 下一篇:std、tr1 和 boost(作为命名空间和/或库)之间有什么区别?

                  相关文章

                • <i id='VHrud'><tr id='VHrud'><dt id='VHrud'><q id='VHrud'><span id='VHrud'><b id='VHrud'><form id='VHrud'><ins id='VHrud'></ins><ul id='VHrud'></ul><sub id='VHrud'></sub></form><legend id='VHrud'></legend><bdo id='VHrud'><pre id='VHrud'><center id='VHrud'></center></pre></bdo></b><th id='VHrud'></th></span></q></dt></tr></i><div id='VHrud'><tfoot id='VHrud'></tfoot><dl id='VHrud'><fieldset id='VHrud'></fieldset></dl></div>

                    <tfoot id='VHrud'></tfoot>
                    • <bdo id='VHrud'></bdo><ul id='VHrud'></ul>

                    <small id='VHrud'></small><noframes id='VHrud'>

                    <legend id='VHrud'><style id='VHrud'><dir id='VHrud'><q id='VHrud'></q></dir></style></legend>