Example #1
0
        public void IncidentEdgesExample()
        {
            // Create two new vertices
            var vertex1 = new Vertex <int>(2);
            var vertex2 = new Vertex <int>(4);

            // Create a graph, and add the vertices to
            // the graph
            var graph = new Graph <int>(true);

            graph.AddVertex(vertex1, vertex2);

            // Add an edge from vertex1 to vertex vertex2
            graph.AddEdge(vertex1, vertex2);

            // The edge will be incident on vertex1, and connected
            // to vertex vertex2.
            Assert.IsTrue(vertex1.HasIncidentEdgeWith(vertex2));

            // To get the list of incident edges, use the
            // IncidentEdges property
            Assert.AreEqual(1, vertex1.IncidentEdges.Count);

            // And also the other way around.
            Assert.IsTrue(vertex2.HasIncidentEdgeWith(vertex1));
            Assert.AreEqual(1, vertex2.IncidentEdges.Count);
        }
Example #2
0
        public void HasIncidentEdgeWithExample()
        {
            // Create two new vertices
            var vertex1 = new Vertex <int>(2);
            var vertex2 = new Vertex <int>(4);

            // Create a graph, and add the vertices to
            // the graph
            var graph = new Graph <int>(true);

            graph.AddVertex(vertex1, vertex2);

            // Add an edge from vertex1 to vertex vertex2
            graph.AddEdge(vertex1, vertex2);

            // The edge will be incident on vertex1, and connected
            // to vertex vertex2.
            Assert.IsTrue(vertex1.HasIncidentEdgeWith(vertex2));

            // And also the other way around.
            Assert.IsTrue(vertex2.HasIncidentEdgeWith(vertex1));
        }
Example #3
0
        public void IncidentEdgesExample()
        {
            // Create two new vertices
            var vertex1 = new Vertex<int>(2);
            var vertex2 = new Vertex<int>(4);

            // Create a graph, and add the vertices to
            // the graph
            var graph = new Graph<int>(true);
            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);

            // Add an edge from vertex1 to vertex vertex2
            graph.AddEdge(vertex1, vertex2);

            // The edge will be incident on vertex1, and connected
            // to vertex vertex2.
            Assert.IsTrue(vertex1.HasIncidentEdgeWith(vertex2));

            // To get the list of incident edges, use the
            // IncidentEdges property
            Assert.AreEqual(vertex1.IncidentEdges.Count, 1);

            // And also the other way around.
            Assert.IsTrue(vertex2.HasIncidentEdgeWith(vertex1));
            Assert.AreEqual(vertex2.IncidentEdges.Count, 1);
        }
Example #4
0
        public void HasIncidentEdgeWithExample()
        {
            // Create two new vertices
            var vertex1 = new Vertex<int>(2);
            var vertex2 = new Vertex<int>(4);

            // Create a graph, and add the vertices to
            // the graph
            var graph = new Graph<int>(true);
            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);

            // Add an edge from vertex1 to vertex vertex2
            graph.AddEdge(vertex1, vertex2);

            // The edge will be incident on vertex1, and connected
            // to vertex vertex2.
            Assert.IsTrue(vertex1.HasIncidentEdgeWith(vertex2));

            // And also the other way around.
            Assert.IsTrue(vertex2.HasIncidentEdgeWith(vertex1));
        }