Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        public void AddOutgoingEdge_success()
        {
            var node = new GraphNode();
            var toNode = new GraphNode();
            var edge = Mock.Create<GraphEdge>();
            edge.Arrange(e => e.To).Returns(toNode);
            node.AddOutgoingEdge(edge);

            Assert.AreEqual(0, node.IncomingEdges.Count);
            Assert.AreEqual(1, node.OutgoingEdges.Count);
            Assert.AreEqual(edge, node.OutgoingEdges.First());
            Assert.AreEqual(1, node.ConnectedEdges.Count);
            Assert.AreEqual(edge, node.ConnectedEdges.First());

            Assert.AreEqual(1, node.ConnectedNodes.Count);
            Assert.AreEqual(toNode, node.ConnectedNodes.First());
        }