31 # ifndef SEARCH_MEMORY_LEAKS_ENABLED
32 # error SEARCH NOT ENABLED
34 # define new DEBUG_NEW
36 static char THIS_FILE[] = __FILE__;
48 nodes_count(0), edges_count(0),
49 hidden_nodes_count(0), hidden_edges_count(0),
50 free_node_ids_count(0), free_edge_ids_count(0)
56 nodes_count(0), edges_count(0),
57 hidden_nodes_count(0), hidden_edges_count(0),
58 free_node_ids_count(0), free_edge_ids_count(0)
66 nodes_count(0), edges_count(0),
67 hidden_nodes_count(0), hidden_edges_count(0),
68 free_node_ids_count(0), free_edge_ids_count(0)
70 copy (G, nod.begin(), nod.end());
75 list<node>::const_iterator
it,
76 list<node>::const_iterator
end) :
78 nodes_count(0), edges_count(0),
79 hidden_nodes_count(0), hidden_edges_count(0),
80 free_node_ids_count(0), free_edge_ids_count(0)
86 list<node>::const_iterator
it,
87 list<node>::const_iterator
end)
90 list<node>::const_iterator n_it;
91 list<node>::const_iterator n_end;
93 for(n_it = it, n_end = end; n_it != n_end; ++n_it)
98 for(n_it = it, n_end = end; n_it != n_end; ++n_it)
102 for (e_it = (*n_it).out_edges_begin(), e_end = (*n_it).out_edges_end();
103 e_it != e_end; ++e_it) {
105 if (copy[e_it->target()] !=
node()) {
106 new_edge(copy[e_it->source()], copy[e_it->target()]);
137 os << conn << n.opposite (out);
240 list<edge> &source_adj = source.
data->
edges[1];
241 list<edge> &target_adj = target.
data->
edges[0];
243 e.
data->
adj_pos[0].push_back(source_adj.insert(source_adj.begin(),
e));
244 e.
data->
adj_pos[1].push_back(target_adj.insert(target_adj.begin(),
e));
293 if ((*it).source() == n || (*it).target() ==
n)
379 list<node>::iterator
it =
nodes.begin();
380 list<node>::iterator
end =
nodes.end();
384 it->data->edges[0].clear();
385 it->data->edges[1].clear();
398 bool bidirected =
true;
414 if ((*it).target () ==
source) {
437 d.
run(*const_cast<graph *>(
this));
447 t.
run(*const_cast<graph *>(
this));
469 if(excentricity < min_excentricity)
472 min_excentricity = excentricity;
484 return nodes.begin();
494 return edges.begin();
584 list<node>::iterator
it;
588 list<edge> &adj = (*it).data->edges[1];
589 e.
data->
adj_pos[0].push_back(adj.insert(adj.begin(),
e));
599 list<edge> &adj = (*it).data->edges[0];
600 e.
data->
adj_pos[1].push_back(adj.insert(adj.begin(),
e));
622 list<edge> implicitly_hidden_edges;
626 for (
int i = 0;
i <= 1; ++
i)
632 implicitly_hidden_edges.push_back(*edge);
647 return implicitly_hidden_edges;
682 for (it = sub_nodes.begin(), end = sub_nodes.end(); it !=
end; ++
it) {
715 list<edge>::iterator e_it, e_end, e_tmp;
720 while (e_it != e_end) {
774 list<node>::const_iterator
it = l.begin();
775 list<node>::const_iterator
end = l.end();
788 list<edge>::const_iterator
it = l.begin();
789 list<edge>::const_iterator
end = l.end();
815 if ((*it).target() == e.
source())
845 FILE*
file = fopen (filename,
"r");
866 orig_list = key_list;
875 if (!strcmp (
"graph", key_list->
key)) {
879 key_list = key_list->
next;
892 list<pair<int,GML_pair*> > node_entries;
893 list<pair<pair<int,int>,
GML_pair*> > edge_entries;
906 if (!strcmp (key_list->
key,
"node")) {
915 pair<int,GML_pair*>
n;
919 if (!strcmp (tmp_list->
key,
"id")) {
925 tmp_list = tmp_list->
next;
929 node_entries.push_back(n);
932 }
else if (!strcmp (key_list->
key,
"edge")) {
941 source_found =
false;
942 target_found =
false;
947 if (!strcmp (tmp_list->
key,
"source")) {
951 if (target_found)
break;
953 }
else if (!strcmp (tmp_list->
key,
"target")) {
957 if (source_found)
break;
960 tmp_list = tmp_list->
next;
963 assert (source_found && target_found);
964 edge_entries.push_back (e);
966 }
else if (!strcmp (key_list->
key,
"directed")) {
970 key_list = key_list->
next;
977 map<int, node> id_2_node;
981 list<pair<int,GML_pair*> >::iterator
it,
end;
982 vector<int> node_ids;
983 node_ids.reserve(num_nodes);
985 for (it = node_entries.begin(), end = node_entries.end();
989 tmp_node.
data->
id = (*it).first;
990 node_ids.push_back((*it).first);
992 id_2_node[(*it).first] = tmp_node;
996 list<pair<pair<int,int>,
GML_pair*> >::iterator eit, eend;
997 for (eit = edge_entries.begin(), eend = edge_entries.end();
998 eit != eend; ++eit) {
999 source = id_2_node[(*eit).first.first];
1000 target = id_2_node[(*eit).first.second];
1001 tmp_edge =
new_edge (source, target);
1008 sort(node_ids.begin(),node_ids.end());
1010 vector<int>::iterator iit, iend;
1013 for (iit = node_ids.begin(), iend = node_ids.end();
1016 if (iit != node_ids.begin()) {
1045 (*file) <<
"graph [" << endl;
1046 (*file) <<
"directed " << (
directed ?
"1" :
"0") << endl;
1051 for (;it !=
end; ++
it) {
1052 (*file) <<
"node [\n" <<
"id " << (*it).id() <<
"\n";
1054 (*file) <<
" ]" << endl;
1060 for (; e_it != e_end; ++e_it) {
1061 (*file) <<
"edge [\n" <<
"source " << (*e_it).source().id() <<
"\n";
1062 (*file) <<
"target " << (*e_it).target().id() <<
"\n";
1064 (*file) <<
" ]" << endl;
1069 (*file) <<
"]" << endl;
1075 ofstream
file (filename);
1076 if (!file)
return 0;