Skip to content

Commit 58b9714

Browse files
committed
simplified List Parameters
1 parent 6c2f87a commit 58b9714

File tree

107 files changed

+2352
-2586
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+2352
-2586
lines changed

src/QuikGraph/Algorithms/Exploration/CloneableVertexGraphExplorerAlgorithm.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,14 @@ public void AddTransitionFactory([NotNull] ITransitionFactory<TVertex, TEdge> tr
189189
_transitionFactories.Add(transitionFactory);
190190
}
191191

192-
/// <summary>
193-
/// Adds new <see cref="ITransitionFactory{TVertex,TEdge}"/>s to this algorithm.
194-
/// </summary>
195-
/// <param name="transitionFactories">Transition factories to add.</param>
196-
/// <exception cref="T:System.ArgumentNullException"><paramref name="transitionFactories"/> is <see langword="null"/>.</exception>
192+
/// <summary>Adds new <see cref="ITransitionFactory{TVertex,TEdge}"/>s to this algorithm. </summary>
193+
public void AddTransitionFactories(
194+
[NotNull, ItemNotNull] params ITransitionFactory<TVertex, TEdge>[] transitionFactories)
195+
{
196+
AddTransitionFactories(transitionFactories.AsEnumerable());
197+
}
198+
199+
/// <summary>Adds new <see cref="ITransitionFactory{TVertex,TEdge}"/>s to this algorithm. </summary>
197200
public void AddTransitionFactories(
198201
[NotNull, ItemNotNull] IEnumerable<ITransitionFactory<TVertex, TEdge>> transitionFactories)
199202
{

src/QuikGraph/Algorithms/TarjanOfflineLeastCommonAncestorAlgorithm.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,13 @@ public bool TryGetVertexPairs(out IEnumerable<SEquatableEdge<TVertex>> pairs)
124124
return pairs != null;
125125
}
126126

127-
/// <summary>
128-
/// Sets vertices pairs.
129-
/// </summary>
127+
/// <summary> Sets vertices pairs. </summary>
128+
/// <param name="pairs">Vertices pairs.</param>
129+
/// <exception cref="T:System.ArgumentNullException"><paramref name="pairs"/> is <see langword="null"/>.</exception>
130+
/// <exception cref="T:System.ArgumentException"><paramref name="pairs"/> is empty or any vertex from pairs is not part of <see cref="AlgorithmBase{TGraph}.VisitedGraph"/>.</exception>
131+
public void SetVertexPairs([NotNull] params SEquatableEdge<TVertex>[] pairs) => SetVertexPairs(pairs.AsEnumerable());
132+
133+
/// <summary> Sets vertices pairs. </summary>
130134
/// <param name="pairs">Vertices pairs.</param>
131135
/// <exception cref="T:System.ArgumentNullException"><paramref name="pairs"/> is <see langword="null"/>.</exception>
132136
/// <exception cref="T:System.ArgumentException"><paramref name="pairs"/> is empty or any vertex from pairs is not part of <see cref="AlgorithmBase{TGraph}.VisitedGraph"/>.</exception>

src/QuikGraph/Extensions/EdgeExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ internal static bool SortedVertexEqualityInternal<TVertex>(
414414
[Pure]
415415
[NotNull]
416416
public static IEnumerable<SReversedEdge<TVertex, TEdge>> ReverseEdges<TVertex, TEdge>(
417-
[NotNull, ItemNotNull] IEnumerable<TEdge> edges)
417+
[NotNull, ItemNotNull] this IEnumerable<TEdge> edges)
418418
where TEdge : IEdge<TVertex>
419419
{
420420
if (edges is null)

src/QuikGraph/Interfaces/Graphs/IMutableEdgeListGraph.cs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using JetBrains.Annotations;
45

56
namespace QuikGraph
67
{
8+
/// <summary> Extension Methods for <see cref="IMutableEdgeListGraph{TVertex, TEdge}"/> </summary>
9+
public static class MutableEdgeListGraph
10+
{
11+
/// <summary> Adds the <paramref name="edges"/> to the <paramref name="graph"/>. </summary>
12+
public static int AddEdgeRange<TVertex, TEdge>(this IMutableEdgeListGraph<TVertex, TEdge> graph
13+
, [NotNull, ItemNotNull] params TEdge[] edges) where TEdge : IEdge<TVertex>
14+
=> graph.AddEdgeRange(edges.AsEnumerable());
15+
16+
}
17+
718
/// <summary>
819
/// A mutable edge list graph with vertices of type <typeparamref name="TVertex"/>
920
/// and edges of type <typeparamref name="TEdge"/>.
@@ -27,9 +38,7 @@ public interface IMutableEdgeListGraph<TVertex, TEdge> : IMutableGraph<TVertex,
2738
/// </summary>
2839
event EdgeAction<TVertex, TEdge> EdgeAdded;
2940

30-
/// <summary>
31-
/// Adds a set of edges to this graph.
32-
/// </summary>
41+
/// <summary> Adds the <paramref name="edges"/> to this graph. </summary>
3342
/// <param name="edges">Edges to add.</param>
3443
/// <returns>The number of edges successfully added to this graph.</returns>
3544
/// <exception cref="T:System.ArgumentNullException">

src/QuikGraph/Interfaces/Graphs/IMutableVertexSet.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
4+
using System.Linq;
35
using JetBrains.Annotations;
46

57
namespace QuikGraph
68
{
7-
/// <summary>
8-
/// Represents a mutable set of vertices.
9-
/// </summary>
10-
/// <typeparam name="TVertex">Vertex type.</typeparam>
9+
/// <summary> Extension Methods for <see cref="IMutableVertexSet{TVertex}"/> </summary>
10+
public static class MutableVertexSet
11+
{
12+
/// <summary>
13+
///
14+
/// </summary>
15+
/// <returns></returns>
16+
public static int AddVertexRange<TVertex>(this IMutableVertexSet<TVertex> set
17+
, [NotNull, ItemNotNull] params TVertex[] vertices) => set.AddVertexRange(vertices.AsEnumerable());
18+
19+
}
20+
21+
/// <summary> Represents a mutable set of vertices.</summary>
1122
public interface IMutableVertexSet<TVertex> : IVertexSet<TVertex>
1223
{
1324
/// <summary>

src/QuikGraph/Structures/Graphs/AdjacencyGraph.cs

+3
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ public virtual bool AddEdge(TEdge edge)
432432
return AddEdgeInternal(edge);
433433
}
434434

435+
/// <inheritdoc />
436+
public int AddEdgeRange(params TEdge[] edges) => AddEdgeRange(edges.AsEnumerable());
437+
435438
/// <inheritdoc />
436439
public int AddEdgeRange(IEnumerable<TEdge> edges)
437440
{

src/QuikGraph/Structures/Graphs/BidirectionalGraph.cs

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.Diagnostics;
45
using System.Linq;
@@ -517,6 +518,9 @@ public virtual bool AddEdge(TEdge edge)
517518
return AddEdgeInternal(edge);
518519
}
519520

521+
/// <inheritdoc />
522+
public int AddEdgeRange(params TEdge[] edges) => AddEdgeRange(edges.AsEnumerable());
523+
520524
/// <inheritdoc />
521525
public int AddEdgeRange(IEnumerable<TEdge> edges)
522526
{

src/QuikGraph/Structures/Graphs/BidirectionalMatrixGraph.cs

+3
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,9 @@ public bool AddEdge(TEdge edge)
492492
throw new ParallelEdgeNotAllowedException();
493493
}
494494

495+
/// <inheritdoc />
496+
public int AddEdgeRange(params TEdge[] edges) => AddEdgeRange(edges.AsEnumerable());
497+
495498
/// <inheritdoc />
496499
public int AddEdgeRange(IEnumerable<TEdge> edges)
497500
{

src/QuikGraph/Structures/Graphs/ClusteredAdjacencyGraph.cs

+25-10
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,12 @@ public virtual bool AddVertex([NotNull] TVertex vertex)
226226
return Wrapped.AddVertex(vertex);
227227
}
228228

229-
/// <summary>
230-
/// Adds given vertices to this graph.
231-
/// </summary>
232-
/// <param name="vertices">Vertices to add.</param>
229+
/// <summary> Adds the <paramref name="vertices"/> to this graph. </summary>
230+
/// <returns>The number of vertex added.</returns>
231+
public virtual int AddVertexRange([NotNull, ItemNotNull] params TVertex[] vertices) => AddVertexRange(vertices.AsEnumerable());
232+
233+
/// <summary> Adds the <paramref name="vertices"/> to this graph. </summary>
233234
/// <returns>The number of vertex added.</returns>
234-
/// <exception cref="T:System.ArgumentNullException">
235-
/// <paramref name="vertices"/> is <see langword="null"/> or at least one of them is <see langword="null"/>.
236-
/// </exception>
237235
public virtual int AddVertexRange([NotNull, ItemNotNull] IEnumerable<TVertex> vertices)
238236
{
239237
if (vertices is null)
@@ -332,6 +330,17 @@ public virtual bool AddVerticesAndEdge([NotNull] TEdge edge)
332330
return AddEdge(edge);
333331
}
334332

333+
/// <summary>
334+
/// Adds a set of edges (and it's vertices if necessary).
335+
/// </summary>
336+
/// <param name="edges">Edges to add.</param>
337+
/// <returns>The number of edges added.</returns>
338+
/// <exception cref="T:System.ArgumentNullException">
339+
/// <paramref name="edges"/> is <see langword="null"/> or at least one of them is <see langword="null"/>.
340+
/// </exception>
341+
public int AddVerticesAndEdgeRange([NotNull, ItemNotNull] params TEdge[] edges)
342+
=> AddVerticesAndEdgeRange(edges.AsEnumerable());
343+
335344
/// <summary>
336345
/// Adds a set of edges (and it's vertices if necessary).
337346
/// </summary>
@@ -369,9 +378,15 @@ public virtual bool AddEdge([NotNull] TEdge edge)
369378
return Wrapped.AddEdge(edge);
370379
}
371380

372-
/// <summary>
373-
/// Adds a set of edges to this graph.
374-
/// </summary>
381+
/// <summary> Adds a set of edges to this graph. </summary>
382+
/// <param name="edges">Edges to add.</param>
383+
/// <returns>The number of edges successfully added to this graph.</returns>
384+
/// <exception cref="T:System.ArgumentNullException">
385+
/// <paramref name="edges"/> is <see langword="null"/> or at least one of them is <see langword="null"/>.
386+
/// </exception>
387+
public int AddEdgeRange([NotNull, ItemNotNull] params TEdge[] edges) => AddEdgeRange(edges.AsEnumerable());
388+
389+
/// <summary> Adds a set of edges to this graph. </summary>
375390
/// <param name="edges">Edges to add.</param>
376391
/// <returns>The number of edges successfully added to this graph.</returns>
377392
/// <exception cref="T:System.ArgumentNullException">

src/QuikGraph/Structures/Graphs/EdgeListGraph.cs

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.Diagnostics;
45
using System.Linq;
@@ -136,14 +137,18 @@ private bool ContainsEdge(TVertex source, TVertex target)
136137
/// <param name="edge">The edge to add.</param>
137138
/// <returns>True if the edge was added, false otherwise.</returns>
138139
/// <exception cref="T:System.ArgumentNullException"><paramref name="edge"/> is <see langword="null"/>.</exception>
139-
public bool AddVerticesAndEdge([NotNull] TEdge edge)
140-
{
141-
return AddEdge(edge);
142-
}
140+
public bool AddVerticesAndEdge([NotNull] TEdge edge) => AddEdge(edge);
143141

144-
/// <summary>
145-
/// Adds a set of edges (and it's vertices if necessary).
146-
/// </summary>
142+
/// <summary> Adds a set of edges (and it's vertices if necessary). </summary>
143+
/// <param name="edges">Edges to add.</param>
144+
/// <returns>The number of edges added.</returns>
145+
/// <exception cref="T:System.ArgumentNullException">
146+
/// <paramref name="edges"/> is <see langword="null"/> or at least one of them is <see langword="null"/>.
147+
/// </exception>
148+
public int AddVerticesAndEdgeRange([NotNull, ItemNotNull] params TEdge[] edges)
149+
=> AddVerticesAndEdgeRange(edges.AsEnumerable());
150+
151+
/// <summary> Adds a set of edges (and it's vertices if necessary). </summary>
147152
/// <param name="edges">Edges to add.</param>
148153
/// <returns>The number of edges added.</returns>
149154
/// <exception cref="T:System.ArgumentNullException">
@@ -180,6 +185,9 @@ public bool AddEdge(TEdge edge)
180185
return true;
181186
}
182187

188+
/// <inheritdoc />
189+
public int AddEdgeRange(params TEdge[] edges) => AddEdgeRange(edges.AsEnumerable());
190+
183191
/// <inheritdoc />
184192
public int AddEdgeRange(IEnumerable<TEdge> edges)
185193
{

src/QuikGraph/Structures/Graphs/UndirectedGraph.cs

+6
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ public bool AddVertex(TVertex vertex)
347347
return true;
348348
}
349349

350+
/// <inheritdoc />
351+
public int AddVertexRange(params TVertex[] vertices) => AddVertexRange(vertices.AsEnumerable());
352+
350353
/// <inheritdoc />
351354
public int AddVertexRange(IEnumerable<TVertex> vertices)
352355
{
@@ -569,6 +572,9 @@ public bool AddEdge(TEdge edge)
569572
return true;
570573
}
571574

575+
/// <inheritdoc />
576+
public int AddEdgeRange(params TEdge[] edges) => AddEdgeRange(edges.AsEnumerable());
577+
572578
/// <inheritdoc />
573579
public int AddEdgeRange(IEnumerable<TEdge> edges)
574580
{

tests/QuikGraph.Data.Tests/DataSetGraphExtensionsTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public void ToGraph()
3737

3838
graph = dataSet.ToGraph();
3939

40-
AssertHasVertices(graph, new[] { ships, modules });
41-
AssertNoEdge(graph);
40+
graph.AssertHasVertices(ships, modules);
41+
graph.AssertNoEdge();
4242
Assert.AreSame(dataSet, graph.DataSet);
4343

4444

@@ -88,7 +88,7 @@ public void ToGraph()
8888

8989
graph = dataSet.ToGraph();
9090

91-
AssertHasVertices(graph, new[] { computers, users, printers, phones });
91+
graph.AssertHasVertices(computers, users, printers, phones);
9292
AssertHasRelations(
9393
graph,
9494
new[]

tests/QuikGraph.Data.Tests/DataSetGraphPopulatorAlgorithmTests.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public void Compute()
7878
algorithm = new DataSetGraphPopulatorAlgorithm(graph, dataSet);
7979
algorithm.Compute();
8080

81-
AssertHasVertices(graph, new[]{ customers, orders });
82-
AssertNoEdge(graph);
81+
graph.AssertHasVertices(customers, orders);
82+
graph.AssertNoEdge();
8383

8484
// Table with relations
8585
dataSet = new DataSet();
@@ -110,14 +110,14 @@ public void Compute()
110110
algorithm = new DataSetGraphPopulatorAlgorithm(graph, dataSet);
111111
algorithm.Compute();
112112

113-
AssertHasVertices(graph, new[]{ addresses, customers, orders });
113+
graph.AssertHasVertices(addresses, customers, orders);
114114
AssertHasRelations(
115115
graph,
116-
new[]
116+
new DataRelationEdge[]
117117
{
118-
new DataRelationEdge(customerOrders),
119-
new DataRelationEdge(customersAddresses),
120-
new DataRelationEdge(warehousesAddresses)
118+
new (customerOrders),
119+
new (customersAddresses),
120+
new (warehousesAddresses)
121121
});
122122
}
123123
}

tests/QuikGraph.Graphviz.Tests/Extensions/GraphvizExtensionsTests.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,10 @@ public void ToGraphvizWithInit()
180180
wrappedGraph.AddVertex(5);
181181
var clusteredGraph = new ClusteredAdjacencyGraph<int, IEdge<int>>(wrappedGraph);
182182
ClusteredAdjacencyGraph<int, IEdge<int>> subGraph1 = clusteredGraph.AddCluster();
183-
subGraph1.AddVerticesAndEdgeRange(new[]
184-
{
183+
subGraph1.AddVerticesAndEdgeRange(
185184
Edge.Create(6, 7),
186185
Edge.Create(7, 8)
187-
});
186+
);
188187
ClusteredAdjacencyGraph<int, IEdge<int>> subGraph2 = clusteredGraph.AddCluster();
189188
subGraph2.AddVerticesAndEdge(Edge.Create(9, 10));
190189
subGraph2.AddVertex(11);

0 commit comments

Comments
 (0)