public UndirectedGraph(bool allowParallelEdges) { this.allowParallelEdges = allowParallelEdges; this.edgeEqualityComparer = EdgeExtensions.GetUndirectedVertexEquality <TVertex, TEdge>(); this.edges2 = new Dictionary <TVertex, List <TVertex> >(); //this.adjacentEdges = new VertexEdgeDictionary<TVertex, TEdge>(EqualityComparer<TVertex>.Default); }
public bool IsSelfEdge <TVertex, TEdge>(TEdge edge) where TEdge : IEdge <TVertex> { // TODO: add assertions to method EdgeExtensionsTest.IsSelfEdge(IEdge`1<!!0>) bool result = EdgeExtensions.IsSelfEdge <TVertex, TEdge>(edge); return(result); }
public bool IsPathWithoutCycles <TVertex, TEdge>(IEnumerable <TEdge> path) where TEdge : IEdge <TVertex> { // TODO: add assertions to method EdgeExtensionsTest.IsPathWithoutCycles(IEnumerable`1<!!1>) bool result = EdgeExtensions.IsPathWithoutCycles <TVertex, TEdge>(path); return(result); }
public bool IsAdjacent <TVertex, TEdge>(TEdge edge, TVertex vertex) where TEdge : IEdge <TVertex> { // TODO: add assertions to method EdgeExtensionsTest.IsAdjacent(!!1, !!0) bool result = EdgeExtensions.IsAdjacent <TVertex, TEdge>(edge, vertex); return(result); }
public SEquatableEdge <TVertex> ToVertexPair <TVertex, TEdge>(TEdge edge) where TEdge : IEdge <TVertex> { // TODO: add assertions to method EdgeExtensionsTest.ToVertexPair(IEdge`1<!!0>) SEquatableEdge <TVertex> result = EdgeExtensions.ToVertexPair <TVertex, TEdge>(edge); return(result); }
/// <summary>Test stub for HasCycles(IEnumerable`1<!!1>)</summary> private bool HasCycles <TVertex, TEdge>(IEnumerable <TEdge> path) where TEdge : IEdge <TVertex> { // TODO: add assertions to method EdgeExtensionsTest.HasCycles(IEnumerable`1<!!1>) bool result = EdgeExtensions.HasCycles <TVertex, TEdge>(path); return(result); }
public TVertex GetOtherVertex <TVertex, TEdge>(TEdge edge, TVertex vertex) where TEdge : IEdge <TVertex> { // TODO: add assertions to method EdgeExtensionsTest.GetOtherVertex(!!1, !!0) TVertex result = EdgeExtensions.GetOtherVertex <TVertex, TEdge>(edge, vertex); Assert.AreNotEqual(vertex, result); Assert.IsTrue( edge.Source.Equals(result) || edge.Target.Equals(result)); return(result); }
public bool IsPredecessor <TVertex, TEdge>( IDictionary <TVertex, TEdge> predecessors, TVertex root, TVertex vertex ) where TEdge : IEdge <TVertex> { // TODO: add assertions to method EdgeExtensionsTest.IsPredecessor(IDictionary`2<!!0,!!1>, !!0, !!0) bool result = EdgeExtensions.IsPredecessor <TVertex, TEdge>(predecessors, root, vertex); return(result); }
public bool TryGetPath <TVertex, TEdge>( IDictionary <TVertex, TEdge> predecessors, TVertex v, out IEnumerable <TEdge> result ) where TEdge : IEdge <TVertex> { // TODO: add assertions to method EdgeExtensionsTest.TryGetPath(IDictionary`2<!!0,!!1>, !!0, IEnumerable`1<!!1>&) bool result01 = EdgeExtensions.TryGetPath <TVertex, TEdge>(predecessors, v, out result); return(result01); }
public bool TryGetOutEdges(TVertex v, out IEnumerable<SReversedEdge<TVertex, TEdge>> edges) { IEnumerable<TEdge> inEdges; if (this.OriginalGraph.TryGetInEdges(v, out inEdges)) { edges = EdgeExtensions.ReverseEdges<TVertex, TEdge>(inEdges); return true; } else { edges = null; return false; } }
public bool RemoveEdge(TEdge edge) { bool removed = this.adjacentEdges[edge.Source].Remove(edge); if (removed) { if (!EdgeExtensions.IsSelfEdge <TVertex, TEdge>(edge)) { this.adjacentEdges[edge.Target].Remove(edge); } this.edgeCount--; Contract.Assert(this.edgeCount >= 0); this.OnEdgeRemoved(edge); return(true); } else { return(false); } }
public bool AddEdge(TEdge edge) { var sourceEdges = this.adjacentEdges[edge.Source]; if (!this.AllowParallelEdges) { if (this.ContainsEdgeBetweenVertices(sourceEdges, edge)) { return(false); } } sourceEdges.Add(edge); if (!EdgeExtensions.IsSelfEdge <TVertex, TEdge>(edge)) { var targetEdges = this.adjacentEdges[edge.Target]; targetEdges.Add(edge); } this.edgeCount++; this.OnEdgeAdded(edge); return(true); }
public IEnumerable<SReversedEdge<TVertex, TEdge>> OutEdges(TVertex v) { return EdgeExtensions.ReverseEdges<TVertex, TEdge>(this.OriginalGraph.InEdges(v)); }
public UndirectedGraph(bool allowParallelEdges) : this(allowParallelEdges, EdgeExtensions.GetUndirectedVertexEquality <TVertex, TEdge>()) { this.allowParallelEdges = allowParallelEdges; }