#include <xnetwork/classes/reportviews.hpp>
template<typename nodeview_t>
NodeView class
A NodeView class to act as gra.nodes for a XNetwork Graph Set operations act on the nodes without considering data. Iteration is over nodes. Node data can be looked up like a dict. Use NodeDataView to iterate over node data or to specify a data attribute for lookup. NodeDataView is created by calling the NodeView.
Parameters
graph : XNetwork graph-like class
Examples
> gra = xnetwork::path_graph(3); > NV = gra.nodes(); > 2 : NV true > for n : NV: print(n); 0 1 2 > assert(NV & {1, 2, 3} == {1, 2}); > gra.add_node(2, color="blue"); > NV[2]; {"color": "blue"} > gra.add_node(8, color="red"); > NDV = gra.nodes(data=true); > (2, NV[2]] : NDV true > for n, dd : NDV: print((n, dd.get("color", "aqua"))); (0, "aqua"); (1, "aqua"); (2, "blue"); (8, "red"); > NDV[2] == NV[2]; true > NVdata = gra.nodes(data="color", default="aqua"); > (2, NVdata[2]] : NVdata true > for n, dd : NVdata: print((n, dd)); (0, "aqua"); (1, "aqua"); (2, "blue"); (8, "red"); > NVdata[2] == NV[2]; // NVdata gets "color", NV gets datadict false
Constructors, destructors, conversion operators
- NodeView(nodeview_t& nodes) explicit
Public functions
- auto size() -> auto
- auto begin() -> auto
- auto end() -> auto
- auto operator[](const Node& n) const -> const auto & -> auto
- auto operator[](const Node& n) -> auto & -> auto
- auto contains(const Node& n) -> bool -> auto