示例#1
0
文件: aig.cpp 项目: diffblue/cbmc
void aigt::output_dot(std::ostream& out) const
{
  // constant TRUE
  out << "TRUE [label=\"TRUE\", shape=box]" << "\n";

  // now the nodes
  for(nodest::size_type n=0; n<number_of_nodes(); n++)
    output_dot_node(out, n);
}
示例#2
0
/* calculate number of children nodes recursively */
int number_of_nodes(mpc_ast_t *t) {
  if (t->children_num == 0) { return 1; }
  if (t->children_num >= 1) {
    int total = 1;
    for (int i=0; i < t->children_num; i++) {
      total = total + number_of_nodes(t->children[i]);
    }
    return total;
  }
  return 0; /* should not be here */
}
示例#3
0
文件: aig.cpp 项目: diffblue/cbmc
void aigt::print(std::ostream &out) const
{
  for(nodest::size_type n=0; n<number_of_nodes(); n++)
  {
    out << "n" << n << " = ";
    literalt l;
    l.set(n, false);
    print(out, l);
    out << "\n";
  }
}
示例#4
0
文件: graph.cpp 项目: lmborba/bppc
list<int> Graph::johnsons_maximal_clique(list<int> & clique)
{

  vector<set<Incidence> > sub_graph(adjacency_lists.size());

  list<int> sub = clique;
  int n_nodes = number_of_nodes();

  vector<bool> rest(n_nodes,true);
  list<int> rest_list;
  for (list<int>::iterator it = sub.begin(); it != sub.end(); it++) {
    rest[*it] = false;
  };
  for (int i=0;i<rest.size();i++) {
    if (rest[i]) {
      rest_list.push_back(i);
    };
  };

  for (list<int>::iterator it = clique.begin(); it != clique.end(); it++) {
    list<int> new_list;
    for (list<int>::iterator it2 =rest_list.begin();it2 != rest_list.end(); it2++) {
      if (has_edge(*it,*it2)) {
        new_list.push_back(*it2);
      };
    };
    rest_list = new_list;
  };

  rest.clear();
  rest.resize(n_nodes,false);
  for (list<int>::iterator it = rest_list.begin(); it != rest_list.end(); it++) {
    rest[*it] = true;
  };

  for (list<int>::iterator it = rest_list.begin(); it != rest_list.end(); it++) {
    for (set<Incidence>::iterator it2 = adjacency_lists[*it].begin(); it2 != adjacency_lists[*it].end(); it2++) {
      if (rest[it2->get_incident_node()]) {
        sub_graph[*it].insert(Incidence(it2->get_incident_node(),1));
      };
    };
  };

  calc_johnsons(sub,sub_graph,rest_list);

  return sub;

};
void city_tour()
{
  graph h; 
  edge *elist; 
  int nedge; 
  init_graph(&h); 
  h.read_node_attr = read_cityname;
  h.write_node_attr = write_cityname;
  h.read_edge_attr = read_distance;
  h.write_edge_attr = write_distance;

  if (read_graph(FILENAME, &h)) {
	print_graph(stdout, &h); 
	elist = (edge *) malloc(sizeof(edge) * (number_of_nodes(&h) - 1));
	nedge = mst_kruskal(&h, elist, get_distance);
  }
}