protected static void TryGetOutEdges_ImmutableGraph_ReversedTest( [NotNull] IMutableVertexAndEdgeSet <int, Edge <int> > wrappedGraph, [NotNull, InstantHandle] Func <IImplicitGraph <int, SReversedEdge <int, Edge <int> > > > createGraph) { var edge1 = new Edge <int>(1, 2); var edge2 = new Edge <int>(1, 2); var edge3 = new Edge <int>(1, 3); var edge4 = new Edge <int>(2, 2); var edge5 = new Edge <int>(2, 4); var edge6 = new Edge <int>(3, 1); var edge7 = new Edge <int>(5, 4); wrappedGraph.AddVerticesAndEdgeRange(new[] { edge1, edge2, edge3, edge4, edge5, edge6, edge7 }); IImplicitGraph <int, SReversedEdge <int, Edge <int> > > graph = createGraph(); Assert.IsFalse(graph.TryGetOutEdges(0, out _)); Assert.IsTrue(graph.TryGetOutEdges(5, out IEnumerable <SReversedEdge <int, Edge <int> > > gotEdges)); CollectionAssert.IsEmpty(gotEdges); Assert.IsTrue(graph.TryGetOutEdges(3, out gotEdges)); AssertSameReversedEdges(new[] { edge3 }, gotEdges); Assert.IsTrue(graph.TryGetOutEdges(2, out gotEdges)); AssertSameReversedEdges(new[] { edge1, edge2, edge4 }, gotEdges); }
protected static void TryGetOutEdges_Test( [NotNull] IImplicitGraph <int, Edge <int> > graph, [NotNull, InstantHandle] Action <IEnumerable <Edge <int> > > addVerticesAndEdgeRange) { var edge1 = new Edge <int>(1, 2); var edge2 = new Edge <int>(1, 2); var edge3 = new Edge <int>(1, 3); var edge4 = new Edge <int>(2, 2); var edge5 = new Edge <int>(2, 4); var edge6 = new Edge <int>(3, 1); var edge7 = new Edge <int>(4, 5); addVerticesAndEdgeRange(new[] { edge1, edge2, edge3, edge4, edge5, edge6, edge7 }); Assert.IsFalse(graph.TryGetOutEdges(0, out _)); Assert.IsTrue(graph.TryGetOutEdges(5, out IEnumerable <Edge <int> > gotEdges)); CollectionAssert.IsEmpty(gotEdges); Assert.IsTrue(graph.TryGetOutEdges(3, out gotEdges)); CollectionAssert.AreEqual(new[] { edge6 }, gotEdges); Assert.IsTrue(graph.TryGetOutEdges(1, out gotEdges)); CollectionAssert.AreEqual(new[] { edge1, edge2, edge3 }, gotEdges); }
protected static void TryGetOutEdges_ImmutableGraph_Test( IMutableVertexAndEdgeSet <int, Edge <int> > wrappedGraph, Func <IImplicitGraph <int, SEquatableEdge <int> > > createGraph) { var edge1 = new Edge <int>(1, 2); var edge2 = new Edge <int>(1, 2); var edge3 = new Edge <int>(1, 3); var edge4 = new Edge <int>(2, 2); var edge5 = new Edge <int>(2, 4); var edge6 = new Edge <int>(3, 1); var edge7 = new Edge <int>(4, 5); wrappedGraph.AddVerticesAndEdgeRange(new[] { edge1, edge2, edge3, edge4, edge5, edge6, edge7 }); IImplicitGraph <int, SEquatableEdge <int> > graph = createGraph(); Assert.IsFalse(graph.TryGetOutEdges(0, out _)); Assert.IsTrue(graph.TryGetOutEdges(5, out IEnumerable <SEquatableEdge <int> > gotEdges)); CollectionAssert.IsEmpty(gotEdges); Assert.IsTrue(graph.TryGetOutEdges(3, out gotEdges)); CollectionAssert.AreEqual( new[] { new SEquatableEdge <int>(3, 1) }, gotEdges); Assert.IsTrue(graph.TryGetOutEdges(1, out gotEdges)); CollectionAssert.AreEqual( new[] { new SEquatableEdge <int>(1, 2), new SEquatableEdge <int>(1, 2), new SEquatableEdge <int>(1, 3) }, gotEdges); }
protected static void TryGetOutEdges_Throws_Test <TVertex, TEdge>( [NotNull] IImplicitGraph <TVertex, TEdge> graph) where TVertex : class where TEdge : IEdge <TVertex> { // ReSharper disable once AssignNullToNotNullAttribute Assert.Throws <ArgumentNullException>(() => graph.TryGetOutEdges(null, out _)); }
protected static void TryGetOutEdges_Test( [NotNull] GraphData <int, Edge <int> > data, [NotNull] IImplicitGraph <int, Edge <int> > graph) { data.CheckCalls(0); data.ShouldReturnValue = false; Assert.IsFalse(graph.TryGetOutEdges(1, out _)); data.CheckCalls(1); data.ShouldReturnValue = true; Assert.IsTrue(graph.TryGetOutEdges(1, out IEnumerable <Edge <int> > edges)); CollectionAssert.IsEmpty(edges); data.CheckCalls(1); data.ShouldReturnEdges = new[] { new Edge <int>(1, 4), new Edge <int>(1, 2) }; Assert.IsTrue(graph.TryGetOutEdges(1, out edges)); CollectionAssert.AreEqual(data.ShouldReturnEdges, edges); data.CheckCalls(1); }
public bool TryGetOutEdges(Vertex v, out IEnumerable <Edge> edges) { return(_impl.TryGetOutEdges(v, out edges)); }