1function graph = cyclicGraph(numVertices)
2% This
is an alternative topologyFcn
for NetworkGenerator. It takes in
3% an integer number of vertices and returns a MATLAB digraph
object
4% representing a cyclic directed graph.
7 graph = addnode(graph, numVertices);
9 error(
'cyclicGraph:nonPositiveVertices',
'numVertices must be positive');
10 elseif numVertices == 1
11 graph = addedge(graph, 1, 1);
13 for i = 1 : numVertices - 1
14 graph = addedge(graph, i, i + 1);
16 graph = addedge(graph, numVertices, 1);