Exemplo n.º 1
0
GraphNode *
graph_add_node (Graph *self, gpointer contents)
{
  GraphNode *new_node = graph_node_new (contents);
  g_ptr_array_add (self->nodes, new_node);

  return new_node;
}
Exemplo n.º 2
0
static g_graph mv_cnf_to_graph(mv_cnf input)
{
    register unsigned int ix, iy, iz = 0;

    g_graph result = graph_new();

    for (ix = 0; ix < input->clauses->sz; ix++) {
	graph_node_add(result, graph_node_new(ix));
    }

    for (ix = 0; ix < input->clauses->sz; ix++) {
	for (iy = ix + 1; iy < input->clauses->sz; iy++) {
	    if (mv_clause_shares_variables(input->clauses->arr[ix], input->clauses->arr[iy]) > 0) {
		graph_edge_add(result, graph_edge_new(iz++, ix, iy));
	    }
	}
    }

    return result;
}