/// <summary> /// Creates a graph where the given list of nodes are sequentially connected to each other /// with bidirectional links. /// </summary> /// <remarks> /// For example, if the given list of nodes was {0, 1, 2, 3}, then the graph would consist of /// bidi links between (0,1), (1,2), and (2,3). /// </remarks> /// <param name="graph"></param> /// <param name="nodes"></param> /// <param name="linkData"></param> public static void BidiLine <TNode, TLink>(Graph <TNode, TLink> graph, IReadOnlyList <TNode> nodes, TLink linkData) { ArgCheck(graph, nodes, linkData); if (nodes.Count <= 1) { throw new InvalidOperationException("Cannot create a line topology with fewer than 2 nodes."); } for (int i = 0; i < nodes.Count - 1; i++) { graph.AddDual(nodes[i], nodes[i + 1], linkData); } }