public void BatchingTopologicalSort_throws_with_formatted_message_when_cycle_cannot_be_broken()
        {
            const string message = "Formatted cycle";

            var vertexOne = new Vertex {
                Id = 1
            };
            var vertexTwo = new Vertex {
                Id = 2
            };
            var vertexThree = new Vertex {
                Id = 3
            };

            var edgeOne = new Edge {
                Id = 1
            };
            var edgeTwo = new Edge {
                Id = 2
            };
            var edgeThree = new Edge {
                Id = 3
            };

            var graph = new Multigraph <Vertex, Edge>();

            graph.AddVertices(new[] { vertexOne, vertexTwo, vertexThree });

            // 1 -> {2}
            graph.AddEdge(vertexOne, vertexTwo, edgeOne);
            // 2 -> {3}
            graph.AddEdge(vertexTwo, vertexThree, edgeTwo);
            // 3 -> {1}
            graph.AddEdge(vertexThree, vertexOne, edgeThree);

            Dictionary <Vertex, Tuple <Vertex, Vertex, IEnumerable <Edge> > > cycleData = null;

            string formatter(IEnumerable <Tuple <Vertex, Vertex, IEnumerable <Edge> > > data)
            {
                cycleData = data.ToDictionary(entry => entry.Item1);
                return(message);
            }

            Assert.Equal(
                CoreStrings.CircularDependency(message),
                Assert.Throws <InvalidOperationException>(() => graph.BatchingTopologicalSort(formatter)).Message);

            Assert.Equal(3, cycleData.Count());

            Assert.Equal(vertexTwo, cycleData[vertexOne].Item2);
            Assert.Equal(new[] { edgeOne }, cycleData[vertexOne].Item3);

            Assert.Equal(vertexThree, cycleData[vertexTwo].Item2);
            Assert.Equal(new[] { edgeTwo }, cycleData[vertexTwo].Item3);

            Assert.Equal(vertexOne, cycleData[vertexThree].Item2);
            Assert.Equal(new[] { edgeThree }, cycleData[vertexThree].Item3);
        }