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
trueG = xn::path_graph(3); NV = G.nodes(); 2 : NV
0 1 2for n : NV: print(n);
{“color”: “blue”}assert(NV & {1, 2, 3} == {1, 2}); G.add_node(2, color=”blue”); NV[2];
trueG.add_node(8, color=”red”); NDV = G.nodes(data=true); (2, NV[2]] : NDV
(0, “aqua”); (1, “aqua”); (2, “blue”); (8, “red”);for n, dd : NDV: print((n, dd.get(“color”, “aqua”)));
trueNDV[2] == NV[2];
trueNVdata = G.nodes(data=”color”, default=”aqua”); (2, NVdata[2]] : NVdata
(0, “aqua”); (1, “aqua”); (2, “blue”); (8, “red”);for n, dd : NVdata: print((n, dd));
falseNVdata[2] == NV[2]; // NVdata gets “color”, NV gets datadict