Example #1
0
        public void SetWeightSymmetrical(int connectionIndex, T weight)
        {
            _weights[connectionIndex] = weight;
            WeightedGraphNode <T> node = (WeightedGraphNode <T>)Connections[connectionIndex];

            node.SetWeight(this, weight);
        }
Example #2
0
        public ICollection <IWeightedGraphNode <T> > GetWeightedGraphNodes()
        {
            List <IWeightedGraphNode <T> > result = new List <IWeightedGraphNode <T> >(Count);

            for (int i = 0; i < Count; i++)
            {
                WeightedGraphNode <T> node = new WeightedGraphNode <T>(InfinityWeight);
                int y = i / Width;
                int x = i - y * Width;
                node.Position = new Vector2Int(x, y);
                result.Add(node);
            }

            for (int i = 0; i < Count; i++)
            {
                WeightedGraphNode <T> node = (WeightedGraphNode <T>)result[i];

                for (int j = 0; j < Count; j++)
                {
                    WeightedGraphNode <T> connection = (WeightedGraphNode <T>)result[i];
                    node.Add(connection);
                    node.SetWeight(node.Count - 1, _weights[i, j]);
                }
            }

            return(result);
        }
 public WeightedGraphNodeEnumerator(WeightedGraphNode <T> node)
 {
     _node = node;
 }