public void Test3Vertices() { // build graph. var graph = new DirectedDynamicGraph(ContractedEdgeDataSerializer.DynamicFixedSize); graph.AddEdge(0, 1, 100, null); graph.AddEdge(1, 0, 100, null); graph.AddEdge(1, 2, 100, null); graph.AddEdge(2, 1, 100, null); graph.Compress(); // contract graph. var hierarchyBuilder = new HierarchyBuilder(graph, new EdgeDifferencePriorityCalculator(graph, new DykstraWitnessCalculator(int.MaxValue)), new DykstraWitnessCalculator(int.MaxValue), (i) => Enumerable.Empty <uint[]>()); hierarchyBuilder.Run(); // check edges. var edges01 = graph.GetEdgeEnumerator(0).FirstOrDefault(x => x.Neighbour == 1); Assert.IsNotNull(edges01); var edge10 = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 0); Assert.IsNull(edge10); var edge12 = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 0); Assert.IsNull(edge12); var edges21 = graph.GetEdgeEnumerator(2).FirstOrDefault(x => x.Neighbour == 1); Assert.IsNotNull(edges21); }
public void TestQuadrilateralOneWay() { // build graph. var graph = new DirectedDynamicGraph(ContractedEdgeDataSerializer.DynamicFixedSize); graph.AddEdge(0, 2, 100, true); graph.AddEdge(2, 0, 100, false); graph.AddEdge(0, 3, 10, false); graph.AddEdge(3, 0, 10, true); graph.AddEdge(1, 2, 1000, false); graph.AddEdge(2, 1, 1000, true); graph.AddEdge(1, 3, 10000, true); graph.AddEdge(3, 1, 10000, false); graph.Compress(); // create a witness calculator and the priority calculator. var contractedFlags = new BitArray32(graph.VertexCount); var priorityCalculator = new EdgeDifferencePriorityCalculator(graph, new Itinero.Algorithms.Contracted.EdgeBased.Witness.DykstraWitnessCalculator(10)); //var priorityCalculator = new EdgeDifferencePriorityCalculator(graph, // new WitnessCalculatorMock(new uint[][] // { // new uint[] { 1, 3, 2, 1 }, // new uint[] { 3, 0, 1, 1 } // })); Assert.AreEqual(0, priorityCalculator.Calculate(contractedFlags, (i) => null, 0)); Assert.AreEqual(0, priorityCalculator.Calculate(contractedFlags, (i) => null, 1)); Assert.AreEqual(0, priorityCalculator.Calculate(contractedFlags, (i) => null, 2)); Assert.AreEqual(0, priorityCalculator.Calculate(contractedFlags, (i) => null, 3)); }
public void TestDoubleContractionOneway() { // build graph. var graph = new DirectedDynamicGraph(ContractedEdgeDataSerializer.DynamicFixedSize); graph.AddEdge(0, 1, 100, null); graph.AddEdge(1, 0, 100, null); graph.AddEdge(1, 2, 100, null); graph.AddEdge(2, 1, 100, null); graph.AddEdge(1, 3, 10, null); graph.AddEdge(3, 1, 10, null); graph.AddEdge(3, 2, 10, null); graph.AddEdge(2, 3, 10, null); graph.Compress(); // contract graph. var priorities = new Dictionary <uint, float>(); priorities.Add(1, 0); priorities.Add(0, 1); priorities.Add(2, 2); priorities.Add(3, 3); var hierarchyBuilder = new HierarchyBuilder(graph, new MockPriorityCalculator(priorities), new DykstraWitnessCalculator(int.MaxValue), (i) => Enumerable.Empty <uint[]>()); hierarchyBuilder.Run(); // edges 1->2 and 2->1 should have been removed. var edge = graph.GetEdgeEnumerator(0).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNotNull(edge); var edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(110, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(1, edge.GetContracted()); edge = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 0); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(100, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(Constants.NO_VERTEX, edgeData.ContractedId); edge = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(10, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(Constants.NO_VERTEX, edgeData.ContractedId); edge = graph.GetEdgeEnumerator(2).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(10, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(Constants.NO_VERTEX, edgeData.ContractedId); }
public void TestOneEdgeAugmented() { // build graph. var graph = new Itinero.Graphs.Graph(EdgeDataSerializer.Size); graph.AddVertex(0); graph.AddVertex(1); graph.AddEdge(0, 1, EdgeDataSerializer.Serialize(new EdgeData() { Distance = 100, Profile = 1 })); // build speed profile function. var speed = 100f / 3.6f; Func <ushort, FactorAndSpeed> getFactor = (x) => { return(new FactorAndSpeed() { Direction = 0, SpeedFactor = 1.0f / speed, Value = 1.0f / speed }); }; // convert graph. var directedGraph = new DirectedDynamicGraph(ContractedEdgeDataSerializer.DynamicAugmentedFixedSize); var algorithm = new DirectedGraphBuilder <Weight>(graph, directedGraph, new WeightHandler(getFactor)); algorithm.Run(); // check result. Assert.IsTrue(algorithm.HasRun); Assert.IsTrue(algorithm.HasSucceeded); directedGraph.Compress(); Assert.AreEqual(2, directedGraph.VertexCount); Assert.AreEqual(2, directedGraph.EdgeCount); // verify all edges. var edges = directedGraph.GetEdgeEnumerator(0); Assert.AreEqual(1, edges.Count()); var data = ContractedEdgeDataSerializer.SerializeDynamicAugmented(100 * getFactor(1).Value, null, 100, 100 * getFactor(1).Value); Assert.AreEqual(data[0], edges.First().Data[0]); Assert.AreEqual(data[1], edges.First().Data[1]); Assert.AreEqual(data[2], edges.First().Data[2]); Assert.AreEqual(1, edges.First().Neighbour); edges = directedGraph.GetEdgeEnumerator(1); Assert.AreEqual(1, edges.Count()); data = ContractedEdgeDataSerializer.SerializeDynamicAugmented(100 * getFactor(1).Value, null, 100, 100 * getFactor(1).Value); Assert.AreEqual(data[0], edges.First().Data[0]); Assert.AreEqual(data[1], edges.First().Data[1]); Assert.AreEqual(data[2], edges.First().Data[2]); Assert.AreEqual(0, edges.First().Neighbour); }
public void TestDoubleContraction() { // build graph. var graph = new DirectedDynamicGraph(ContractedEdgeDataSerializer.DynamicFixedSize); graph.AddEdge(0, 2, 100, null); graph.AddEdge(2, 0, 100, null); graph.AddEdge(0, 3, 100, null); graph.AddEdge(3, 0, 100, null); graph.AddEdge(1, 2, 200, null); graph.AddEdge(2, 1, 200, null); graph.AddEdge(1, 3, 200, null); graph.AddEdge(3, 1, 200, null); graph.Compress(); // contract graph. var priorityCalculator = new EdgeDifferencePriorityCalculator(graph, new DykstraWitnessCalculator(int.MaxValue)); priorityCalculator.DepthFactor = 0; priorityCalculator.ContractedFactor = 0; var hierarchyBuilder = new HierarchyBuilder(graph, priorityCalculator, new DykstraWitnessCalculator(int.MaxValue), (i) => Enumerable.Empty <uint[]>()); hierarchyBuilder.Run(); // check edges. var edge = graph.GetEdgeEnumerator(0).FirstOrDefault(x => x.Neighbour == 2); Assert.IsNull(edge); edge = graph.GetEdgeEnumerator(2).FirstOrDefault(x => x.Neighbour == 0); Assert.IsNotNull(edge); edge = graph.GetEdgeEnumerator(0).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNull(edge); edge = graph.GetEdgeEnumerator(3).FirstOrDefault(x => x.Neighbour == 0); Assert.IsNotNull(edge); edge = graph.GetEdgeEnumerator(2).FirstOrDefault(x => x.Neighbour == 1); Assert.IsNull(edge); edge = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 2); Assert.IsNotNull(edge); edge = graph.GetEdgeEnumerator(3).FirstOrDefault(x => x.Neighbour == 1); Assert.IsNull(edge); edge = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNotNull(edge); }
public void TestSerialize() { var graph = new DirectedDynamicGraph(10, 1); // add and compress. graph.AddEdge(0, 1, 1); graph.Compress(); var expectedSize = 1 + 8 + 8 + 8 + 4 + // the header: version byte two longs representing vertex, edge count and the size of the edge array and one int for minimum edge size. graph.VertexCount * 1 * 4 + // the bytes for the vertex-index: 1 uint. graph.EdgeCount * 2 * 4; // the bytes for the edges: one edge 2 uint's. using (var stream = new System.IO.MemoryStream()) { Assert.AreEqual(expectedSize, graph.Serialize(stream)); Assert.AreEqual(expectedSize, stream.Position); } // verify all edges. var edges = graph.GetEdgeEnumerator(0); Assert.AreEqual(1, edges.Count()); Assert.AreEqual(1, edges.First().Data[0]); Assert.AreEqual(1, edges.First().Neighbour); graph = new DirectedDynamicGraph(10, 1); // add and compress. graph.AddEdge(0, 1, 10); graph.AddEdge(1, 2, 20); graph.AddEdge(2, 3, 30); graph.AddEdge(3, 4, 40); graph.RemoveEdge(1, 2); graph.Compress(); expectedSize = 1 + 8 + 8 + 8 + 4 + // the header: version bytes, three longs representing vertex and edge count and the size of the edge array and one int for fixed edge size. graph.VertexCount * 4 + // the bytes for the vertex-index: 2 uint's. graph.EdgeCount * 2 * 4; // the bytes for the edges: one edge 1 uint. using (var stream = new System.IO.MemoryStream()) { Assert.AreEqual(expectedSize, graph.Serialize(stream)); Assert.AreEqual(expectedSize, stream.Position); } }
public void TestRestrictedNetwork2() { // build graph. var graph = new DirectedDynamicGraph(ContractedEdgeDataSerializer.DynamicFixedSize); graph.AddEdge(0, 1, 100, null); graph.AddEdge(1, 0, 100, null); graph.AddEdge(1, 2, 100, null); graph.AddEdge(2, 1, 100, null); graph.AddEdge(1, 3, 100, null); graph.AddEdge(3, 1, 100, null); graph.AddEdge(1, 4, 100, null); graph.AddEdge(4, 1, 100, null); graph.AddEdge(2, 3, 100, null); graph.AddEdge(3, 2, 100, null); graph.Compress(); // contract graph. var priorities = new Dictionary <uint, float>(); priorities.Add(1, 0); priorities.Add(0, 1); priorities.Add(2, 2); priorities.Add(3, 3); priorities.Add(4, 4); var hierarchyBuilder = new HierarchyBuilder(graph, new MockPriorityCalculator(priorities), new DykstraWitnessCalculator(int.MaxValue), (i) => { if (i == 0 || i == 1 || i == 4) { return(new uint[][] { new uint[] { 0, 1, 4 } }); } return(null); }); hierarchyBuilder.Run(); // check all edges. ContractedEdgeData edgeData; var edge = graph.GetEdgeEnumerator(0).FirstOrDefault(x => { if (x.Neighbour == 4) { edgeData = ContractedEdgeDataSerializer.Deserialize(x.Data[0], Constants.NO_VERTEX); return(edgeData.Direction == true); } return(false); }); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(500, edgeData.Weight); Assert.AreEqual(true, edgeData.Direction); Assert.AreEqual(1, edge.GetContracted()); edge = graph.GetEdgeEnumerator(0).FirstOrDefault(x => { if (x.Neighbour == 4) { edgeData = ContractedEdgeDataSerializer.Deserialize(x.Data[0], Constants.NO_VERTEX); return(edgeData.Direction == false); } return(false); }); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(200, edgeData.Weight); Assert.AreEqual(false, edgeData.Direction); Assert.AreEqual(1, edge.GetContracted()); edge = graph.GetEdgeEnumerator(0).FirstOrDefault(x => x.Neighbour == 2); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(200, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(1, edge.GetContracted()); edge = graph.GetEdgeEnumerator(0).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(200, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(1, edge.GetContracted()); edge = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 0); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(100, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(null, edge.GetContracted()); edge = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 2); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(100, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(null, edge.GetContracted()); edge = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(100, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(null, edge.GetContracted()); edge = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 4); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(100, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(null, edge.GetContracted()); edge = graph.GetEdgeEnumerator(2).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(100, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(null, edge.GetContracted()); edge = graph.GetEdgeEnumerator(2).FirstOrDefault(x => x.Neighbour == 4); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(200, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(1, edge.GetContracted()); edge = graph.GetEdgeEnumerator(3).FirstOrDefault(x => x.Neighbour == 4); Assert.IsNotNull(edge); edgeData = ContractedEdgeDataSerializer.Deserialize(edge.Data[0], Constants.NO_VERTEX); Assert.AreEqual(200, edgeData.Weight); Assert.AreEqual(null, edgeData.Direction); Assert.AreEqual(1, edge.GetContracted()); }
public void TestPentagonDirected() { // build graph. var graph = new DirectedDynamicGraph(ContractedEdgeDataSerializer.DynamicFixedSize); graph.AddEdge(0, 1, 100, true); graph.AddEdge(1, 0, 100, false); graph.AddEdge(1, 2, 100, true); graph.AddEdge(2, 1, 100, false); graph.AddEdge(2, 3, 100, true); graph.AddEdge(3, 2, 100, false); graph.AddEdge(3, 4, 100, true); graph.AddEdge(4, 3, 100, false); graph.AddEdge(4, 0, 100, true); graph.AddEdge(0, 4, 100, false); graph.Compress(); // contract graph. var priorityCalculator = new EdgeDifferencePriorityCalculator(graph, new DykstraWitnessCalculator(int.MaxValue)); priorityCalculator.ContractedFactor = 0; priorityCalculator.DepthFactor = 0; var hierarchyBuilder = new HierarchyBuilder(graph, priorityCalculator, new DykstraWitnessCalculator(int.MaxValue), (i) => Enumerable.Empty <uint[]>()); hierarchyBuilder.Run(); // check edges. var edges01 = graph.GetEdgeEnumerator(0).FirstOrDefault(x => x.Neighbour == 1); Assert.IsNotNull(edges01); var edges10 = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 0); Assert.IsNull(edges10); var edges12 = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 2); Assert.IsNull(edges12); var edges21 = graph.GetEdgeEnumerator(2).FirstOrDefault(x => x.Neighbour == 1); Assert.IsNotNull(edges21); var edges23 = graph.GetEdgeEnumerator(2).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNotNull(edges23); var edges32 = graph.GetEdgeEnumerator(3).FirstOrDefault(x => x.Neighbour == 2); Assert.IsNull(edges32); var edges34 = graph.GetEdgeEnumerator(3).FirstOrDefault(x => x.Neighbour == 4); Assert.IsNull(edges34); var edges43 = graph.GetEdgeEnumerator(4).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNotNull(edges43); var edges40 = graph.GetEdgeEnumerator(4).FirstOrDefault(x => x.Neighbour == 0); Assert.IsNull(edges40); var edges04 = graph.GetEdgeEnumerator(0).FirstOrDefault(x => x.Neighbour == 4); Assert.IsNotNull(edges04); var edges41 = graph.GetEdgeEnumerator(4).FirstOrDefault(x => x.Neighbour == 1); Assert.IsNotNull(edges41); var s1 = edges41.GetSequence1(); var s2 = edges41.GetSequence2(); Assert.AreEqual(1, s1.Length); Assert.AreEqual(0, s1[0]); Assert.AreEqual(1, s2.Length); Assert.AreEqual(0, s2[0]); var edges14 = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 4); Assert.IsNull(edges14); var edges31 = graph.GetEdgeEnumerator(3).FirstOrDefault(x => x.Neighbour == 1); Assert.IsNotNull(edges31); s1 = edges31.GetSequence1(); s2 = edges31.GetSequence2(); Assert.AreEqual(1, s1.Length); Assert.AreEqual(4, s1[0]); Assert.AreEqual(1, s2.Length); Assert.AreEqual(0, s2[0]); var edges13 = graph.GetEdgeEnumerator(1).FirstOrDefault(x => x.Neighbour == 3); Assert.IsNull(edges13); }
public void TestCompress() { var graph = new DirectedDynamicGraph(10, 1); // add and compress. graph.AddEdge(0, 1, 1); graph.Compress(); // verify all edges. var edges = graph.GetEdgeEnumerator(0); Assert.AreEqual(1, edges.First().Data[0]); Assert.AreEqual(1, edges.First().Neighbour); graph = new DirectedDynamicGraph(10, 1); // add and compress. graph.AddEdge(0, 1, 10); graph.AddEdge(1, 2, 20); graph.AddEdge(2, 3, 30); graph.AddEdge(3, 4, 40); graph.RemoveEdge(1, 2); // verify all edges. edges = graph.GetEdgeEnumerator(0); Assert.AreEqual(1, edges.Count()); Assert.AreEqual(10, edges.First().Data[0]); Assert.AreEqual(1, edges.First().Neighbour); edges = graph.GetEdgeEnumerator(1); Assert.IsFalse(edges.MoveNext()); edges = graph.GetEdgeEnumerator(2); Assert.AreEqual(1, edges.Count()); Assert.AreEqual(30, edges.First().Data[0]); Assert.AreEqual(3, edges.First().Neighbour); edges = graph.GetEdgeEnumerator(3); Assert.AreEqual(1, edges.Count()); Assert.AreEqual(40, edges.First().Data[0]); Assert.AreEqual(4, edges.First().Neighbour); // compress. graph.Compress(); // verify all edges. edges = graph.GetEdgeEnumerator(0); Assert.AreEqual(1, edges.Count()); Assert.AreEqual(10, edges.First().Data[0]); Assert.AreEqual(1, edges.First().Neighbour); edges = graph.GetEdgeEnumerator(1); Assert.IsFalse(edges.MoveNext()); edges = graph.GetEdgeEnumerator(2); Assert.AreEqual(1, edges.Count()); Assert.AreEqual(30, edges.First().Data[0]); Assert.AreEqual(3, edges.First().Neighbour); edges = graph.GetEdgeEnumerator(3); Assert.AreEqual(1, edges.Count()); Assert.AreEqual(40, edges.First().Data[0]); Assert.AreEqual(4, edges.First().Neighbour); }
public void TestQuadrilateralOneWay() { // build graph. var graph = new DirectedDynamicGraph(ContractedEdgeDataSerializer.DynamicFixedSize); graph.AddEdge(0, 2, 100, true); graph.AddEdge(2, 0, 100, false); graph.AddEdge(0, 3, 10, false); graph.AddEdge(3, 0, 10, true); graph.AddEdge(1, 2, 1000, false); graph.AddEdge(2, 1, 1000, true); graph.AddEdge(1, 3, 10000, true); graph.AddEdge(3, 1, 10000, false); graph.Compress(false); var witnessCalculator = new DykstraWitnessCalculator(int.MaxValue); // calculate witnesses for 0. var forwardWitnesses = new EdgePath <float> [1]; var backwardWitnesses = new EdgePath <float> [1]; witnessCalculator.Calculate(graph, (i) => null, 2, new List <uint>(new uint[] { 3 }), new List <float>(new float[] { 110 }), ref forwardWitnesses, ref backwardWitnesses, 0); Assert.AreEqual(Constants.NO_VERTEX, forwardWitnesses[0].Vertex); Assert.AreEqual(Constants.NO_VERTEX, backwardWitnesses[0].Vertex); // calculate witnesses for 0. forwardWitnesses = new EdgePath <float> [1]; backwardWitnesses = new EdgePath <float> [1]; witnessCalculator.Calculate(graph, (i) => null, 3, new List <uint>(new uint[] { 2 }), new List <float>(new float[] { 110 }), ref forwardWitnesses, ref backwardWitnesses, 0); Assert.AreEqual(Constants.NO_VERTEX, forwardWitnesses[0].Vertex); Assert.AreEqual(Constants.NO_VERTEX, backwardWitnesses[0].Vertex); // calculate witnesses for 2. forwardWitnesses = new EdgePath <float> [1]; backwardWitnesses = new EdgePath <float> [1]; witnessCalculator.Calculate(graph, (i) => null, 0, new List <uint>(new uint[] { 1 }), new List <float>(new float[] { 1100 }), ref forwardWitnesses, ref backwardWitnesses, 2); Assert.AreEqual(Constants.NO_VERTEX, forwardWitnesses[0].Vertex); Assert.AreEqual(Constants.NO_VERTEX, backwardWitnesses[0].Vertex); // calculate witnesses for 2. forwardWitnesses = new EdgePath <float> [1]; backwardWitnesses = new EdgePath <float> [1]; witnessCalculator.Calculate(graph, (i) => null, 1, new List <uint>(new uint[] { 0 }), new List <float>(new float[] { 1100 }), ref forwardWitnesses, ref backwardWitnesses, 2); Assert.AreEqual(Constants.NO_VERTEX, forwardWitnesses[0].Vertex); Assert.AreEqual(Constants.NO_VERTEX, backwardWitnesses[0].Vertex); // calculate witnesses for 1. forwardWitnesses = new EdgePath <float> [1]; backwardWitnesses = new EdgePath <float> [1]; witnessCalculator.Calculate(graph, (i) => null, 3, new List <uint>(new uint[] { 2 }), new List <float>(new float[] { 11000 }), ref forwardWitnesses, ref backwardWitnesses, 1); Assert.AreEqual(2, forwardWitnesses[0].Vertex); Assert.AreEqual(Constants.NO_VERTEX, backwardWitnesses[0].Vertex); // calculate witnesses for 1. forwardWitnesses = new EdgePath <float> [1]; backwardWitnesses = new EdgePath <float> [1]; witnessCalculator.Calculate(graph, (i) => null, 2, new List <uint>(new uint[] { 3 }), new List <float>(new float[] { 11000 }), ref forwardWitnesses, ref backwardWitnesses, 1); Assert.AreEqual(Constants.NO_VERTEX, forwardWitnesses[0].Vertex); Assert.AreEqual(3, backwardWitnesses[0].Vertex); // calculate witnesses for 3. forwardWitnesses = new EdgePath <float> [1]; backwardWitnesses = new EdgePath <float> [1]; witnessCalculator.Calculate(graph, (i) => null, 0, new List <uint>(new uint[] { 1 }), new List <float>(new float[] { 10010 }), ref forwardWitnesses, ref backwardWitnesses, 3); Assert.AreEqual(1, forwardWitnesses[0].Vertex); Assert.AreEqual(Constants.NO_VERTEX, backwardWitnesses[0].Vertex); // calculate witnesses for 3. forwardWitnesses = new EdgePath <float> [1]; backwardWitnesses = new EdgePath <float> [1]; witnessCalculator.Calculate(graph, (i) => null, 1, new List <uint>(new uint[] { 0 }), new List <float>(new float[] { 10010 }), ref forwardWitnesses, ref backwardWitnesses, 3); Assert.AreEqual(Constants.NO_VERTEX, forwardWitnesses[0].Vertex); Assert.AreEqual(0, backwardWitnesses[0].Vertex); }