예제 #1
0
int main() {
  
  igraph_t g;
  igraph_vector_ptr_t result;
  igraph_es_t es;
  igraph_integer_t omega;
  long int i, j, n;
  const int params[] = {4, -1, 2, 2, 0, 0, -1, -1};
 
  igraph_set_warning_handler(warning_handler_ignore);

  igraph_vector_ptr_init(&result, 0);
  igraph_full(&g, 6, 0, 0);
  igraph_es_pairs_small(&es, 0, 0, 1, 0, 2, 3, 5, -1);
  igraph_delete_edges(&g, es);
  igraph_es_destroy(&es);
  
  for (j=0; j<sizeof(params)/(2*sizeof(params[0])); j++) {
    if (params[2*j+1] != 0) {
      igraph_cliques(&g, &result, params[2*j], params[2*j+1]);  
    } else {
      igraph_largest_cliques(&g, &result);
    }
    n = igraph_vector_ptr_size(&result);
    printf("%ld cliques found\n", (long)n);
    canonicalize_list(&result);
    for (i=0; i<n; i++) {
      igraph_vector_t* v = (igraph_vector_t*) igraph_vector_ptr_e(&result,i);
      print_vector(v);
      igraph_vector_destroy(v);
      free(v);
    }
  }
   
  igraph_clique_number(&g, &omega);
  printf("omega=%ld\n", (long)omega);

  test_callback(&g);

  igraph_destroy(&g);

  igraph_tree(&g, 5, 2, IGRAPH_TREE_OUT);
  igraph_cliques(&g, &result, 5, 5);
  if (igraph_vector_ptr_size(&result) != 0) return 1;

  igraph_destroy(&g);
  igraph_vector_ptr_destroy(&result);

  return 0;
}
예제 #2
0
static LRESULT CALLBACK
window_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
    HDC hdc = GetDC(hwnd);
    int ret;

    switch (message) {
    case WM_CREATE:
        setup_pixel_format(hdc);
        ret = test_callback(hdc);
        ReleaseDC(hwnd, hdc);
        exit(ret);
        return 0;
    default:
        return DefWindowProc(hwnd, message, wparam, lparam);
    }
}
int main()
{
    srand(time(0));
    debug(4, "Test case scenario: write random parts of memory, then read it");
    debug(4, "Initializing library");
    ASSERT_SYSCALL(page_sim_init(PAGE_SIZE, MEM_SIZE, ADDRESS_SPACE_SIZE,
                MAX_CONCURRENT_OPERATIONS, callback));
    local_version = malloc(TOTAL_MEMORY_LENGTH);
    debug(4, "Filling memory with zeros");
    int i;
    for(i=0; i<TOTAL_MEMORY_LENGTH; ++i){
        ASSERT_SYSCALL(page_sim_set(i, 0));
        local_version[i] = 0;
    }
    debug(4, "Spawning %d threads", THREADS_COUNT);
    pthread_t threads[THREADS_COUNT];
    for(i=0; i<THREADS_COUNT; ++i){
        ASSERT_PTHREAD(pthread_create(threads+i, 0, thread_procedure, 0));
    }
    debug(4, "Threads spawned, now joining with them");
    for(i=0; i<THREADS_COUNT; ++i){
        ASSERT_PTHREAD(pthread_join(threads[i], 0));
    }
    debug(4, "Joined all threads");
    debug(4, "Testing content of whole available memory");
    for(i=0; i<TOTAL_MEMORY_LENGTH; ++i){
        debug(4, "Reading byte from address %u:", i);
        uint8_t v;
        ASSERT_SYSCALL(page_sim_get(i, &v));
        debug(4, "Read byte: %d from address %u", v, i);
        assert(local_version[i] == v);
        debug(4, "Byte correct");
    }
    debug(4, "All memory was OK");
    debug(4, "Releasing library");
    ASSERT_SYSCALL(page_sim_end());
    test_callback();
    return 0;
}