A Graph is a container of references to objects (called objrefs) that may be linked to an arbitrary number of other objects. The objects themselves may be located on other processors, ie the Graph may be distributed. Objects are polymorphic -- the only properties Graph needs to know is how create, copy, and serialise them, as well as what other objects they are linked to.
Because the objects are polymorphic, it is possible to create hypergraphs. Simply have two types of object in the graph -- pins and wires, say. A pin may be connected to multiple wire objects, just as wires may be connected to multiple pins.
The objrefs themselves are stored in a maplike object called an omap, which is replicated across all processors.
A short synopsis of Graph is as follows:
class Graph: public Ptrlist { public: omap objects; Graph& operator=(const Graph&); Graph(Graph&); Graph(); /* object management */ objref& AddObject(object* o, GraphID_t id, bool managed=false); template <class T> objref& AddObject(GraphID_t id); template <class T> objref& AddObject(const T& master_copy, GraphID_t id); /* these methods must be called on all processors simultaneously */ void Prepare_Neighbours(bool cache_requests=false); void Partition_Objects(); void Distribute_Objects(); void gather(); void rebuild_local_list(); void clear_non_local() void print(int proc) };
object
. You must
explicitly supply the type of the object to be created as a template
argument:
g.AddObject<foo>(id);In the third form, create a new object, and initialise its data with the contents of argument
master_copy
.
cache_requests
to true
, which
substantially reduces the amount of interprocessor communication
required.
proc
member of each objref), then call Distribute_Objects()
.
rebuild_local_list()
on each
processor.
gather()
, followed by Distribute_Pins()
brings all
processors' graphs up-to-date. This is, naturally, an expensive
operation, and should be done for startup or checkpointing purposes.
proc
member of the objrefs.