public void IsBipartiteDFS_NotBipartiteGraph_Failure() { UndirectedGraphMatrixBased <string> graph = new UndirectedGraphMatrixBased <string>(new string[] { "A", "B", "C", "D" }); graph.SetEdge(0, 1); graph.SetEdge(1, 2); graph.SetEdge(2, 3); graph.SetEdge(1, 3); var r = graph.IsBipartiteDFS(); Assert.IsFalse(r); }
public void IsBipartiteDFS_BipartiteGraph_Success() { UndirectedGraphMatrixBased <string> graph = new UndirectedGraphMatrixBased <string>(new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I" }); graph.SetEdge(0, 1); graph.SetEdge(1, 2); graph.SetEdge(1, 8); graph.SetEdge(2, 3); graph.SetEdge(3, 6); graph.SetEdge(4, 5); graph.SetEdge(4, 7); graph.SetEdge(7, 8); var r = graph.IsBipartiteDFS(); Assert.IsTrue(r); }