I need to implement is the RoutesBetween
method to trace the route between one point and another (in this case, point A and E ).
Test Method:
public void TestRoutesBetweenTwoPoints()
{
var links = new ILink<string>[]
{
new Link<string>("a","b"),
new Link<string>("b","c"),
new Link<string>("c","b"),
new Link<string>("b","a"),
new Link<string>("c","d"),
new Link<string>("d","e"),
new Link<string>("d","a"),
new Link<string>("a","h"),
new Link<string>("h","g"),
new Link<string>("g","f"),
new Link<string>("f","e"),
};
var graph = new Graph<string>(links);
var paths = graph.RoutesBetween("a", "e");
var list = paths.ToEnumerable().ToArray();
Assert.AreEqual(list.Length, 2);
Assert.IsTrue(list.Any(l => String.Join("-", 1) == "a-b-c-d-e"));
Assert.IsTrue(list.Any(l => String.Join("-", 1) == "a-h-g-f-e"));
}
How can I check the list ( links
) if it is not being passed as a method parameter?
The class, constructor and method:
namespace Graph
{
public interface IGraph<T>
{
IObservable<IEnumerable<T>> RoutesBetween(T source, T target);
}
public class Graph<T> : IGraph<T>
{
public Graph(IEnumerable<ILink<T>> links)
{
}
}
publi IObservable<IEnumerable<T>> RoutesBetween(T source, T target)
{
throw new NotImplementedException();
}
}