| Home | Libraries | People | FAQ | More

## Class graph_communicator

boost::mpi::graph_communicator — An MPI communicator with a graph topology.

## Synopsis

    // In header: <boost/mpi/graph_communicator.hpp>

    class graph_communicator : public boost::mpi::communicator {
    public:
      // construct/copy/destruct
      graph_communicator(const MPI_Comm &, comm_create_kind);
      template<typename Graph>
        explicit graph_communicator(const communicator &, const Graph &,
                                    bool = false);
      template<typename Graph, typename RankMap>
        explicit graph_communicator(const communicator &, const Graph &, RankMap,
                                    bool = false);
    };

## Description

A `graph_communicator` is a communicator whose topology is expressed as a graph. Graph communicators have the same functionality as (intra)communicators, but also allow one to query the relationships among processes. Those relationships are expressed via a graph, using the interface defined by the Boost Graph Library. The `graph_communicator` class meets the requirements of the BGL Graph, Incidence Graph, Adjacency Graph, Vertex List Graph, and Edge List Graph concepts.

### `graph_communicator` public construct/copy/destruct

1.     graph_communicator(const MPI_Comm & comm, comm_create_kind kind);

   Build a new Boost.MPI graph communicator based on the MPI communicator `comm` with graph topology.

   `comm` may be any valid MPI communicator. If `comm` is MPI_COMM_NULL, an empty communicator (that cannot be used for communication) is created and the `kind` parameter is ignored. Otherwise, the `kind` parameter determines how the Boost.MPI communicator will be related to `comm:`

   - If `kind` is `comm_duplicate`, duplicate `comm` to create a new communicator. This new communicator will be freed when the Boost.MPI communicator (and all copies of it) is destroyed. This option is only permitted if the underlying MPI implementation supports MPI 2.0; duplication of intercommunicators is not available in MPI 1.x.

   - If `kind` is `comm_take_ownership`, take ownership of `comm`. It will be freed automatically when all of the Boost.MPI communicators go out of scope.

   - If `kind` is `comm_attach`, this Boost.MPI communicator will reference the existing MPI communicator `comm` but will not free `comm` when the Boost.MPI communicator goes out of scope. This option should only be used when the communicator is managed by the user.

2.     template<typename Graph>
         explicit graph_communicator(const communicator & comm, const Graph & graph,
                                     bool reorder = false);

   Create a new communicator whose topology is described by the given graph. The indices of the vertices in the graph will be assumed to be the ranks of the processes within the communicator. There may be fewer vertices in the graph than there are processes in the communicator; in this case, the resulting communicator will be a NULL communicator.

   Parameters: |

   `comm` | The communicator that the new, graph communicator will be based on.
   `graph` | Any type that meets the requirements of the Incidence Graph and Vertex List Graph concepts from the Boost Graph Library. This structure of this graph will become the topology of the communicator that is returned.
   `reorder` | Whether MPI is permitted to re-order the process ranks within the returned communicator, to better optimize communication. If false, the ranks of each process in the returned process will match precisely the rank of that process within the original communicator.

3.     template<typename Graph, typename RankMap>
         explicit graph_communicator(const communicator & comm, const Graph & graph,
                                     RankMap rank, bool reorder = false);

   Create a new communicator whose topology is described by the given graph. The rank map (`rank`) gives the mapping from vertices in the graph to ranks within the communicator. There may be fewer vertices in the graph than there are processes in the communicator; in this case, the resulting communicator will be a NULL communicator.

   Parameters: |

   `comm` | The communicator that the new, graph communicator will be based on. The ranks in `rank` refer to the processes in this communicator.
   `graph` | Any type that meets the requirements of the Incidence Graph and Vertex List Graph concepts from the Boost Graph Library. This structure of this graph will become the topology of the communicator that is returned.
   `rank` | This map translates vertices in the `graph` into ranks within the current communicator. It must be a Readable Property Map (see the Boost Property Map library) whose key type is the vertex type of the `graph` and whose value type is `int`.
   `reorder` | Whether MPI is permitted to re-order the process ranks within the returned communicator, to better optimize communication. If false, the ranks of each process in the returned process will match precisely the rank of that process within the original communicator.