Sunday, May 10, 2015

In continuation of our discussion on an example of Graph API, shall we look into a generic methods of graph related computing. Take for example, persistence of a graph by reachability. How do we find nodes in the graph that correspond to entities that should be affected when a start node or a pivot entity is to be modified and saved? These are  done witg shared references. We find that shared references prevents us from deleting an entity even when the pivot entity is being deleted simply because another entity is using the shared reference
 If all the nodes are connected by a root entity, meaning all entities derive from a root object type, does it help to have a process that can find and collect these dirty elements. Taking it more generally give a connected graph where there are entities constantly getting dirtied, how do we non-invasively differentiate them and connect a subgraph that we need to work on ?
One such method to deal with this is the garbage collection method using gossip algorithm from the text book. Here is an example:
We first need to find the dirty objects in the graph. There are two processes involved - a marker process that marks different objects as dirty/clean and a mutator process that is responsible for connecting nodes that are already in sync with the store and need not be taken any action on. 
The marker need not be exact. It can be conservative. 
The mutator and the marker do not interfere with each others running because they work on basis of superposition. That is they touch data that are not related to each other. 
We begin with the root and simply mark vertices that can be reached from the already marked ones. This behaves just like the gossip program. However, the mutator can still frustrate the marker. So we add a second logic to say that we add an edge to x,y when y is clean and set both x and y to delete, we delete an edge between x and y when either of them is false. This way we build the sub-graph we are interested in.

No comments:

Post a Comment