如何用setS顶点列表创建增强子图? [英] How to create boost subgraph with setS vertices list?

查看:105
本文介绍了如何用setS顶点列表创建增强子图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码存在错误:


  AAA.cpp:23:15:这里
... / boost / include / boost / graph / subgraph.hpp:333:5:error:static assertion failed:(!is_same< edge_index_type,
boost :: detail :: error_property_not_found> ;: :value)

AAA.cpp:27:21:错误:调用'add_vertex(foo(int,char **)::< anonymous enum>,Graph&''

AAA.cpp:27:21:备注:候选人是:
... / boost / include / boost / graph / subgraph.hpp:在'boost :: subgraph< Graph> :: subgraph(boost :: subgraph< Graph> :: vertices_size_type,
const graph_property_type&)[with Graph =
boost :: adjacency_list< boost :: setS,boost :: setS,boost: :directedS,
boost :: no_property,boost :: no_property,boost :: no_property,
boost :: setS>; boost :: subgraph< Graph> :: vertices_size_type = long
unsigned int; boost :: subgraph< Graph> :: graph_property_type =
boost :: no_property]':




  #include< boost / config.hpp> 
#include< iostream>
#include< boost / graph / subgraph.hpp>
#include< boost / graph / adjacency_list.hpp>
#include< boost / graph / graph_utility.hpp>

int foo(int,char * [])
{
using namespace boost;
typedef子图<
adjacency_list<
setS,
setS,
directedS,
no_property,
no_property,
no_property,// graph prop
setS // edgelist
>
>图形;

const int N = 6;
Graph G0(N);
enum {A,B,C,D,E,F};

图表& G1 = G0.create_subgraph();
add_vertex(C,G1); //全局顶点C变成本地A1 for G1

return 0;



$ b $ p
$ b

如果我将setS更改为vecS作为顶点列表,它可以被编译。
如何用setS顶点列表创建增强子图?



谢谢,

解决方案首先,它不能用VertexContainer的 vecS 编译:


要创建图形和子图,首先创建根图对象。这里我们使用adjacency_list作为底层的图形实现。底层图形类型需要具有vertex_index和edge_index内部属性,因此我们将边缘索引属性添加到邻接列表。 (


所以我们来添加一些东西。现在它编译:

Live Live Coliru

  #include< boost / config.hpp> ; 
#include< iostream>
#include< boost / graph / subgraph.hpp>
#include< boost / graph / adjacency_list.hpp>
#include< boost / graph / graph_utility.hpp>

int main()
{
using namespace boost;
使用containerS = vecS;
typedef子图< adjacency_list< containerS,containerS,directedS,
property< vertex_index_t,size_t>,
property< edge_index_t,size_t>
>
>图形;

const int N = 6;
Graph G0(N);
enum {A,B,C,D,E,F};

图表& G1 = G0.create_subgraph();
Graph :: vertex_descriptor CG1 = add_vertex(G1);
Graph :: vertex_descriptor EG1 = add_vertex(G1);

add_edge(CG1,EG1,G1);

print_graph(G0);
std :: cout<< 子图:\\\
;
print_graph(G1);

$ / code>

打印

  0  - > 
1 - >
2 - >
3 - >
4 - >
5 - >
6 - > 7
7 - >
SUBGRAPH:
0 - > 1
1 - >



使用 setS



坦率地说,尽管文档间接建议像 listS setS 这样的东西可以是选择我真的不认为这可以工作。



问题似乎是如何 local_to_global m_global_vertex 已经实现。



这可能是一个人工限制/未实现的功能。你可能想在开发人员列表/ Trac问题上提出这个问题。


The following code has errors:

AAA.cpp:23:15:   required from here
   .../boost/include/boost/graph/subgraph.hpp:333:5: error: static assertion failed: (!is_same<edge_index_type,
   boost::detail::error_property_not_found>::value)

AAA.cpp:27:21: error: no matching function for call to ‘add_vertex(foo(int, char**)::<anonymous enum>, Graph&)’

AAA.cpp:27:21: note: candidates are:
   .../boost/include/boost/graph/subgraph.hpp: In instantiation of ‘boost::subgraph<Graph>::subgraph(boost::subgraph<Graph>::vertices_size_type,
   const graph_property_type&) [with Graph =
   boost::adjacency_list<boost::setS, boost::setS, boost::directedS,
   boost::no_property, boost::no_property, boost::no_property,
   boost::setS>; boost::subgraph<Graph>::vertices_size_type = long
   unsigned int; boost::subgraph<Graph>::graph_property_type =
   boost::no_property]’:

#include <boost/config.hpp>
#include <iostream>
#include <boost/graph/subgraph.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>

int foo(int,char*[])
{
    using namespace boost;
    typedef subgraph< 
        adjacency_list<
            setS, 
            setS, 
            directedS,
            no_property,
            no_property,
            no_property, // graph prop
            setS // edgelist
            > 
        > Graph;

    const int N = 6;
    Graph G0(N);
    enum { A, B, C, D, E, F}; 

    Graph& G1 = G0.create_subgraph();
    add_vertex(C, G1); // global vertex C becomes local A1 for G1

    return 0;
}

If I changed setS to vecS for the vertices list, it can be compiled. How to create boost subgraph with setS vertices list?

Thank you,

解决方案

Firstly, it doesn't compile with vecS for the VertexContainer:

To create a graph and subgraphs, first create the root graph object. Here we use adjacency_list as the underlying graph implementation. The underlying graph type is required to have vertex_index and edge_index internal properties, so we add an edge index property to the adjacency list. (docs)

So let's add things. Now it compiles:

Live On Coliru

#include <boost/config.hpp>
#include <iostream>
#include <boost/graph/subgraph.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>

int main()
{
    using namespace boost;
    using containerS = vecS;
    typedef subgraph< adjacency_list<containerS, containerS, directedS,
            property<vertex_index_t, size_t>,
            property<edge_index_t, size_t>
        >
    > Graph;

    const int N = 6;
    Graph G0(N);
    enum { A, B, C, D, E, F}; 

    Graph& G1 = G0.create_subgraph();
    Graph::vertex_descriptor CG1 = add_vertex(G1);
    Graph::vertex_descriptor EG1 = add_vertex(G1);

    add_edge(CG1, EG1, G1);

    print_graph(G0);
    std::cout << "SUBGRAPH:\n";
    print_graph(G1);
}

Prints

0 --> 
1 --> 
2 --> 
3 --> 
4 --> 
5 --> 
6 --> 7 
7 --> 
SUBGRAPH:
0 --> 1 
1 --> 

Using setS

Frankly, although the documentation suggests indirectly that something like listS or setS could be chosen I honestly don't think this can work.

The problem seems to be how local_to_global and m_global_vertex have been implemented.

This might be an artificial limitation/unimplemented feature. you might want to raise this question at the developer list/Trac issues.

这篇关于如何用setS顶点列表创建增强子图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆