在Fortran程序中使用Boost Graph库(BGL)
Using Boost Graph Library (BGL) in Fortran program
无论如何,我可以在我的fortran程序中使用Boost Graph库(BGL)使用图形数据结构。
任何人都可以帮助我或给我一个提示。我想在MPI-Fortran代码中的多个处理器上进行并行图结构。是否可以将Boost Graph库(BGL)用于此目的!
亲切的问候,ziv
您必须构造用C 编写的中间层,该中间层在某些特殊情况下对您有用的所有模板都对您有用,然后从Fortran调用它。bind(C)
和iso_c_binding
模块是您的朋友。我使用这种方法成功地在Fortran中使用了基于Boost的库CGAL。
沿着:
的线条my_bgl.cc:
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
using namespace boost;
extern "C"{
void* make_graph(int num_vertices, int num_edges, int *edge_array)
{
// create a typedef for the Graph type
typedef adjacency_list<vecS, vecS, bidirectionalS> Graph;
Graph *g = new Graph(num_vertices);
// add the edges to the graph object
for (int i = 0; i < num_edges; ++i)
add_edge(edge_array[2*i], edge_array[2*i+1], *g);
return g;
}
}
my_bgl.f90:
module my_bgl
use iso_c_binding
interface
type(c_ptr) function make_graph(num_vertices, num_edges, edge_array) bind(C,name="make_graph")
import
integer(c_int), value :: num_vertices
integer(c_int), value :: num_edges
integer(c_int) :: edge_array(2, num_edges)
end function
end interface
end module
函数make_graph
从输入的点返回一个不透明的指针。
no,Boost是C 模板库。除非将代码移植到Fortran,否则这是不可能的。
相关文章:
- Boost Graph Library,修复节点大小
- BGL:当包含 random_spanning_tree.hpp 时,对strong_components的调用无法编译
- 使用BGL实现random_spanning_tree
- BGL:无法访问捆绑的顶点属性
- 如果 BGL 中的add_vertex则检查顶点是否存在
- BGL 获取图形的权重图
- 如何从TBB :: Flow :: Graph中删除/取消消息
- Boost Graph库,depth_first_search未在MSVC中调用finish_edge
- 如何在Boost Graph库中的Grid_graph的边缘添加自定义属性
- 在现有数据结构上使用BGL算法需要什么(边和顶点作为矢量<对象*>)?
- BGL:不同命名空间中模板的专用化
- 使用提升图 [BGL] 检查add_edge之前顶点是否已存在
- 为什么在 BGL 中的访客中无法更改边缘属性?
- TensorFlow从C 中的Graph Def获得形状
- 在Boost Graph库中选择给定顶点的随机进出邻居的有效方法
- 如何使用Boost Graph库使用循环中的循环设置相同的边缘重量
- 如何在BGL图中找到两个顶点之间的最短路径
- Boost Graph库示例不编译
- 在Fortran程序中使用Boost Graph库(BGL)
- 如何将一组C++动态分配的对象表示为BGL(Boost Graph Library)图,以获得它们的依赖图