public void Test1() { // Arrange var graph = new Graph(); graph.AddVertex(0); // a graph.AddVertex(1); // b graph.AddVertex(2); // c graph.AddVertex(3); // d // (a, b) // (a, c) graph.AddDirectedEdge(0, 1); graph.AddDirectedEdge(0, 2); // (b, c) graph.AddDirectedEdge(1, 2); // (c, d) graph.AddDirectedEdge(2, 3); // Act var sortedVertices = Topo.TopologicalSort(graph); // Assert CollectionAssert.AreEqual(new[] { 3, 2, 1, 0 }, sortedVertices); }
static void Main(string[] args) { var topo = new Topo(); topo.Sort(); }