コード例 #1
0
        public void TestPriorityCalculation1NoWitnesses()
        {
            var graph = new DirectedGraph<CHEdgeData>();
            var vertex1 = graph.AddVertex(1, 0);
            var vertex2 = graph.AddVertex(2, 0);
            var vertex3 = graph.AddVertex(3, 0);

            graph.AddEdge(vertex1, vertex3, new CHEdgeData(1, true, true, true, 10));
            graph.AddEdge(vertex3, vertex1, new CHEdgeData(1, false, true, true, 10));
            graph.AddEdge(vertex2, vertex3, new CHEdgeData(1, true, true, true, 10));
            graph.AddEdge(vertex3, vertex2, new CHEdgeData(1, false, true, true, 10));

            var witnessCalculator = new DykstraWitnessCalculator(int.MaxValue);
            var priorityCalculator = new EdgeDifferenceContractedSearchSpace(graph, witnessCalculator);

            int newEdges, removedEdges, contracted, depth;
            priorityCalculator.Calculate(vertex1, out newEdges, out removedEdges, out depth, out contracted);
            Assert.AreEqual(0, newEdges);
            Assert.AreEqual(1, removedEdges);
            Assert.AreEqual(0, depth);
            Assert.AreEqual(0, contracted);
            priorityCalculator.Calculate(vertex2, out newEdges, out removedEdges, out depth, out contracted);
            Assert.AreEqual(0, newEdges);
            Assert.AreEqual(1, removedEdges);
            Assert.AreEqual(0, depth);
            Assert.AreEqual(0, contracted);
            priorityCalculator.Calculate(vertex3, out newEdges, out removedEdges, out depth, out contracted);
            Assert.AreEqual(2, newEdges);
            Assert.AreEqual(2, removedEdges);
            Assert.AreEqual(0, depth);
            Assert.AreEqual(0, contracted);
        }
コード例 #2
0
        /// <summary>
        /// Flushes all data.
        /// </summary>
        public override void Flush()
        {
            base.Flush();

            // compress the graph.
            INodeWitnessCalculator witnessCalculator = new DykstraWitnessCalculator();
            var edgeDifference = new EdgeDifferenceContractedSearchSpace(
                _graph, witnessCalculator);
            var preProcessor = new CHPreProcessor(
                _graph, edgeDifference, witnessCalculator);
            preProcessor.Start();

            // create tags.
            TagsCollectionBase metaTags = new TagsCollection();

            // create serializer.
            var routingSerializer = new CHEdgeDataDataSourceSerializer();
            routingSerializer.Serialize(_graphStream, _graph, metaTags);
            _graphStream.Flush();
        }
 /// <summary>
 /// Returns the preprocessor for this stream.
 /// </summary>
 /// <returns></returns>
 public override OsmSharp.Routing.Graph.PreProcessor.IPreProcessor GetPreprocessor()
 {
     var witnessCalculator = new DykstraWitnessCalculator();
     var edgeDifference = new EdgeDifferenceContractedSearchSpace(
         this.Graph, witnessCalculator);
     return new CHPreProcessor(this.Graph, edgeDifference, witnessCalculator);
 }