Algorithmic Solutions > LEDA > LEDA Guide > Graphs and Related Data Types > Sets of Nodes > Example
Example Sets of NodesThe following example shows how a set of nodes can be used. First a random
#include <LEDA/graph/graph.h>
#include <LEDA/graph/node_set.h>
using namespace leda;
int main()
{
graph G;
random_graph(G,12,30);
node_set S(G);
node v;
forall_nodes(v,G) S.insert(v);
forall(v,S) { G.print_node(v); std::cout << std::endl; }
std::cout << std::endl;
v=G.choose_node();
G.print_node(v);
if (S.member(v)) std::cout << " is a member of S\n";
else std::cout << " is no member of S\n";
node w=G.new_node();
G.print_node(w);
if (S.member(w)) std::cout << " is a member of S\n";
else std::cout << " is no member of S\n";
return 0;
}
|
See also:Manual Entries: |