Beispiel #1
0
void Graph::makeSubgraph (const Graph &other, const Filter &filter,
                             Array<int> *mapping_out, Array<int> *inv_mapping)
{
   QS_DEF(Array<int>, vertices);

   if (mapping_out == 0)
      mapping_out = &vertices;

   filter.collectGraphVertices(other, *mapping_out);

   makeSubgraph(other, *mapping_out, inv_mapping);
}
void MoleculeLayoutGraphSmart::makeLayoutSubgraph (MoleculeLayoutGraph &graph, Filter &vertex_filter, Filter *edge_filter)
{
   _molecule = graph._molecule;
   _graph = &graph;
   _molecule_edge_mapping = graph._molecule_edge_mapping;

   QS_DEF(Array<int>, vertices);
   QS_DEF(Array<int>, vertex_mapping);
   QS_DEF(Array<int>, edges);
   QS_DEF(Array<int>, edge_mapping);

   clear();

   vertex_filter.collectGraphVertices(graph, vertices);
   if (edge_filter != 0) (*edge_filter).collectGraphEdges(graph, edges);

   if (edge_filter != 0) makeSubgraph(graph, vertices, &vertex_mapping, &edges, &edge_mapping);
   else makeSubgraph(graph, vertices, &vertex_mapping);

   LayoutVertex new_vertex;
   LayoutEdge new_edge;

   new_vertex.is_cyclic = false;

   for (int i = 0; i < vertices.size(); i++)
   {
      new_vertex.ext_idx = vertices[i];
      new_vertex.orig_idx = graph._layout_vertices[vertices[i]].orig_idx;
      new_vertex.type = graph._layout_vertices[vertices[i]].type;
	  new_vertex.morgan_code = graph._layout_vertices[vertices[i]].morgan_code;
     new_vertex.pos.copy(graph._layout_vertices[vertices[i]].pos);
      registerLayoutVertex(vertex_mapping[vertices[i]], new_vertex);
   }

   int index = 0;
   for (int i = edgeBegin(); i < edgeEnd(); i = edgeNext(i))
   {
      const Edge &edge = getEdge(i);
      int ext_idx = graph.findEdgeIndex(vertices[edge.beg], vertices[edge.end]);

      new_edge.ext_idx = ext_idx;
      new_edge.orig_idx = graph._layout_edges[ext_idx].orig_idx;
      new_edge.type = graph._layout_edges[ext_idx].type;
      registerLayoutEdge(i, new_edge);
   }

   _layout_component_number.clear_resize(edgeEnd());
   _layout_component_number.fffill();
   _layout_component_count = 0;
}