2
I need to implement the method RoutesBetween
to trace the route between a point and another (in this case, point To and And).
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 will I sweep the list (links
) if it is not being passed as 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();
}
}
@Joãomartins I was making this issue now :P
– Leandro Angelo
So it was for seconds ;)
– João Martins
@When asking a question, put the text of your code, avoid using a print from your editor. This makes it much easier for those who will answer your question and present a [MCVE]
– Leandro Angelo
@Leandroangelo Leandro, Ok... Thank you
– Tamara Amorim