/// <summary> /// Initializes a new instance of the <see cref="UnorientedGraphEdge"/> class. /// </summary> /// <param name="from">The node from which the edge starts.</param> /// <param name="to">The node where the edge ends.</param> public UnorientedGraphEdge(GraphNode from, GraphNode to) : base(from, to) { Contract.Requires(from != null); Contract.Requires(to != null); from.AddIncomingEdge(this); to.AddOutgoingEdge(this); }
public void AddIncomingEdge_success() { var node = new GraphNode(); var fromNode = new GraphNode(); var edge = Mock.Create<GraphEdge>(); edge.Arrange(e => e.From).Returns(fromNode); node.AddIncomingEdge(edge); Assert.AreEqual(1, node.IncomingEdges.Count); Assert.AreEqual(edge, node.IncomingEdges.First()); Assert.AreEqual(0, node.OutgoingEdges.Count); Assert.AreEqual(1, node.ConnectedEdges.Count); Assert.AreEqual(edge, node.ConnectedEdges.First()); Assert.AreEqual(1, node.ConnectedNodes.Count); Assert.AreEqual(fromNode, node.ConnectedNodes.First()); }