public void MayHaveDuplicateEdges() { var graph = typeof(DirectedGraph) .Invoking(_ => DirectedGraph.Of( GraphFactory.CreateEdges("A-B", "A-B"), GraphFactory.CreateNodes("A", "B"))) .Should().NotThrow() .Subject; graph.EdgeCount.Should().Be(2); }
public void PathDoesNotVisitOtherNodes() { var path = GraphFactory.CreateEdges("A-B", "B-C", "C-D", "D-E"); path.Visits(NodeIdentity.Of("Q")).Should().BeFalse(); }
public void PathVisitsNodeInMiddle() { var path = GraphFactory.CreateEdges("A-B", "B-C", "C-D", "D-E"); path.Visits(NodeIdentity.Of("C")).Should().BeTrue(); }
public void PathContainingACycleIsNotACycle() { var path = GraphFactory.CreateEdges("A-B", "B-C", "C-A", "A-D"); path.DescribesCycle().Should().BeFalse(); }
public void PathLongerThan2WhichEndsWhereItStartsIsACycle() { var path = GraphFactory.CreateEdges("A-B", "B-C", "C-A"); path.DescribesCycle().Should().BeTrue(); }
public void ANodeLeadingToItselfIsACycle() { var path = GraphFactory.CreateEdges("A-A"); path.DescribesCycle().Should().BeTrue(); }
public void AnEmptyPathIsNotACycle() { var path = GraphFactory.CreateEdges(); path.DescribesCycle().Should().BeFalse(); }