Пример #1
0
        public void ShortestPathWithUndirectedArc()
        {
            createContext();

            var start = nodes[0];
            var end = nodes[3];
            var features = new FeatureType[]
            {
                ftypes[1],
                ftypes[0]
            };
            var shortestPath = new List<GraphObject>()
            {
                nodes[0],
                arcs[2],
                nodes[4],
                arcs[2],
                nodes[0],
                arcs[0],
                nodes[1],
                arcs[6],
                nodes[5],
                arcs[7],
                nodes[3]
            };

            var pathFinder = new AStarPathFinder();

            var path = pathFinder.FindPath(start, end, features);

            assertPathsEqual(shortestPath, path);
        }
Пример #2
0
 public Feature(string name, GraphObject graphObject,
                FeatureType featureType, string description = "")
 {
     Name = name;
     GraphObject = graphObject;
     FeatureType = featureType;
     Description = description;
 }
Пример #3
0
 private void addFeatureButton_Click(object sender, EventArgs e)
 {
     string name = featureNameBox.Text;
     string typeName = featureTypeBox.Text;
     if (name != "" && typeName != "")
     {
         FeatureType type = DbContext.FeatureTypes
             .FirstOrDefault(x => x.Name == typeName);
         if (type == null)
         {
             type = new FeatureType(typeName);
             DbContext.FeatureTypes.Add(type);
         }
         var feature = new Feature(name, graphObject, type);
         DbContext.Features.Add(feature);
         DbContext.SaveChanges();
         showObjectData();
         featureNameBox.Text = "";
         featureTypeBox.Text = "";
     }
 }
Пример #4
0
        public void SimpleShortestPath()
        {
            createContext();

            var start = nodes[0];
            var end = nodes[3];
            var features = new FeatureType[0];
            var shortestPath = new List<GraphObject>()
            {
                nodes[0],
                arcs[1],
                nodes[2],
                arcs[5],
                nodes[3]
            };

            var pathFinder = new AStarPathFinder();

            var path = pathFinder.FindPath(start, end, new List<FeatureType>());

            assertPathsEqual(shortestPath, path);
        }