Exemple #1
0
        public Graph ConnectNodes(LocationNode a, LocationNode b)
        {
            var containsA = AdjacencyList.Any(list => list.Contains(a));
            var containsB = AdjacencyList.Any(list => list.Contains(b));

            if (!containsA)
            {
                AddNode(a);
            }
            if (!containsB)
            {
                AddNode(b);
            }

            List <LocationNode>[] rootA = { new List <LocationNode>() };
            List <LocationNode>[] rootB = { new List <LocationNode>() };
            foreach (var list in AdjacencyList.Where(list => list[0] == a && rootA[0].Count == 0))
            {
                rootA[0] = list;
            }
            foreach (var list in AdjacencyList.Where(list => list[0] == b && rootB[0].Count == 0))
            {
                rootB[0] = list;
            }

            rootA[0].Add(b);
            rootB[0].Add(a);

            return(this);
        }
        public Graph ConnectNodes(LocationNode a, LocationNode b)
        {
            var containsA = AdjacencyList.Any(list => list.Contains(a));
            var containsB = AdjacencyList.Any(list => list.Contains(b));
            if (!containsA)
            {
                AddNode(a);
            }
            if (!containsB)
            {
                AddNode(b);
            }

            List<LocationNode>[] rootA = {new List<LocationNode>()};
            List<LocationNode>[] rootB = {new List<LocationNode>()};
            foreach (var list in AdjacencyList.Where(list => list[0] == a && rootA[0].Count == 0))
            {
                rootA[0] = list;
            }
            foreach (var list in AdjacencyList.Where(list => list[0] == b && rootB[0].Count == 0))
            {
                rootB[0] = list;
            }

            rootA[0].Add(b);
            rootB[0].Add(a);

            return this;
        }
 public Graph AddNode(LocationNode node)
 {
     if (node == null)
         return this;
     
     var contains = AdjacencyList.Any(list => list.Contains(node));
     if (contains)
         return this;
     AdjacencyList.Add(new List<LocationNode>{node});
     return this;
 }
 public PointF GetLocationOfNearestBeacon(PointF userPosition)
 {
     var distance = float.MaxValue;
     var selectedNode = new LocationNode{X = int.MinValue, Y = int.MinValue};
     foreach (var node in Graph.RootNodes)
     {
         var newDist = EptaStrategy.GetDistanceBetween(userPosition, node.AsPointF());
         if (!(newDist < distance)) 
             continue;
         distance = (float) newDist;
         selectedNode = node;
     }
     return selectedNode.AsPointF();
 }
Exemple #5
0
        public Graph AddNode(LocationNode node)
        {
            if (node == null)
            {
                return(this);
            }

            var contains = AdjacencyList.Any(list => list.Contains(node));

            if (contains)
            {
                return(this);
            }
            AdjacencyList.Add(new List <LocationNode> {
                node
            });
            return(this);
        }
        public PointF GetLocationOfNearestBeacon(PointF userPosition)
        {
            var distance     = float.MaxValue;
            var selectedNode = new LocationNode {
                X = int.MinValue, Y = int.MinValue
            };

            foreach (var node in Graph.RootNodes)
            {
                var newDist = EptaStrategy.GetDistanceBetween(userPosition, node.AsPointF());
                if (!(newDist < distance))
                {
                    continue;
                }
                distance     = (float)newDist;
                selectedNode = node;
            }
            return(selectedNode.AsPointF());
        }