What is a Graph? · Definitions
Lesson 8
Now, assume that the graph \(G(V,E)\) is directed and use the following as a working toy example: \[V=\{A, B, C, D\} \text{ and }E=\{(A, B), (B, C), (C, D), (B, D), (A, D), (D, A)\}.\]

from networkx import DiGraph
graph = DiGraph(['AB', 'BC', 'AD', 'BD', 'CD', 'DA'])
for node in ('A', 'D'):
print(f'indeg({node})={graph.in_degree(node)}', end=' ')
print(f'outdeg({node})={graph.out_degree(node)}', end=' ')indeg(A)=1 outdeg(A)=2 indeg(D)=3 outdeg(D)=1
Walks, paths, and cycles in directed graphs are defined similarly to the undirected case, but they need to respect the directions on edges. For example, \(B \to D \to C\) is not a walk in the toy graph above, since there is no edge \((D,C)\) in the graph.