public void YouTubeExampleConnectivityTest() { Graph graph = new UnidirectionalGraph(); GraphTestHelpers.CommonInitialize(graph); Connectivity connectivity = new Connectivity(graph); bool isConnected = connectivity.IsConnected("a", "z"); Assert.IsTrue(isConnected, "A should be connected to Z"); isConnected = connectivity.IsConnected(graph.GetVertex("z"), graph.GetVertex("a")); Assert.IsFalse(isConnected, "Z should not be connected to A"); }
public void GetVertexTest() { Graph graph = new UnidirectionalGraph(); Assert.IsTrue(graph.Directionality == Directionality.Unidirectional); GraphTestHelpers.CommonInitialize(graph); Assert.IsTrue(graph.NumVertices == 6); Vertex v = graph.GetVertex("a"); Assert.IsNotNull(v); }
public void GetVertexIndexTest2() { Graph graph = new UnidirectionalGraph(); Assert.IsTrue(graph.Directionality == Directionality.Unidirectional); GraphTestHelpers.CommonInitialize(graph); Vertex v = graph.GetVertex("b"); Assert.IsNotNull(v); int index = graph.GetVertexIndex(v); Assert.IsTrue(index >= 0); }
public void GetAdjacentVerticesNoConnectionsTest() { Graph graph = new UnidirectionalGraph(); Assert.IsTrue(graph.Directionality == Directionality.Unidirectional); GraphTestHelpers.CommonInitialize(graph); Vertex v = graph.GetVertex("z"); Assert.IsNotNull(v); List <Vertex> adjacentVertices = graph.GetAdjacentVertices(v); Assert.IsNotNull(adjacentVertices); Assert.IsFalse(adjacentVertices.Any()); }
public void GetEdgesTest() { Graph graph = new UnidirectionalGraph(); Assert.IsTrue(graph.Directionality == Directionality.Unidirectional); GraphTestHelpers.CommonInitialize(graph); Vertex v = graph.GetVertex("a"); Assert.IsNotNull(v); IEnumerable <WeightedEdge <int> > edges = graph.GetEdges(v); Assert.IsNotNull(edges); Assert.IsTrue(edges.Any()); }
public void GetAdjacentVerticesTest() { Graph graph = new UnidirectionalGraph(); Assert.IsTrue(graph.Directionality == Directionality.Unidirectional); GraphTestHelpers.CommonInitialize(graph); Vertex v = graph.GetVertex("a"); Assert.IsNotNull(v); List <Vertex> adjacentVertices = graph.GetAdjacentVertices(v); Assert.IsNotNull(adjacentVertices); Assert.IsTrue(adjacentVertices.Any()); // Vertex B and C should be the only vertices that are adjacent to A Assert.IsTrue(adjacentVertices.Count == 2); Assert.IsTrue(adjacentVertices[0].Name == "b"); Assert.IsTrue(adjacentVertices[1].Name == "c"); }