void exhaust( int N , map< vector< int > , set< pair< int , int > > >& adjacencyList , vector< int > I , vector< int > T , list< int >& R , list< int >::iterator R_it ) { Word result; // pick an edge leaving the current vertex - I pair< int , int > P = *adjacencyList[I].begin( ); int direction = P.first; int arity = P.second; // update the adjacency list adjacencyList[I].erase( P ); if( arity>1 ) adjacencyList[I].insert( pair< int , int >( direction , arity-1 ) ); // save the value of I and compute a new value of I vector< int > I0 = I; I[abs(direction)-1] += direction<0 ? -1 : 1; // add a new letter to a word R_it = R.insert( R_it , direction ); list< int >::iterator R_it2 = R_it; ++R_it2; // continue the process if we are not at the initial vertex if( I!=T ) exhaust( N , adjacencyList , I , T , R , R_it2 ); ++R_it; while( !adjacencyList[I].empty( ) ) exhaust( N , adjacencyList , I , I , R , R_it ); adjacencyList.erase( I ); }
Word FreeMetabelianGroupAlgorithms::getWordFromEdgeMap( int N , const map< vector< int > , int >& EM ) { Word result; // adjacencyList = point in Z^n -> (edge direction, arity) map< vector< int > , set< pair< int , int > > > adjacencyList; for( map< vector< int > , int >::const_iterator E_it=EM.begin( ) ; E_it!=EM.end( ) ; ++E_it ) { pair< vector< int > , int > C = *E_it; int direction = C.first[N]; C.first.pop_back( ); if( C.second<0 ) { ++C.first[direction-1]; adjacencyList[C.first].insert( pair< int , int >( -direction , -C.second ) ); } else { adjacencyList[C.first].insert( pair< int , int >( direction , C.second ) ); } } // Cover the components while( !adjacencyList.empty( ) ) { pair< vector< int > , set< pair< int , int > > > C = *adjacencyList.begin( ); list< int > R; exhaust( N , adjacencyList , C.first , C.first , R , R.begin( ) ); Word TW = getTailWord( N , C.first ); result *= TW*Word( R )*-TW; } return result; }
void ops(char * flag) { if(strcmp(flag, "-all") == 0) { strcpy(flag, "-vtpdcs"); } if(exhaust(flag, 'v')) { printf("-v\tviolent crime\n"); printf("\t\thomicide\n"); printf("\t\tcriminal sexual assault\n"); printf("\t\tcriminal damage\n"); printf("\t\tbattery\n"); } if(exhaust(flag, 't')) { printf("-t\ttheft\n"); printf("\t\tburglary\n"); printf("\t\ttheft\n"); printf("\t\tmotor vehicle theft\n"); printf("\t\trobbery\n"); } if(exhaust(flag, 'p')) { printf("-p\tpublic violation\n"); printf("\t\tpublic indecency\n"); printf("\t\tobscenity\n"); printf("\t\tpublic peace violation\n"); } if(exhaust(flag, 'd')) { printf("-d\tdrug related crime\n"); printf("\t\tnarcotics\n"); printf("\t\tliqour law violation\n"); } if(exhaust(flag, 'c')) { printf("-c\tinvolving children\n"); printf("\t\tkidnapping\n"); printf("\t\toffense involving children\n"); } if(exhaust(flag, 's')) { printf("-s\tsexual\n"); printf("\t\tcriminal sexual assault\n"); printf("\t\tsex offense\n"); printf("\t\tprostitution\n"); } }
int groupfilter(struct crime * c, char * flag) { int f = 0; if(exhaust(flag, 'v')) { // violent crime if(strcmp(c->IUCRname, "HOMICIDE ") == 0) { f = 1; } if(strcmp(c->IUCRname, "CRIM SEXUAL ASSAULT ") == 0) { f = 1; } if(strcmp(c->IUCRname, "CRIMINAL DAMAGE ") == 0) { f = 1; } if(strcmp(c->IUCRname, "BATTERY ") == 0) { f = 1; } } if(exhaust(flag, 't')) { // theft crime if(strcmp(c->IUCRname, "BURGLARY ") == 0) { f = 1; } if(strcmp(c->IUCRname, "THEFT ") == 0) { f = 1; } if(strcmp(c->IUCRname, "MOTOR VEHICLE THEFT ") == 0) { f = 1; } if(strcmp(c->IUCRname, "ROBBERY ") == 0) { f = 1; } } if(exhaust(flag, 'p')) { // public crime if(strcmp(c->IUCRname, "PUBLIC INDECENCY ") == 0) { f = 1; } if(strcmp(c->IUCRname, "OBSCENITY ") == 0) { f = 1; } if(strcmp(c->IUCRname, "PUBLIC PEACE VIOLATION ") == 0) { f = 1; } } if(exhaust(flag, 'd')) { // drug related crime if(strcmp(c->IUCRname, "NARCOTICS ") == 0) { f = 1; } if(strcmp(c->IUCRname, "LIQUOR LAW VIOLATION ") == 0) { f = 1; } } if(exhaust(flag, 'c')) { // involving children if(strcmp(c->IUCRname, "KIDNAPPING ") == 0) { f = 1; } if(strcmp(c->IUCRname, "OFFENSE INVOLVING CHILDREN ") == 0) { f = 1; } } if(exhaust(flag, 's')) { // sexual crime if(strcmp(c->IUCRname, "CRIM SEXUAL ASSAULT ") == 0) { f = 1; } if(strcmp(c->IUCRname, "SEX OFFENSE ") == 0) { f = 1; } if(strcmp(c->IUCRname, "PROSTITUTION ") == 0) { f = 1; } } return f; }
int make_neighbors_list(EW * firstrow, EW * lastrow, EW * curr_row, SHORT row, SHORT col, NEIGHBOR * head, /* head points to dummy plus npoints neighbors */ int npoints) { extern CELL *cell; SHORT neighbors = 0, /* number of neighbors in current list */ nsearch = 1, ssearch = 1; /* expand search north and south */ EW *north, *south; /* begin north search in the row of the point to be interpolated */ north = curr_row; (*init_row_search) (north, col); north->next = NULL; /* curtail interpolation if this cell has a value and not -e option */ if (north->east && north->east->x == col && north->east->y == row) { if (error_flag) { /* ignore value and interpolate */ if (ll) extend_east(north); else north->east = north->east->next; } else { /* no interpolation required */ cell[col] = north->east->value; return (0); } } /* initialize south search routine */ if (north == lastrow) south = NULL; else { south = north + 1; (*init_row_search) (south, col); south->next = NULL; } /* initialize search cycle pattern */ (*locate_neighbors) (north, head, row, col, npoints, &neighbors); search(&north, head, row, col, npoints, &neighbors, firstrow, -1); if (south) (*locate_neighbors) (south, head, row, col, npoints, &neighbors); /* expand row search north and south until all nearest neighbors must occur * within the current search boundaries, then exhaust search region */ do { if (north) { if (nsearch) nsearch = search(&north, head, row, col, npoints, &neighbors, firstrow, -1); else exhaust(&north, head, row, col); } if (south) { if (ssearch) ssearch = search(&south, head, row, col, npoints, &neighbors, lastrow, 1); else exhaust(&south, head, row, col); } } while (north || south); return (1); }