Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SubGraphAdaptor Class Template Reference
[Adaptor Classes for Graphs]

#include <lemon/graph_adaptor.h>

List of all members.


Detailed Description

template<typename _Graph, typename NodeFilterMap, typename EdgeFilterMap>
class lemon::SubGraphAdaptor< _Graph, NodeFilterMap, EdgeFilterMap >

Warning:
Graph adaptors are in even more experimental state than the other parts of the lib. Use them at you own risk.
SubGraphAdaptor shows the graph with filtered node-set and edge-set. 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.

We have to note that this does not mean that an induced subgraph is obtained, the node-iterator cares only the filter on the node-set, and the edge-iterators care only the filter on the edge-set.

  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> > SubGW;
  SubGW gw(g, nm, em);
  for (SubGW::NodeIt n(gw); n!=INVALID; ++n) std::cout << g.id(n) << std::endl;
  std::cout << ":-)" << std::endl;
  for (SubGW::EdgeIt e(gw); 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 SubGW::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


The documentation for this class was generated from the following file:
Generated on Sat Aug 27 14:15:31 2005 for LEMON by  doxygen 1.4.4