2014-01-29 08:38:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/*
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  PartitionWorkSpace . h 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *    Created  on :  Nov  24 ,  2010 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *        Author :  nikai 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *   Description :  a  preallocated  memory  space  used  in  partitioning 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# pragma once 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <vector> 
  
						 
					
						
							
								
									
										
										
										
											2023-01-18 06:05:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <memory> 
  
						 
					
						
							
								
									
										
										
										
											2014-01-29 08:38:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								namespace  gtsam  {  namespace  partition  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-31 00:44:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  typedef  std : : vector < int >  PartitionTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  // the work space, preallocated memory
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  struct  WorkSpace  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    std : : vector < int >  dictionary ;                           // a mapping from the integer key in the original graph to 0-based index in the subgraph, useful when handling a subset of keys and graphs
 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-18 06:05:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    std : : shared_ptr < std : : vector < size_t >  >  dsf ;           // a block memory pre-allocated for DSFVector
 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-31 00:44:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    PartitionTable  partitionTable ;                         // a mapping from a key to the submap index, 0 means the separator, i means the ith submap
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // constructor
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    WorkSpace ( const  size_t  numNodes )  :  dictionary ( numNodes , 0 ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     dsf ( new  std : : vector < size_t > ( numNodes ,  0 ) ) ,  partitionTable ( numNodes ,  - 1 )  {  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // set up dictionary: -1: no such key, none-zero: the corresponding 0-based index
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    inline  void  prepareDictionary ( const  std : : vector < size_t > &  keys )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      int  index  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      std : : fill ( dictionary . begin ( ) ,  dictionary . end ( ) ,  - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      std : : vector < size_t > : : const_iterator  it = keys . begin ( ) ,  itLast = keys . end ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      while ( it ! = itLast )   dictionary [ * ( it + + ) ]  =  index + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  // manually defined cuts
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  struct  Cuts  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    PartitionTable  partitionTable ; 
							 
						 
					
						
							
								
									
										
										
										
											2023-01-18 06:05:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    std : : vector < std : : shared_ptr < Cuts >  >  children ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-31 00:44:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2014-01-29 08:38:28 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} }  // namespace