The next example involves the directed and weighted graph, as follows:

The implementation is very similar to the one described in the previous section. However, some modifications are necessary. To start with, different values of the parameters of the constructor are used, namely `true` instead of `false` to indicate that a directed and weighted variant of edges is being considered. The suitable line of code is as follows:

Graph<int> graph = new Graph<int>(true, true);

The part regarding adding nodes is exactly the same as in the previous example:

Node<int> n1 = graph.AddNode(1); Node<int> n2 = graph.AddNode(2); ...