#include <lemon/graph_adaptor.h>
g
of type ListGraph implements 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;
1 :-) 1
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.