Ejemplo n.º 1
0
graph_p graph_random(uint32_t v, uint32_t e) {
  graph_p g = graph_init(v);
  return g;
  for (uint32_t i = 0; i < e; i++) {
    edge_t e;
    e.v = rand() % v;
    e.w = rand() % v;
    graph_insert_edge(g, e);
  }
}
Ejemplo n.º 2
0
} END_TEST

START_TEST(test_graph_remove_edge) {
  kld_graph_t * g = (kld_graph_t *) new_graph();

  int data = 1;
  int * data_ref = &data;

  kld_graph_node_t * n1 = (kld_graph_node_t *) new_graph_node(g);
  kld_graph_node_t * n2 = (kld_graph_node_t *) new_graph_node(g);

  graph_insert_edge(g, n1, n2, data_ref);
  graph_remove_edge(g, n1, n2);

  kld_graph_edge_t * e = (kld_graph_edge_t *) graph_get_edge(g, n1, n2);
  fail_if(e != NULL, "Edge should be NULL after inserting and then removing it.");
} END_TEST
Ejemplo n.º 3
0
} END_TEST

START_TEST(test_graph_insert_edge) {
  kld_graph_t * g = (kld_graph_t *) new_graph();

  int data = 1;
  int * data_ref = &data;

  kld_graph_node_t * n1 = (kld_graph_node_t *) new_graph_node(g);
  kld_graph_node_t * n2 = (kld_graph_node_t *) new_graph_node(g);

  graph_insert_edge(g, n1, n2, data_ref);

  kld_graph_edge_t * e = (kld_graph_edge_t *) graph_get_edge(g, n1, n2);
  fail_if(e == NULL, "Edge is NULL after inserting it.");
  fail_if(e->data == NULL, "Edge data is NULL after inserting it.");
  fail_if(e->data != data_ref, "Edge data is not the expected value.");
} END_TEST
Ejemplo n.º 4
0
} END_TEST

START_TEST(test_graph_get_edge) {
  kld_graph_t * g = (kld_graph_t *) new_graph();

  int data = 1;
  int * data_ref = &data;

  kld_graph_node_t * n1 = (kld_graph_node_t *) new_graph_node(g);
  kld_graph_node_t * n2 = (kld_graph_node_t *) new_graph_node(g);

  graph_insert_edge(g, n1, n2, data_ref);

  kld_graph_edge_t * e = (kld_graph_edge_t *) graph_get_edge(g, n1, n2);
  kld_graph_edge_t * e2 = (kld_graph_edge_t *) graph_get_edge(g, n2, n1);
  
  fail_if(e == NULL, "Incorrect edge returned.");
  fail_if(e->data == NULL, "Incorrect edge data returned.");
  fail_if(e->data != data_ref, "Incorrect edge data returned.");
  fail_if(e2 != NULL, "Incorrect edge returned.");
} END_TEST
Ejemplo n.º 5
0
int main(int argc, char** argv) {
  graph_p g = graph_init(8);
  edge_t e;
  e.v = 1;
  e.w = 3;

  printf("inserting edge\n");
  graph_insert_edge(g, e);
  graph_print(g);

  /*
  edge_t edges[8 * 7 / 2];
  printf("edges %d\n", graph_edges(g, edges));
  */

  printf("removing edge\n");
  graph_remove_edge(g, e);
  graph_print(g);

  graph_destroy(g);
  return EXIT_SUCCESS;
}
Ejemplo n.º 6
0
timing_analyze_graph*  create_timing_analyze_graph(const input_circuit_info* circuit_info)
{
    assert(circuit_info != NULL);

    timing_analyze_graph* graph = (timing_analyze_graph*)malloc(sizeof(timing_analyze_graph));
    assert(graph != NULL);
    /* first insert vertexs */
    graph_insert_vertexs(circuit_info, graph);
    /* then insert edge */
    const int num_of_edges = circuit_info->m_num_of_edges;
    int e = 0;
    while (e < num_of_edges) {
        int source = circuit_info->m_input_edges[e]->m_from;
        int sink = circuit_info->m_input_edges[e]->m_to;
        double delay = circuit_info->m_input_edges[e]->m_delay;
        graph_insert_edge(source,
                          sink,
                          delay,
                          graph);
        ++e;
    }

    return graph;
}