int main(int argc, char* argv[])
{

    if (argc < 2) 
    {
        std::cerr << "Not enough args" << endl;
        return 1;
    }

	
	string filename = argv[1];
    reach_coord mins, maxs;
	
	boost::scoped_ptr<reach_graph> pgraph (new reach_graph());
	load_osm(filename, *pgraph, mins, maxs);
	penalties_preprocessor prep (pgraph.get(), 0.01, 1);
	pgraph.reset (prep.iterate());
	

	return 0;
}
예제 #2
0
  int hpartition(const vector< set<int> > &graph, vector<int>& npartitions, int partition_method, vector<int> &decomp){

    vector<int> hdecomp;
    int edgecut = gpartition(graph, npartitions[0], partition_method, hdecomp);

    if(npartitions.size()==2){
      decomp.resize(graph.size());
      for(int i=0;i<npartitions[0];i++){
        map<int, int> renumber;
        int cnt=0;
        for(size_t j=0;j<hdecomp.size();j++){
          if(i==hdecomp[j]){
            renumber[j]=cnt++;
          }
        }

        vector< set<int> > pgraph(renumber.size());
        for(map<int, int>::const_iterator it=renumber.begin();it!=renumber.end();++it){
          for(set<int>::const_iterator jt=graph[it->first].begin();jt!=graph[it->first].end();++jt){
            if(renumber.find((*jt)-1)!=renumber.end()){
              pgraph[it->second].insert(renumber[(*jt)-1]+1);
            }
          }
        }
        
        vector<int> pdecomp, ncores(npartitions[1], 0);
        set<int> parts;
        int sedgecut = gpartition(pgraph, npartitions[1], partition_method, pdecomp);
        for(map<int, int>::const_iterator it=renumber.begin();it!=renumber.end();++it){
          ncores[pdecomp[it->second]]++;
          decomp[it->first] = hdecomp[it->first]*npartitions[1] + pdecomp[it->second];
          parts.insert(decomp[it->first]);
        }
      }
    }else{
      decomp.swap(hdecomp);
    }

    return edgecut;
  }
예제 #3
0
파일: row.c 프로젝트: imclab/nip2
static void *
row_new_heap( Heapmodel *heapmodel, PElement *root )
{
	Row *row = ROW( heapmodel );
	Expr *expr = row->expr;

#ifdef DEBUG
	printf( "row_new_heap: " );
	row_name_print( row );
	printf( "\n" );

	printf( "row_new_heap: new value is " );
	pgraph( root );

	printf( "row_new_heap: top value is " );
	pgraph( &row->top_row->expr->root );
#endif /*DEBUG*/

	if( row_is_displayable( row->sym ) ) {
		/* Hide superclasses whose constructor starts with "_".
		 */
		if( is_super( row->sym ) && PEISCLASS( root ) &&
			*IOBJECT( PEGETCLASSCOMPILE( root )->sym )->name == 
			'_' )
			model_display( MODEL( row ), FALSE );
	}

	/* New value ... reset error state.
	 */
	expr_error_clear( expr );
	expr->root = *root;
	expr_new_value( expr );

	if( row->child_rhs &&
		heapmodel_new_heap( HEAPMODEL( row->child_rhs ), root ) )
		return( row );

	/* Class display only for non-param classes.
	 */
	row->is_class = PEISCLASS( root ) && row->sym->type != SYM_PARAM;

	/* Set the default vis level.
	 */
	if( row->child_rhs && row->child_rhs->vislevel == -1 ) {
		PElement member;
		double value;
		gboolean is_class;

		if( !heap_is_class( root, &is_class ) )
			return( row );

		/* If it's a class with a vis hint, use that.
		 */
		if( is_class && 
			class_get_member( root, MEMBER_VISLEVEL, 
				NULL, &member ) &&
			heap_get_real( &member, &value ) ) 
			rhs_set_vislevel( row->child_rhs, value );

		/* Non-parameter rows get higher vislevel, except for super. 
		 */
		else if( row->sym->type != SYM_PARAM && !is_super( row->sym ) )
			rhs_set_vislevel( row->child_rhs, 1 );
		else 
			rhs_set_vislevel( row->child_rhs, 0 );
	}

	return( HEAPMODEL_CLASS( parent_class )->new_heap( heapmodel, root ) ); }