public static TEdge GetEdge <TVertex, TEdge>(IEdgeSet <TVertex, TEdge> g, Random rnd) where TEdge : IEdge <TVertex> { if (g == null) { throw new ArgumentNullException("g"); } if (rnd == null) { throw new ArgumentNullException("random generator"); } if (g.EdgeCount == 0) { throw new ArgumentException("g is empty"); } int i = rnd.Next(g.EdgeCount); foreach (var e in g.Edges) { if (i == 0) { return(e); } else { --i; } } // failed throw new InvalidOperationException("Could not find edge"); }
public static void AssertNoEdge <TVertex, TEdge>(IEdgeSet <TVertex, TEdge> graph) where TEdge : IEdge <TVertex> { Assert.IsTrue(graph.IsEdgesEmpty); Assert.AreEqual(0, graph.EdgeCount); CollectionAssert.IsEmpty(graph.Edges); }
protected static void ContainsEdge_NullThrows_Test <TVertex, TEdge>( [NotNull] IEdgeSet <TVertex, TEdge> graph) where TEdge : class, IEdge <TVertex> { // ReSharper disable once AssignNullToNotNullAttribute // ReSharper disable once ReturnValueOfPureMethodIsNotUsed Assert.Throws <ArgumentNullException>(() => graph.ContainsEdge(null)); }
public RdfObject(INode node, IEdgeSet edgeSet = default(IEdgeSet)) : base(new Dict(node, edgeSet)) { var test = base._items as Dict; this.Node = test.Node; this.EdgeSet = test.EdgeSet; }
protected static void ContainsEdge_EquatableEdge_Test( [NotNull] IEdgeSet <int, EquatableEdge <int> > graph, [NotNull, InstantHandle] Action <EquatableEdge <int> > addVerticesAndEdge) { var edge1 = new EquatableEdge <int>(1, 2); var edge2 = new EquatableEdge <int>(1, 3); var edge3 = new EquatableEdge <int>(2, 1); var edge4 = new EquatableEdge <int>(2, 2); var otherEdge1 = new EquatableEdge <int>(1, 2); Assert.IsFalse(graph.ContainsEdge(edge1)); Assert.IsFalse(graph.ContainsEdge(edge2)); Assert.IsFalse(graph.ContainsEdge(edge3)); Assert.IsFalse(graph.ContainsEdge(edge4)); Assert.IsFalse(graph.ContainsEdge(otherEdge1)); addVerticesAndEdge(edge1); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsFalse(graph.ContainsEdge(edge2)); Assert.IsFalse(graph.ContainsEdge(edge3)); Assert.IsFalse(graph.ContainsEdge(edge4)); Assert.IsTrue(graph.ContainsEdge(otherEdge1)); addVerticesAndEdge(edge2); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsTrue(graph.ContainsEdge(edge2)); Assert.IsFalse(graph.ContainsEdge(edge3)); Assert.IsFalse(graph.ContainsEdge(edge4)); Assert.IsTrue(graph.ContainsEdge(otherEdge1)); addVerticesAndEdge(edge3); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsTrue(graph.ContainsEdge(edge2)); Assert.IsTrue(graph.ContainsEdge(edge3)); Assert.IsFalse(graph.ContainsEdge(edge4)); Assert.IsTrue(graph.ContainsEdge(otherEdge1)); addVerticesAndEdge(edge4); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsTrue(graph.ContainsEdge(edge2)); Assert.IsTrue(graph.ContainsEdge(edge3)); Assert.IsTrue(graph.ContainsEdge(edge4)); Assert.IsTrue(graph.ContainsEdge(otherEdge1)); addVerticesAndEdge(otherEdge1); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsTrue(graph.ContainsEdge(edge2)); Assert.IsTrue(graph.ContainsEdge(edge3)); Assert.IsTrue(graph.ContainsEdge(edge4)); Assert.IsTrue(graph.ContainsEdge(otherEdge1)); // Both vertices not in graph Assert.IsFalse(graph.ContainsEdge(new EquatableEdge <int>(0, 10))); // Source not in graph Assert.IsFalse(graph.ContainsEdge(new EquatableEdge <int>(0, 1))); // Target not in graph Assert.IsFalse(graph.ContainsEdge(new EquatableEdge <int>(1, 0))); }
public static void AssertEdgeCountEqual <TVertex, TEdge>( [NotNull] this IEdgeSet <TVertex, TEdge> left, [NotNull] IEdgeSet <TVertex, TEdge> right) where TEdge : IEdge <TVertex> { Assert.IsNotNull(left); Assert.IsNotNull(right); Assert.AreEqual(left.EdgeCount, right.EdgeCount); }
public static void AssertHasEdges <TVertex, TEdge>( IEdgeSet <TVertex, SReversedEdge <TVertex, TEdge> > graph, IEnumerable <TEdge> edges) where TEdge : IEdge <TVertex> { AssertHasEdges( graph, edges.Select(edge => new SReversedEdge <TVertex, TEdge>(edge))); }
bool IEdgeSet <TVertex, TEdge> .ContainsEdge(TEdge edge) { IEdgeSet <TVertex, TEdge> ithis = this; Contract.Requires(edge != null); Contract.Ensures(Contract.Result <bool>() == Contract.Exists(ithis.Edges, e => e.Equals(edge))); return(default(bool)); }
public static IEnumerable <INode> AddRange <T>(this IEdgeSet set, IEnumerable <T> objs) { Contract.Requires(set != null); foreach (var obj in objs) { yield return(set.Add <T>(obj)); } }
public object Deserialize(INode subject, IEdgeSet edges) { Contract.Requires(subject is IriNode || subject is BlankNode); Contract.Requires(edges != null); object result = null; this.Deserialize(subject, edges, ref result); return(result); }
public static TEdge GetEdge <TVertex, TEdge>( [NotNull] IEdgeSet <TVertex, TEdge> graph, [NotNull] Random rng) where TEdge : IEdge <TVertex> { if (graph is null) { throw new ArgumentNullException(nameof(graph)); } return(GetEdge <TVertex, TEdge>(graph.Edges, graph.EdgeCount, rng)); }
public static INode Add <T>(this IEdgeSet set, T obj) { Contract.Requires(set != null); var s = new EdgeSerializer(); var edges = s.Serialize(obj); set.AddRange(edges); return(null); }
private static int EvaluateEdgeCrossing( [NotNull] IEdgeSet <object, IEdge <object> > compoundGraph, [NotNull] ILayoutAlgorithm <object, IEdge <object>, CompoundGraph <object, IEdge <object> > > algorithm, [NotNull] IReadOnlyDictionary <object, Size> verticesSizes) { int crossings = 0; foreach (IEdge <object> edge in compoundGraph.Edges) { Point uPos1 = algorithm.VerticesPositions[edge.Source]; Point vPos1 = algorithm.VerticesPositions[edge.Target]; Size uSize1 = verticesSizes[edge.Source]; Size vSize1 = verticesSizes[edge.Target]; Point uPoint1 = LayoutUtils.GetClippingPoint(uSize1, uPos1, vPos1); Point vPoint1 = LayoutUtils.GetClippingPoint(vSize1, vPos1, uPos1); foreach (IEdge <object> edge2 in compoundGraph.Edges) { if (ReferenceEquals(edge, edge2)) { continue; } Point uPos2 = algorithm.VerticesPositions[edge.Source]; Point vPos2 = algorithm.VerticesPositions[edge.Target]; Size uSize2 = verticesSizes[edge.Source]; Size vSize2 = verticesSizes[edge.Target]; Point uPoint2 = LayoutUtils.GetClippingPoint(uSize2, uPos2, vPos2); Point vPoint2 = LayoutUtils.GetClippingPoint(vSize2, vPos2, uPos2); Vector v1 = vPoint1 - uPoint1; Vector v2 = vPoint2 - uPoint2; if (v1 == v2 || v1 == -v2) { continue; // Parallel edges } double t2 = (uPoint1.Y - uPoint2.Y + (uPoint2.X - uPoint1.X) * v1.Y / v1.X) / (v2.Y - v2.X * v1.Y / v1.X); double t1 = (uPoint2.X - uPoint1.X + t2 * v2.X) / v1.X; Point p = uPoint1 + t1 * v1; bool b1 = t1 > 0 && (p - uPoint1).Length < (vPoint1 - uPoint1).Length; bool b2 = t2 > 0 && (p - uPoint2).Length < (vPoint2 - uPoint2).Length; if (b1 && b2) { ++crossings; } } } return(crossings); }
public static void AssertHasEdges <TVertex, TEdge>( IEdgeSet <TVertex, TEdge> graph, IEnumerable <TEdge> edges) where TEdge : IEdge <TVertex> { TEdge[] edgeArray = edges.ToArray(); CollectionAssert.IsNotEmpty(edgeArray); Assert.IsFalse(graph.IsEdgesEmpty); Assert.AreEqual(edgeArray.Length, graph.EdgeCount); CollectionAssert.AreEquivalent(edgeArray, graph.Edges); }
public static IDictionary <TEdge, double> ConstantCapacities <TVertex, TEdge>( IEdgeSet <TVertex, TEdge> g, double value) where TEdge : IEdge <TVertex> { GraphContracts.AssumeNotNull(g, "g"); var capacities = new Dictionary <TEdge, double>(g.EdgeCount); foreach (var e in g.Edges) { capacities.Add(e, value); } return(capacities); }
protected static void AddEdge_ImmutableGraph_WithUpdate <TGraph>( TGraph wrappedGraph, Func <IEdgeSet <int, Edge <int> > > createGraph) where TGraph : IMutableVertexSet <int>, IMutableEdgeListGraph <int, Edge <int> > { IEdgeSet <int, Edge <int> > graph = createGraph(); var edge = new Edge <int>(1, 2); wrappedGraph.AddVertex(1); wrappedGraph.AddVertex(2); wrappedGraph.AddEdge(edge); AssertHasEdges(graph, new[] { edge }); // Graph is updated }
protected static void AddEdge_ImmutableGraph_NoUpdate <TGraph>( [NotNull] TGraph wrappedGraph, [NotNull, InstantHandle] Func <IEdgeSet <int, Edge <int> > > createGraph) where TGraph : IMutableVertexSet <int>, IMutableEdgeListGraph <int, Edge <int> > { IEdgeSet <int, Edge <int> > graph = createGraph(); var edge = new Edge <int>(1, 2); wrappedGraph.AddVertex(1); wrappedGraph.AddVertex(2); wrappedGraph.AddEdge(edge); AssertNoEdge(graph); // Graph is not updated }
public static void AssertHasRelations( [NotNull] IEdgeSet <DataTable, DataRelationEdge> graph, [NotNull, ItemNotNull] IEnumerable <DataRelationEdge> relations) { DataRelation[] relationArray = relations .Select(r => r.Relation) .ToArray(); CollectionAssert.IsNotEmpty(relationArray); Assert.IsFalse(graph.IsEdgesEmpty); Assert.AreEqual(relationArray.Length, graph.EdgeCount); CollectionAssert.AreEquivalent( relationArray, graph.Edges.Select(r => r.Relation)); }
public static Dictionary <TEdge, double> UnaryWeightsFromEdgeList( IEdgeSet <TVertex, TEdge> graph) { if (graph == null) { throw new ArgumentNullException("graph"); } Dictionary <TEdge, double> weights = new Dictionary <TEdge, double>(); foreach (var e in graph.Edges) { weights.Add(e, 1); } return(weights); }
/// <summary> /// Gets the edge identity. /// </summary> /// <typeparam name="TVertex">The type of the vertex.</typeparam> /// <typeparam name="TEdge">The type of the edge.</typeparam> /// <param name="graph">The graph.</param> /// <returns></returns> public static EdgeIdentity <TVertex, TEdge> GetEdgeIdentity <TVertex, TEdge>(this IEdgeSet <TVertex, TEdge> graph) where TEdge : IEdge <TVertex> { Contract.Requires(graph != null); // create dictionary var ids = new Dictionary <TEdge, string>(graph.EdgeCount); return(e => { string id; if (!ids.TryGetValue(e, out id)) { ids[e] = id = ids.Count.ToString(); } return id; }); }
protected static void CheckEdgeCount <TVertex, TEdge>( IEdgeSet <TVertex, TEdge> graph, IEdgeListGraph <AdjacencyGraph <TVertex, TEdge>, CondensedEdge <TVertex, TEdge, AdjacencyGraph <TVertex, TEdge> > > condensedGraph) where TEdge : IEdge <TVertex> { // Check edge count int count = 0; foreach (CondensedEdge <TVertex, TEdge, AdjacencyGraph <TVertex, TEdge> > edges in condensedGraph.Edges) { count += edges.Edges.Count; } foreach (AdjacencyGraph <TVertex, TEdge> vertices in condensedGraph.Vertices) { count += vertices.EdgeCount; } Assert.AreEqual(graph.EdgeCount, count, $"{nameof(graph.EdgeCount)} does not match."); }
public static void AssertHasEdges_DeepCheck <TVertex>( [NotNull] IEdgeSet <TVertex, Edge <TVertex> > graph, [NotNull, ItemNotNull] IEnumerable <Edge <TVertex> > edges) { List <Edge <TVertex> > edgeList = edges.ToList(); CollectionAssert.IsNotEmpty(edgeList); Assert.IsFalse(graph.IsEdgesEmpty); Assert.AreEqual(edgeList.Count, graph.EdgeCount); foreach (Edge <TVertex> edge in graph.Edges) { Edge <TVertex> foundEdge = edgeList.FirstOrDefault( e => Equals(e.Source, edge.Source) && Equals(e.Target, edge.Target)); Assert.IsNotNull(foundEdge); edgeList.Remove(foundEdge); } }
object GetObjectFor(INode subject, IEdgeSet edges) { object result = null; var typeEdge = edges.AllWhere(subject: subject, predicate: Rdf.Schema.Rdf.Type).FirstOrDefault(); if (typeEdge != null) { var typeName = this.Map.GetTypeName(typeEdge.Object); if (typeName != null) { var type = Type.GetType(typeName, throwOnError: false, ignoreCase: true); if (type != null) { result = Activator.CreateInstance(type); } } } return(result ?? new ExpandoObject()); }
protected static void ContainsEdge_Test( [NotNull] GraphData <int, Edge <int> > data, [NotNull] IEdgeSet <int, Edge <int> > graph) { data.CheckCalls(0); data.ShouldReturnValue = false; var edge12 = new Edge <int>(1, 2); var edge21 = new Edge <int>(2, 1); Assert.IsFalse(graph.ContainsEdge(edge12)); data.CheckCalls(1); Assert.IsFalse(graph.ContainsEdge(edge21)); data.CheckCalls(1); data.ShouldReturnValue = true; Assert.IsFalse(graph.ContainsEdge(edge12)); data.CheckCalls(1); Assert.IsFalse(graph.ContainsEdge(edge21)); data.CheckCalls(1); var edge13 = new Edge <int>(1, 3); data.ShouldReturnEdges = new[] { edge12, edge13, edge21 }; Assert.IsTrue(graph.ContainsEdge(edge12)); data.CheckCalls(1); Assert.IsTrue(graph.ContainsEdge(edge21)); data.CheckCalls(1); var edge15 = new Edge <int>(1, 5); var edge51 = new Edge <int>(5, 1); var edge56 = new Edge <int>(5, 6); Assert.IsFalse(graph.ContainsEdge(edge15)); Assert.IsFalse(graph.ContainsEdge(edge51)); Assert.IsFalse(graph.ContainsEdge(edge56)); }
public T Deserialize <T>(INode subject, IEdgeSet edges) where T : class { Contract.Requires(subject is IriNode || subject is BlankNode); Contract.Requires(edges != null); var typeEdge = edges.AllWhere(subject: subject, predicate: Rdf.Schema.Rdf.Type).FirstOrDefault(); if (typeEdge == null) { return(null); } var typeName = this.Map.GetTypeName(typeEdge.Object); if (typeName == null) { return(null); } var type = Type.GetType(typeName); if (type == null) { return(null); } if (type != typeof(T) && typeof(T).GetTypeInfo().IsSubclassOf(type)) { return(null); } object result = default(T); this.Deserialize(subject, edges, ref result); return(result as T); }
public static TEdge GetEdge <TVertex, TEdge>(IEdgeSet <TVertex, TEdge> g, Random rnd) where TEdge : IEdge <TVertex> { Contract.Requires(g != null); Contract.Requires(rnd != null); Contract.Requires(g.EdgeCount > 0); int i = rnd.Next(g.EdgeCount); foreach (var e in g.Edges) { if (i == 0) { return(e); } else { --i; } } // failed throw new InvalidOperationException("Could not find edge"); }
protected static void ContainsEdge_DefaultNullThrows_Test <TVertex>( [NotNull] IEdgeSet <TVertex, SEquatableEdge <TVertex> > graph) { // ReSharper disable once AssignNullToNotNullAttribute // ReSharper disable once ReturnValueOfPureMethodIsNotUsed Assert.Throws <ArgumentNullException>(() => graph.ContainsEdge(default));
private void Deserialize(INode subject, IEdgeSet edges, ref object obj, bool throwOnMissing = false) { var literal = subject as LiteralNode; if (literal != null) { if (literal.TryGetValue(out obj)) { return; } } if (obj == null) { obj = this.GetObjectFor(subject, edges); } var propertyEdges = edges.AllWhere(subject: subject); foreach (var propertyEdge in propertyEdges) { if (propertyEdge.Predicate.Equals(Rdf.Schema.Rdf.Type)) { continue; } string propertyName; if (!this.Map.GetPropertyName(propertyEdge.Predicate, out propertyName)) { if (throwOnMissing) { throw new MemberAccessException("Can not get property for predicate " + propertyEdge.Predicate); } continue; } var property = obj.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if (property == null || property.CanWrite == false) { if (throwOnMissing) { throw new MemberAccessException("Can not set property " + propertyName); } continue; } object value = null; this.Deserialize(propertyEdge.Object, edges, ref value); try { property.SetValue(obj, value); } catch (Exception e) when(e is ArgumentException || e is MethodAccessException || e is TargetInvocationException) { if (throwOnMissing) { throw; } } } }
protected static void ContainsEdge_EquatableEdge_ImmutableGraph_ReversedTest( IMutableVertexAndEdgeSet <int, EquatableEdge <int> > wrappedGraph, Func <IEdgeSet <int, SReversedEdge <int, EquatableEdge <int> > > > createGraph) { IEdgeSet <int, SReversedEdge <int, EquatableEdge <int> > > graph = createGraph(); var edge1 = new EquatableEdge <int>(1, 2); var reversedEdge1 = new SReversedEdge <int, EquatableEdge <int> >(edge1); var edge2 = new EquatableEdge <int>(1, 3); var reversedEdge2 = new SReversedEdge <int, EquatableEdge <int> >(edge2); var edge3 = new EquatableEdge <int>(2, 1); var reversedEdge3 = new SReversedEdge <int, EquatableEdge <int> >(edge3); var edge4 = new EquatableEdge <int>(2, 2); var reversedEdge4 = new SReversedEdge <int, EquatableEdge <int> >(edge4); var otherEdge1 = new EquatableEdge <int>(1, 2); var reversedOtherEdge1 = new SReversedEdge <int, EquatableEdge <int> >(otherEdge1); Assert.IsFalse(graph.ContainsEdge(reversedEdge1)); Assert.IsFalse(graph.ContainsEdge(reversedEdge2)); Assert.IsFalse(graph.ContainsEdge(reversedEdge3)); Assert.IsFalse(graph.ContainsEdge(reversedEdge4)); Assert.IsFalse(graph.ContainsEdge(reversedOtherEdge1)); wrappedGraph.AddVerticesAndEdge(edge1); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(reversedEdge1)); Assert.IsFalse(graph.ContainsEdge(reversedEdge2)); Assert.IsFalse(graph.ContainsEdge(reversedEdge3)); Assert.IsFalse(graph.ContainsEdge(reversedEdge4)); Assert.IsTrue(graph.ContainsEdge(reversedOtherEdge1)); wrappedGraph.AddVerticesAndEdge(edge2); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(reversedEdge1)); Assert.IsTrue(graph.ContainsEdge(reversedEdge2)); Assert.IsFalse(graph.ContainsEdge(reversedEdge3)); Assert.IsFalse(graph.ContainsEdge(reversedEdge4)); Assert.IsTrue(graph.ContainsEdge(reversedOtherEdge1)); wrappedGraph.AddVerticesAndEdge(edge3); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(reversedEdge1)); Assert.IsTrue(graph.ContainsEdge(reversedEdge2)); Assert.IsTrue(graph.ContainsEdge(reversedEdge3)); Assert.IsFalse(graph.ContainsEdge(reversedEdge4)); Assert.IsTrue(graph.ContainsEdge(reversedOtherEdge1)); wrappedGraph.AddVerticesAndEdge(edge4); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(reversedEdge1)); Assert.IsTrue(graph.ContainsEdge(reversedEdge2)); Assert.IsTrue(graph.ContainsEdge(reversedEdge3)); Assert.IsTrue(graph.ContainsEdge(reversedEdge4)); Assert.IsTrue(graph.ContainsEdge(reversedOtherEdge1)); wrappedGraph.AddVerticesAndEdge(otherEdge1); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(reversedEdge1)); Assert.IsTrue(graph.ContainsEdge(reversedEdge2)); Assert.IsTrue(graph.ContainsEdge(reversedEdge3)); Assert.IsTrue(graph.ContainsEdge(reversedEdge4)); Assert.IsTrue(graph.ContainsEdge(reversedOtherEdge1)); // Both vertices not in graph Assert.IsFalse( graph.ContainsEdge( new SReversedEdge <int, EquatableEdge <int> >( new EquatableEdge <int>(0, 10)))); // Source not in graph Assert.IsFalse( graph.ContainsEdge( new SReversedEdge <int, EquatableEdge <int> >( new EquatableEdge <int>(0, 1)))); // Target not in graph Assert.IsFalse( graph.ContainsEdge( new SReversedEdge <int, EquatableEdge <int> >( new EquatableEdge <int>(1, 0)))); }
protected static void ContainsEdge_ImmutableGraph_Test( [NotNull] IMutableVertexAndEdgeSet <int, Edge <int> > wrappedGraph, [NotNull, InstantHandle] Func <IEdgeSet <int, Edge <int> > > createGraph) { IEdgeSet <int, Edge <int> > graph = createGraph(); var edge1 = new Edge <int>(1, 2); var edge2 = new Edge <int>(1, 3); var edge3 = new Edge <int>(2, 1); var edge4 = new Edge <int>(2, 2); var otherEdge1 = new Edge <int>(1, 2); Assert.IsFalse(graph.ContainsEdge(edge1)); Assert.IsFalse(graph.ContainsEdge(edge2)); Assert.IsFalse(graph.ContainsEdge(edge3)); Assert.IsFalse(graph.ContainsEdge(edge4)); Assert.IsFalse(graph.ContainsEdge(otherEdge1)); wrappedGraph.AddVerticesAndEdge(edge1); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsFalse(graph.ContainsEdge(edge2)); Assert.IsFalse(graph.ContainsEdge(edge3)); Assert.IsFalse(graph.ContainsEdge(edge4)); Assert.IsFalse(graph.ContainsEdge(otherEdge1)); wrappedGraph.AddVerticesAndEdge(edge2); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsTrue(graph.ContainsEdge(edge2)); Assert.IsFalse(graph.ContainsEdge(edge3)); Assert.IsFalse(graph.ContainsEdge(edge4)); Assert.IsFalse(graph.ContainsEdge(otherEdge1)); wrappedGraph.AddVerticesAndEdge(edge3); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsTrue(graph.ContainsEdge(edge2)); Assert.IsTrue(graph.ContainsEdge(edge3)); Assert.IsFalse(graph.ContainsEdge(edge4)); Assert.IsFalse(graph.ContainsEdge(otherEdge1)); wrappedGraph.AddVerticesAndEdge(edge4); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsTrue(graph.ContainsEdge(edge2)); Assert.IsTrue(graph.ContainsEdge(edge3)); Assert.IsTrue(graph.ContainsEdge(edge4)); Assert.IsFalse(graph.ContainsEdge(otherEdge1)); wrappedGraph.AddVerticesAndEdge(otherEdge1); graph = createGraph(); Assert.IsTrue(graph.ContainsEdge(edge1)); Assert.IsTrue(graph.ContainsEdge(edge2)); Assert.IsTrue(graph.ContainsEdge(edge3)); Assert.IsTrue(graph.ContainsEdge(edge4)); Assert.IsTrue(graph.ContainsEdge(otherEdge1)); // Both vertices not in graph Assert.IsFalse(graph.ContainsEdge(new Edge <int>(0, 10))); // Source not in graph Assert.IsFalse(graph.ContainsEdge(new Edge <int>(0, 1))); // Target not in graph Assert.IsFalse(graph.ContainsEdge(new Edge <int>(1, 0))); }