小编pbi*_*ble的帖子

快速添加vertex_index到listS图表以实现中介中心性

更新:问题可能在中介代码中.如果我注释掉brandes_betweenness_centrality代码的调用将编译.问题可能不是以前认为的索引设置.如果您能够提出另一个对Brandes_betweenness_centrality的调用,我将授予赏金,这将允许将索引保持在外部.

我正在尝试将一些旧的vecS代码转换为listS,特别是brandes_betweenness_centrality算法.

我试图保持Vertex和Edge属性非常轻,并且主要使用外部属性.这样做的原因是我不知道在这一点上我想要与他们联系的是什么.

我得到的错误来自内部adjacency_list.hpp所以我认为问题出在我们的老朋友vertex_index_tlistS上.

以下代码显示了如何重现编译错误.在此工作示例中,您可以更改定义以将vertex_index填充到图形定义中,并在完整工作代码(正确运行中介性)的中介方法中更改设置.

完整的例子:

#include <iostream>
#include <algorithm>
#include <vector>

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/betweenness_centrality.hpp>

#include <boost/timer.hpp>

using namespace std;

enum edge_t {A,B};

struct VertexProperties{
    std::string id;
};

struct EdgeProperties{
    edge_t type;
};

//vertex_index in as internal property, switch to this graph and change below vertex map for working code
//typedef boost::adjacency_list < boost::listS, boost::listS, boost::undirectedS,
//      boost::property<boost::vertex_index_t,size_t,VertexProperties>, EdgeProperties > DynamicNet;

// No internal vertex_index
typedef boost::adjacency_list < …
Run Code Online (Sandbox Code Playgroud)

c++ boost-graph

12
推荐指数
1
解决办法
529
查看次数

如何使用SWIG for Python正确包装std :: vector <std :: size_t>?std :: size_t的问题

我正在努力std::vector<std::size_t>与SWIG合作.我需要为c ++库提供一个python接口.std::vector原始类型和对象的工作正常,但有一个问题std::size_t.

我在这里提供了一个关于github的MCVE .

主要问题

基本上问题是std::size_t不被认可并被std::vector<std::size_t>视为std::vector< int,std::allocator< int > > *.当我尝试指定模板时,我得到以下内容.

使用%template(VecSize) std::vector<std::size_t>;给出:

swig -c++ -python c_swig_vec_std_size.i
:0: Warning(490): Fragment 'SWIG_AsVal_std_size_t' not found.
:0: Warning(490): Fragment 'SWIG_From_std_size_t' not found.
g++ -fpic -c c_swig_vec_std_size_wrap.cxx -I/public/users/paul/dev/software/Python-2.7.11/Include -I/public/users/paul/dev/software/Python-2.7.11
c_swig_vec_std_size_wrap.cxx: In static member function ‘static int swig::traits_asval<long unsigned int>::asval(PyObject*, swig::traits_asval::value_type*)’:
c_swig_vec_std_size_wrap.cxx:4289: error: ‘SWIG_AsVal_std_size_t’ was not declared in this scope
c_swig_vec_std_size_wrap.cxx: In static member function ‘static PyObject* swig::traits_from<long unsigned …
Run Code Online (Sandbox Code Playgroud)

c++ python swig vector

8
推荐指数
1
解决办法
1399
查看次数

如何扩展TableRowSorter只更改单个列的比较器,超级处理其余的

嗨,我试图在JTable中只为一个列使用自定义比较器.我用以下代码完成了这个.问题是这样做会破坏Integer的适当排序.

我有一个JTable,列类是:String | 整数| 整数| 布尔| 布尔

我正在使用的比较器就是这些.第一个使用如何拆分字母和数字之间(或数字和字母之间)的字符串?.

//compare strings being aware of numbers embedded in the string
private static Comparator<String> numberAwareCompare = new Comparator<String>() {
    public int compare(String s1, String s2) {

        String[] s1Parts = s1.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");
        String[] s2Parts = s2.split("(?<=\\D)(?=\\d)|(?<=\\d)(?=\\D)");

        int i = 0;
        while(i < s1Parts.length && i < s2Parts.length){

            //if parts are the same
            if(s1Parts[i].compareTo(s2Parts[i]) == 0){
                ++i;
            }else{
                try{

                    int intS1 = Integer.parseInt(s1Parts[i]);
                    int intS2 = Integer.parseInt(s2Parts[i]);

                    //if the parse works

                    int diff = …
Run Code Online (Sandbox Code Playgroud)

java swing jtable comparator tablerowsorter

4
推荐指数
1
解决办法
5669
查看次数

标签 统计

c++ ×2

boost-graph ×1

comparator ×1

java ×1

jtable ×1

python ×1

swig ×1

swing ×1

tablerowsorter ×1

vector ×1