简体   繁体   English

在Fortran程序中使用Boost Graph Library(BGL)

[英]Using Boost Graph Library (BGL) in Fortran program

Is there anyway, I can use the graph data structure using the Boost Graph Library (BGL) inside my FORTRAN program. 无论如何,我可以在FORTRAN程序中使用Boost Graph Library(BGL)来使用图形数据结构。

Could anyone help me or give me a hint. 任何人都可以帮助我或给我一个提示。 I want to do parallel graph structure on several processors in my MPI-FORTRAN code. 我想在我的MPI-FORTRAN代码中的几个处理器上进行并行图结构。 Is it possible to use Boost Graph Library (BGL) for this purpose! 是否可以使用Boost Graph Library(BGL)来达到此目的!

Kind regards, Ziv 亲切的问候,Ziv

You would have to construct an intermediate layer, written in C++, that does all the templating in some special case useful for you and then call it from Fortran. 你必须构建一个用C ++编写的中间层,它在某些特殊情况下对你有用,然后从Fortran调用它。 bind(C) and iso_c_binding module are your friends. bind(C)iso_c_binding模块是你的朋友。 I successfully use Boost based library CGAL in Fortran using this approach. 我使用这种方法成功地在Fortran中使用基于Boost的库CGAL。

Something along the lines of: 有点像:

my_bgl.cc: 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: 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

The function make_graph returns an opaque pointer to a Graph from the points entered. 函数make_graph从输入的点返回一个指向Graph的不透明指针。

No, boost is a C++ template library. 不,boost是一个C ++模板库。 Unless you port the code to FORTRAN, this is impossible. 除非您将代码移植到FORTRAN,否则这是不可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Boost Graph Library(BGL)和现有的图形数据结构 - Using Boost Graph Library (BGL) with existing graph data structure 使用BGL(Boost图形库)查找DAG中的所有拓扑排序 - Find all topological sorts in a DAG using BGL (Boost graph library) 使用 BOOST 库以 BGL 图的形式存储嵌套的 XML 结构 - Storing a nested XML structure in form of BGL graph using BOOST library 使用Boost Graph Library(BGL)识别连接的组件 - Using Boost Graph Library (BGL) to identify connected components BGL中的Lengauer Tarjan算法(增强图库) - Lengauer Tarjan Algorithm in BGL (boost graph library) Boost Graph Library:BGL内置了一个用于社区检测的简洁算法吗? - Boost Graph Library: Is there a neat algorithm built into BGL for community detection? 自定义InputIterator用于Boost图形(BGL) - Custom InputIterator for Boost graph (BGL) 如何将一组C ++动态分配的对象表示为BGL(提升图库)图以获得其依赖图? - How to represent a group of C++ dynamically allocated objects as a BGL (Boost Graph Library) graph in order to obtain their dependency graph? 使用Boost Graph [BGL]检查add_edge之前是否已存在顶点 - Check if vertex already exists before an add_edge using Boost Graph [BGL] 在Python中使用Boost Graph库 - Using Boost Graph Library in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM