Template Class NodeView¶
Defined in File reportviews.hpp
Page Contents
Template Parameter Order¶
typename nodeview_t
Class Documentation¶
-
template<typename nodeview_t>
class NodeView¶ A NodeView class to act as G.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
G = xn::path_graph(3); NV = G.nodes(); 2 : NV
for n : NV: print(n);
assert(NV & {1, 2, 3} == {1, 2}); G.add_node(2, color=”blue”); NV[2];
G.add_node(8, color=”red”); NDV = G.nodes(data=true); (2, NV[2]] : NDV
for n, dd : NDV: print((n, dd.get(“color”, “aqua”)));
NDV[2] == NV[2];
NVdata = G.nodes(data=”color”, default=”aqua”); (2, NVdata[2]] : NVdata
for n, dd : NVdata: print((n, dd));
NVdata[2] == NV[2]; // NVdata gets “color”, NV gets datadict