예제 #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);
        }
예제 #2
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);
        }
예제 #3
0
 public bool ContainsVertex(T vertex)
 {
     return(AdjacencyList.Any(x => x.Key.X == vertex.X && x.Key.Y == vertex.Y));
 }
예제 #4
0
 public bool ContainsLowerCaseLetters()
 {
     return(AdjacencyList.Any(x => !char.IsWhiteSpace(x.Key.Content) && char.IsLower(x.Key.Content)));
 }