SubGraphAdaptor< _Graph, NodeFilterMap, EdgeFilterMap, checked > Class Template Reference
[Adaptor Classes for Graphs]


Detailed Description

template<typename _Graph, typename NodeFilterMap, typename EdgeFilterMap, bool checked = true>
class lemon::SubGraphAdaptor< _Graph, NodeFilterMap, EdgeFilterMap, checked >

SubGraphAdaptor shows the graph with filtered node-set and edge-set. If the checked parameter is true then it filters the edgeset to do not get invalid edges without source or target. Let $ G=(V, A) $ be a directed graph and suppose that the graph instance g of type ListGraph implements $ G $. Let moreover $ b_V $ and $ b_A $ be bool-valued functions resp. on the node-set and edge-set. SubGraphAdaptor<...>NodeIt iterates on the node-set $ \{v\in V : b_V(v)=true\} $ and SubGraphAdaptor<...>EdgeIt iterates on the edge-set $ \{e\in A : b_A(e)=true\} $. Similarly, SubGraphAdaptor<...>OutEdgeIt and SubGraphAdaptor<...>InEdgeIt iterates only on edges leaving and entering a specific node which have true value.

If the checked template parameter is false then we have to note that the node-iterator cares only the filter on the node-set, and the edge-iterator cares only the filter on the edge-set. This way the edge-map should filter all edges which's source or target is filtered by the node-filter.

      typedef ListGraph Graph;
      Graph g;
      typedef Graph::Node Node;
      typedef Graph::Edge Edge;
      Node u=g.addNode(); //node of id 0
      Node v=g.addNode(); //node of id 1
      Node e=g.addEdge(u, v); //edge of id 0
      Node f=g.addEdge(v, u); //edge of id 1
      Graph::NodeMap<bool> nm(g, true);
      nm.set(u, false);
      Graph::EdgeMap<bool> em(g, true);
      em.set(e, false);
      typedef SubGraphAdaptor<Graph, Graph::NodeMap<bool>, Graph::EdgeMap<bool> > SubGA;
      SubGA ga(g, nm, em);
      for (SubGA::NodeIt n(ga); n!=INVALID; ++n) std::cout << g.id(n) << std::endl;
      std::cout << ":-)" << std::endl;
      for (SubGA::EdgeIt e(ga); e!=INVALID; ++e) std::cout << g.id(e) << std::endl;
The output of the above code is the following.
      1
      :-)
      1
Note that n is of type SubGA::NodeIt, but it can be converted to Graph::Node that is why g.id(n) can be applied.

For other examples see also the documentation of NodeSubGraphAdaptor and EdgeSubGraphAdaptor.

Author:
Marton Makai
#include <lemon/graph_adaptor.h>

Inheritance diagram for SubGraphAdaptor< _Graph, NodeFilterMap, EdgeFilterMap, checked >:

Inheritance graph
[legend]

List of all members.


Generated on Thu Jun 4 04:04:17 2009 for LEMON by  doxygen 1.5.9