Suppose one wants to create a directed graph containing two nodes n1 and n2 and an edge from n1 to n2:
#include <GTL/graph.h> void main() { graph G; node n1 = G.new_node(); node n2 = G.new_node(); G.new_edge(n1, n2); cout << G << endl; }
Obviously this example can be extended to create any directed graph. But, of course, not all graphs are directed, hence it is possible to switch between directed and undirected, using
To determine, whether a graph is directed G.is_directed() can be used, which returns true iff G is directed.