next up previous contents index
Next: Objects Up: Graph Previous: Graph   Contents   Index

Basic usage of Graph

Graph is designed to be used in a SPMD parallel environment, using MPI to handle messages between processors. A copy of the Graph object is maintained on each process. Each process has a copy of the objref database (of type omap), called GRAPHCODE_NS::objectMap. The Graph::objects reference refers to this database. However the payload pointer of each objref will tend to only point to an object if the object is located in the current processes address space, or a cached copy of the remote object is needed for some reason. Otherwise it may be set to NULL to save space.

To call a method foo() on all objects of a Graph g (in parallel), execute the following code:

for (Graph::iterator i=g.begin(); i!=g.end(); i++)
   (*i)->foo();

If the method foo needs to know the values of neighbouring nodes, then you may call Graph::Prepare_Neighbours(), which ensures that a cached copy of any remotely located node linked to a local nodes is retrieved from the remote node. Thus arbitrary communication patterns can be expressed simply by the form of the network structure of the Graph.


next up previous contents index
Next: Objects Up: Graph Previous: Graph   Contents   Index
Russell Standish 2016-09-02