checked
parameter is true then it filters the edgeset to do not get invalid edges without source or target. Let be a directed graph and suppose that the graph instance g
of type ListGraph implements . Let moreover and be bool-valued functions resp. on the node-set and edge-set. SubGraphAdaptor<...>NodeIt iterates on the node-set and SubGraphAdaptor<...>EdgeIt iterates on the edge-set . 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;
1 :-) 1
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.
#include <lemon/graph_adaptor.h>