internal void UpdateCostCache(Station node)
        {
            RectangleNode <CdtTriangle> cdtTree = cdt.GetCdtTree();

            node.CdtTriangle = cdtTree.FirstHitNode(node.Position, Test).UserData;

            node.cachedIdealRadius = HubRadiiCalculator.CalculateIdealHubRadiusWithNeighbors(metroGraphData, bundlingSettings, node);
            node.cachedRadiusCost  = costCalculator.RadiusCost(node, node.Position);
            node.cachedBundleCost  = 0;

            foreach (var adj in node.Neighbors)
            {
                if (!adj.IsRealNode)
                {
                    adj.cachedIdealRadius = HubRadiiCalculator.CalculateIdealHubRadiusWithNeighbors(metroGraphData, bundlingSettings, adj);
                    adj.cachedRadiusCost  = costCalculator.RadiusCost(adj, adj.Position);
                }

                StationEdgeInfo edgeInfo = metroGraphData.GetIjInfo(node, adj);
                adj.cachedBundleCost -= edgeInfo.cachedBundleCost;

                edgeInfo.cachedBundleCost = costCalculator.BundleCost(node, adj, node.Position);
                node.cachedBundleCost    += edgeInfo.cachedBundleCost;
                adj.cachedBundleCost     += edgeInfo.cachedBundleCost;
            }
        }
        StationEdgeInfo GetOrderedIjInfo(Station i, Station j)
        {
            Debug.Assert(i < j);
            var             couple = new Tuple <Station, Station>(i, j);
            StationEdgeInfo cw;

            if (edgeInfoDictionary.TryGetValue(couple, out cw))
            {
                return(cw);
            }
            edgeInfoDictionary[couple] = cw = new StationEdgeInfo(i.Position, j.Position);
            return(cw);
        }
        internal void InitializeCostCache()
        {
            foreach (var v in metroGraphData.VirtualNodes())
            {
                v.cachedIdealRadius = HubRadiiCalculator.CalculateIdealHubRadiusWithNeighbors(metroGraphData, bundlingSettings, v);
                v.cachedRadiusCost  = costCalculator.RadiusCost(v, v.Position);
                v.cachedBundleCost  = 0;
            }

            foreach (var edge in metroGraphData.VirtualEdges())
            {
                var             v        = edge.Item1;
                var             u        = edge.Item2;
                StationEdgeInfo edgeInfo = metroGraphData.GetIjInfo(v, u);
                edgeInfo.cachedBundleCost = costCalculator.BundleCost(v, u, v.Position);
                v.cachedBundleCost       += edgeInfo.cachedBundleCost;
                u.cachedBundleCost       += edgeInfo.cachedBundleCost;
            }
        }
 StationEdgeInfo GetOrderedIjInfo(Station i, Station j) {
     Debug.Assert(i < j);
     var couple = new Tuple<Station, Station>(i, j);
     StationEdgeInfo cw;
     if (edgeInfoDictionary.TryGetValue(couple, out cw))
         return cw;
     edgeInfoDictionary[couple] = cw = new StationEdgeInfo(i.Position, j.Position);
     return cw;
 }