internal void NodeOnPathFinderTest() { Graph <BasicNode> g = new Graph <BasicNode>(); BasicNode u = new BasicNode("u"); BasicNode v = new BasicNode("v"); BasicNode w = new BasicNode("w"); BasicNode x = new BasicNode("x"); BasicNode y = new BasicNode("y"); BasicNode z = new BasicNode("z"); g.Nodes.Add(u); g.Nodes.Add(v); g.Nodes.Add(w); g.Nodes.Add(x); g.Nodes.Add(y); g.Nodes.Add(z); g.AddEdge(u, v); g.AddEdge(v, w); g.AddEdge(w, x); g.AddEdge(x, v); g.AddEdge(v, y); g.AddEdge(v, z); g.AddEdge(z, u); var nodesOnPath = new HashSet <BasicNode>(); var pf = new NodeOnPathFinder <BasicNode>(g.TargetsOf, g, MakeIndexedProperty.FromSet(nodesOnPath), node => node.Data.Equals("z")); pf.SearchFrom(u); Console.Write("nodes on path: "); Console.WriteLine(StringUtil.CollectionToString(nodesOnPath, " ")); }
public void IndexedPropertyTest() { bool[] array = new bool[10]; IndexedProperty <int, bool> prop = MakeIndexedProperty.FromArray <bool>(array); prop[0] = true; Assert.True(prop[0]); prop.Clear(); Assert.False(prop[0]); }
internal void EdgeOnPathFinderTest() { var g = new Graph <BasicEdgeNode, BasicEdge>(BasicEdge.New); var u = new BasicEdgeNode("u"); var v = new BasicEdgeNode("v"); var w = new BasicEdgeNode("w"); var x = new BasicEdgeNode("x"); var y = new BasicEdgeNode("y"); var z = new BasicEdgeNode("z"); g.Nodes.Add(u); g.Nodes.Add(v); g.Nodes.Add(w); g.Nodes.Add(x); g.Nodes.Add(y); g.Nodes.Add(z); g.AddEdge(u, v); g.AddEdge(v, w); g.AddEdge(w, x); g.AddEdge(x, v); g.AddEdge(v, y); g.AddEdge(v, z); g.AddEdge(z, u); var edgesOnPath = new HashSet <BasicEdge>(); var pf = new EdgeOnPathFinder <BasicEdgeNode, BasicEdge>(g.EdgesOutOf, g.TargetOf, g, MakeIndexedProperty.FromSet(edgesOnPath), node => node.Data.Equals("z")); pf.SearchFrom(u); Console.Write("edges on path: "); Console.WriteLine(StringUtil.CollectionToString(edgesOnPath, " ")); }