Example #1
0
        public void SetWeightSymmetrical(IWeightedGraphNode <T> node, T weight)
        {
            int index = IndexOf((WeightedGraphNode <T>)node);

            if (index < 0)
            {
                throw new ArgumentException("Node is not connected");
            }
            _weights[index] = weight;
            node.SetWeight(this, weight);
        }
Example #2
0
        public void ConnectNode(IWeightedGraphNode <double> node, NeighbourMode neighbourMode)
        {
            AStarAlgorithm        aStarAlgorithm = new AStarAlgorithm();
            CoordinateTransformer transformer    = new CoordinateTransformer(this, LeftBottom);

            foreach (var transitionNode in _transitionNodes)
            {
                IList <Vector2Int> path = aStarAlgorithm.GetPath(transformer, node.Position - LeftBottom,
                                                                 transitionNode.Position - LeftBottom, neighbourMode);
                if (path != null)
                {
                    node.SetWeight(transitionNode, path.Count);
                    transitionNode.SetWeight(node, path.Count);
                    // Other mode will not be connected
                }
            }
        }