public void SimpleTopological7ContextTest()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
                new GraphNode <string>("Node2"),
                new GraphNode <string>("Node3"),
                new GraphNode <string>("Node4"),
                new GraphEdge <string>("Node1", "Node2"),
                new GraphEdge <string>("Node2", "Node3"),
                new GraphEdge <string>("Node3", "Node4"),
            };

            var graphContext = new GraphTopologicalContext <String, IGraphEdge <string> >(maxLevels: 2)
                               .AddStopNodeKey("Node3");

            IList <IList <IGraphNode <string> > > sort = map.TopologicalSort(graphContext);

            var compare = new List <IList <string> >
            {
                new List <string> {
                    "Node1"
                },
                new List <string> {
                    "Node2"
                },
            };

            Verify(sort, compare);
        }
示例#2
0
        public void Run_ShortGraph_PathFound()
        {
            // ARRAGE
            var expectedPath = new List <IGraphNode>();

            var map = new GraphMap();

            map.AddNode(new HexNode(0, 0));
            map.AddNode(new HexNode(1, 0));
            map.AddNode(new HexNode(0, 1));

            var nodesArray = map.Nodes.ToArray();

            map.AddEdge(nodesArray[0], nodesArray[2]);
            map.AddEdge(nodesArray[2], nodesArray[1]);

            expectedPath.Add(nodesArray[0]);
            expectedPath.Add(nodesArray[2]);
            expectedPath.Add(nodesArray[1]);

            var context = CreatePathFindingContext(map);

            var astar = new AStar(context, expectedPath.First(), expectedPath.Last());

            // ACT
            var factState = astar.Run();

            // ASSERT

            factState.Should().Be(State.GoalFound);

            var factPath = astar.GetPath();

            factPath.Should().BeEquivalentTo(expectedPath);
        }
示例#3
0
    public void CreateMap()
    {
        Tiles = new List <Tile>();

        _noise = new PerlinNoise(
            Data.Width,
            Data.Height,
            UnityEngine.Random.Range(0f, 99999f),
            UnityEngine.Random.Range(0f, 99999f),
            Data.Scale);

        // Создания тайлов по шуму
        for (int column = 0; column < Data.Width; column++)
        {
            for (int row = 0; row < Data.Height; row++)
            {
                var sample = _noise.GetSample(column, row);

                if (sample < 0.35f)
                {
                    Tiles.Add(CreateTile(Data.PrefabWater, CreateCoordinate(column, row)));
                }
                if (sample >= 0.35f && sample < 0.5f)
                {
                    Tiles.Add(CreateTile(Data.PrefabShores, CreateCoordinate(column, row)));
                }
                if (sample >= 0.5f)
                {
                    Tiles.Add(CreateTile(Data.PrefabEarth, CreateCoordinate(column, row)));
                }
            }
        }

        Graph = new GraphMap(Tiles);
    }
示例#4
0
        public void Level3PipelineTopological2Test()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("P0"),

                new GraphNode <string>("P0-A1"),
                new GraphEdge <string>("P0", "P0-A1"),

                new GraphNode <string>("P0-A2"),
                new GraphEdge <string>("P0", "P0-A2"),

                new GraphNode <string>("P0-A3"),
                new GraphEdge <string>("P0", "P0-A3"),
                new GraphDependOnEdge <string>("P0-A3", "P0-A2"),

                new GraphNode <string>("P3-A1"),
                new GraphEdge <string>("P0-A3", "P3-A1"),

                new GraphNode <string>("P3-A2"),
                new GraphEdge <string>("P0-A3", "P3-A2"),

                new GraphNode <string>("P0-A4"),
                new GraphDependOnEdge <string>("P0-A4", "P0-A1"),
                new GraphDependOnEdge <string>("P0-A4", "P0-A2"),
                new GraphDependOnEdge <string>("P0-A4", "P0-A3"),

                new GraphNode <string>("P4-A1"),
                new GraphEdge <string>("P0-A4", "P4-A1"),

                new GraphNode <string>("P4-A2"),
                new GraphEdge <string>("P0-A4", "P4-A2"),
            };

            IList <IList <IGraphNode <string> > > sort = map.TopologicalSort();

            var compare = new List <IList <string> >
            {
                new List <string> {
                    "P0"
                },
                new List <string> {
                    "P0-A1", "P0-A2"
                },
                new List <string> {
                    "P0-A3"
                },
                new List <string> {
                    "P3-A1", "P3-A2"
                },
                new List <string> {
                    "P0-A4"
                },
                new List <string> {
                    "P4-A1", "P4-A2"
                },
            };

            Verify(sort, compare);
        }
        public void TestExceptionHandling()
        {
            var job1 = new TestJob("Job1")
            {
                ThrowException = true
            };

            var graph = new GraphMap <string, JobBase <string>, IGraphEdge <string> >
            {
                job1,
            };

            var jobHost = new OrchestratorBuilder <string, JobBase <string>, IGraphEdge <string> >(graph)
                          .Build()
                          .Start(_workContext);

            jobHost.Wait(_workContext);

            jobHost.RunningTask.IsCompleted.Should().BeTrue();
            jobHost.GetProcessedNodeKeys().Count.Should().Be(0);
            jobHost.GetStopNodeKeys().Count.Should().Be(1);

            graph.Nodes.Values
            .All(x => x.GetResult(_workContext).Status == JobStatus.Failed)
            .Should()
            .BeTrue();
        }
        public void TestException2Handling()
        {
            var job1 = new TestJob("Job1")
            {
                ThrowException = true
            };
            var job1a = new TestJob("Job1-a");
            var job2  = new TestJob("Job2-a", job1);

            var graph = new GraphMap <string, JobBase <string>, IGraphEdge <string> >
            {
                job1,
                job1a,
                job2,
                new GraphEdge <string>(job1.Key, job2.Key)
            };

            var jobHost = new OrchestratorBuilder <string, JobBase <string>, IGraphEdge <string> >(graph)
                          .Build()
                          .Start(_workContext);

            jobHost.Wait(_workContext);
            jobHost.RunningTask.IsCompleted.Should().BeTrue();
            jobHost.GetProcessedNodeKeys().ForEach(x => _output.WriteLine($"ProcessNode: {x}"));
            jobHost.GetProcessedNodeKeys().Count.Should().Be(1);
            jobHost.GetStopNodeKeys().Count.Should().Be(1);
            jobHost.GetProcessedNodeKeys().Last().Should().Be(job1a.Key);
        }
        public void AllFilterGraphTests()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
                new GraphNode <string>("Node2"),
                new GraphNode <string>("Node3"),
                new GraphNode <string>("Node4"),

                new GraphEdge <string>("Node1", "Node2"),
                new GraphEdge <string>("Node2", "Node3"),
                new GraphEdge <string>("Node1", "Node4"),
            };

            var filter = map.CreateFilter()
                         .Include(map.Nodes["Node1"].Key);

            GraphMap <string, IGraphNode <string>, IGraphEdge <string> > newMap = map.Create(filter);

            newMap.Nodes.Count.Should().Be(4);
            newMap.Nodes.Values.Any(x => x.Key == "Node1").Should().BeTrue();
            newMap.Nodes.Values.Any(x => x.Key == "Node2").Should().BeTrue();
            newMap.Nodes.Values.Any(x => x.Key == "Node3").Should().BeTrue();
            newMap.Nodes.Values.Any(x => x.Key == "Node4").Should().BeTrue();
        }
示例#8
0
        public void ComplexGraphTest()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
                new GraphNode <string>("Node2"),
                new GraphNode <string>("Node3"),
                new GraphNode <string>("Node4"),

                new GraphEdge <string>("Node1", "Node2"),
                new GraphEdge <string>("Node2", "Node3"),
                new GraphEdge <string>("Node1", "Node4"),
            };

            IReadOnlyList <IGraphNode <string> > nodes = map.GetLeafNodes(map.Nodes["Node1"]);

            nodes.Should().NotBeNull();
            nodes.Count.Should().Be(2);
            nodes[0].Key.Should().Be("Node4");
            nodes[1].Key.Should().Be("Node3");

            nodes = map.GetLeafNodes(map.Nodes["Node2"]);
            nodes.Should().NotBeNull();
            nodes.Count.Should().Be(1);
            nodes[0].Key.Should().Be("Node3");

            nodes = map.GetLeafNodes(map.Nodes["Node3"]);
            nodes.Should().NotBeNull();
            nodes.Count.Should().Be(0);

            nodes = map.GetLeafNodes(map.Nodes["Node4"]);
            nodes.Should().NotBeNull();
            nodes.Count.Should().Be(0);
        }
 public SimpleOptionalLockedDoorWithMovie(GraphMap.Door door, string openMovie, string cantOpenMovie, string confirmationString, string idToReport, Color color)
     : base(door, idToReport, color)
 {
     this.openMovie = openMovie;
     this.cantOpenMovie = cantOpenMovie;
     this.confirmationString = confirmationString;
 }
示例#10
0
        private static WeightMatrix LinkNodes(GraphMap<FeatureVector, WeightMatrix>.ILinkable self, GraphMap<FeatureVector, WeightMatrix>.ILinkable node)
        {
            if (self.Data.sourcenames.Contains(node.Data.name))
            {
                MessageBox.Show("Cycles not supported yet");
                return null;
            }

            WeightMatrix wm = new WeightMatrix(self.Data.size + 1, node.Data.size);
            wm.linkAccess = self.LinkTo(node, wm);
            wm.linkAccess.AddAction("See Matrix", x =>
            {
                var fm = new ViewMatrix(x.weights);
                fm.Show();
            });
            wm.linkAccess.Name = wm.weights.ColumnCount + "x" + wm.weights.RowCount;

            foreach (var sourcename in self.Data.sourcenames)
            {
                node.Data.sourcenames.Add(sourcename);
            }

            // add new
            UpdateLinks(self);
            return wm;
        }
示例#11
0
        public void SimpleTreeTopological2Test()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
                new GraphNode <string>("Node2-1"),
                new GraphNode <string>("Node2-2"),
                new GraphNode <string>("Node3-1"),
                new GraphNode <string>("Node3-2"),
                new GraphEdge <string>("Node2-1", "Node1"),
                new GraphEdge <string>("Node2-2", "Node1"),
                new GraphEdge <string>("Node3-1", "Node2-1"),
                new GraphEdge <string>("Node3-2", "Node2-2"),
            };


            IList <IList <IGraphNode <string> > > sort = map.TopologicalSort();

            var compare = new List <IList <string> >
            {
                new List <string> {
                    "Node3-1", "Node3-2"
                },
                new List <string> {
                    "Node2-1", "Node2-2"
                },
                new List <string> {
                    "Node1"
                },
            };

            Verify(sort, compare);
        }
示例#12
0
        public void ThreeMix1JobTest()
        {
            var job1  = new TestJob("Job1");
            var job1a = new TestJob("Job1-a");
            var job2  = new TestJob("Job2-a", job1);

            var graph = new GraphMap <string, JobBase <string>, IGraphEdge <string> >
            {
                job1,
                job1a,
                job2,
                new GraphEdge <string>(job1.Key, job2.Key)
            };

            var jobHost = new OrchestratorBuilder <string, JobBase <string>, IGraphEdge <string> >(graph)
                          .Build()
                          .Start(_workContext);

            jobHost.Wait(_workContext);
            jobHost.RunningTask.IsCompleted.Should().BeTrue();
            jobHost.GetProcessedNodeKeys().ForEach(x => _output.WriteLine($"ProcessNode: {x}"));
            jobHost.GetProcessedNodeKeys().Count.Should().Be(3);
            jobHost.GetProcessedNodeKeys().Last().Should().Be(job2.Key);

            graph.Nodes.Values
            .All(x => x.GetResult(_workContext).Status == JobStatus.Completed)
            .Should()
            .BeTrue();
        }
示例#13
0
        public Clue(GraphMap.Clue mapClue, Color lockColour, string id)
        {
            Setup(mapClue);

            color = lockColour;
            this.id = id;
        }
示例#14
0
        public void ThreeLevelTopologicalTest()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
                new GraphNode <string>("Node2"),
                new GraphNode <string>("Node3"),
                new GraphNode <string>("Node4"),
                new GraphEdge <string>("Node2", "Node1"),
                new GraphEdge <string>("Node3", "Node2"),
                new GraphEdge <string>("Node4", "Node3"),
            };


            IList <IList <IGraphNode <string> > > sort = map.TopologicalSort();

            var compare = new List <IList <string> >
            {
                new List <string> {
                    "Node4"
                },
                new List <string> {
                    "Node3"
                },
                new List <string> {
                    "Node2"
                },
                new List <string> {
                    "Node1"
                },
            };

            Verify(sort, compare);
        }
示例#15
0
        public Clue(GraphMap.Clue mapClue)
        {
            Setup(mapClue);

            color = ColorPresets.Magenta;
            /*
            //Map id to color
            switch (parentId)
            {
                case "red":
                    color = ColorPresets.Red;
                    break;
                case "green":
                    color = ColorPresets.Green;
                    break;
                case "blue":
                    color = ColorPresets.Blue;
                    break;
                case "yellow":
                    color = ColorPresets.Yellow;
                    break;
                case "escape":
                    color = ColorPresets.Yellow;
                    break;
                case "self-destruct":
                    color = ColorPresets.LimeGreen;
                    break;
            }*/
        }
示例#16
0
        private void SetActions(GraphMap <FeatureVector> .Box box)
        {
            if (box.Data.layer != Layer.OUTPUT)
            {
                box.AddAction("Link", self =>
                {
                    gm.SelectNode(node =>
                    {
                        if (node.Data.layer != Layer.INPUT)
                        {
                            self.LinkTo(node);
                        }
                    });
                });
            }

            box.AddAction("Edit", self =>
            {
                EditFeatureVector editfv = new EditFeatureVector(self.Data);
                editfv.ShowDialog();
                self.Data.size = editfv.NumOfUnits;
                self.Data.name = editfv.FVName;
                self.Name      = editfv.FVName;
            });
        }
示例#17
0
文件: Neurone.cs 项目: Sorenly/neuron
        private static WeightMatrix LinkNodes(GraphMap <FeatureVector, WeightMatrix> .ILinkable self, GraphMap <FeatureVector, WeightMatrix> .ILinkable node)
        {
            if (self.Data.sourcenames.Contains(node.Data.name))
            {
                MessageBox.Show("Cycles not supported yet");
                return(null);
            }

            WeightMatrix wm = new WeightMatrix(self.Data.size + 1, node.Data.size);

            wm.linkAccess = self.LinkTo(node, wm);
            wm.linkAccess.AddAction("See Matrix", x =>
            {
                var fm = new ViewMatrix(x.weights);
                fm.Show();
            });
            wm.linkAccess.Name = wm.weights.ColumnCount + "x" + wm.weights.RowCount;

            foreach (var sourcename in self.Data.sourcenames)
            {
                node.Data.sourcenames.Add(sourcename);
            }

            // add new
            UpdateLinks(self);
            return(wm);
        }
示例#18
0
文件: Neurone.cs 项目: Sorenly/neuron
        private void SetActions(GraphMap <FeatureVector, WeightMatrix> .Box box)
        {
            box.Data.sourcenames.Add(box.Data.name);
            box.Data.state = new Matrix(box.Data.size, 1);

            if (box.Data.layer != LayerType.OUTPUT)
            {
                box.AddAction("Link", self =>
                {
                    gm.SelectNode(node =>
                    {
                        if (node.Data.layer != LayerType.INPUT)
                        {
                            LinkNodes((GraphMap <FeatureVector, WeightMatrix> .ILinkable)self, node);
                            return;
                        }
                    });
                });
            }

            //box.AddAction("Edit", self =>
            //{
            //    EditFeatureVector editfv = new EditFeatureVector(self.Data);
            //    editfv.ShowDialog();
            //    self.Data.size = editfv.NumOfUnits;
            //    self.Data.name = editfv.FVName;
            //    self.Name = editfv.FVName;
            //});
        }
示例#19
0
        // get real property name
        public void ProjectDataFilter(DataObject dataObject, ref DataFilter filter, GraphMap graphMap)
        {
            try
            {
                if (filter != null && (filter.Expressions != null || filter.OrderExpressions != null))
                {
                    _graphMap = graphMap;

                    DataObject _dataObject = dataObject;

                    if (filter.Expressions != null)
                    {
                        for (int i = 0; i < filter.Expressions.Count; i++)
                        {
                            Expression expression = filter.Expressions[i];

                            try
                            {
                                string[] propertyNameParts = expression.PropertyName.Split('.');
                                Values   values            = expression.Values;
                                string   dataPropertyName  = ProjectProperty(propertyNameParts, ref values);
                                expression.PropertyName = dataPropertyName.Substring(dataPropertyName.LastIndexOf('.') + 1);
                            }
                            catch (Exception e)
                            {
                                _logger.Error("Error projecting data filter expression [" + expression.ToString() + "]: " + e.Message);
                                filter.Expressions.RemoveAt(i--);
                            }
                        }
                    }

                    if (filter.OrderExpressions != null)
                    {
                        for (int i = 0; i < filter.OrderExpressions.Count; i++)
                        {
                            OrderExpression orderExpression = filter.OrderExpressions[i];

                            try
                            {
                                string[] propertyNameParts = orderExpression.PropertyName.Split('.');
                                string   dataPropertyName  = ProjectProperty(propertyNameParts);
                                orderExpression.PropertyName = dataPropertyName.Substring(dataPropertyName.LastIndexOf('.') + 1);
                            }
                            catch (Exception e)
                            {
                                _logger.Error("Error projecting data filter expression [" + orderExpression.ToString() + "]: " + e.Message);
                                filter.OrderExpressions.RemoveAt(i--);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string error = "Error while projecting a DataFilter: " + ex.Message;
                _logger.Error(error);
                throw new Exception(error);
            }
        }
示例#20
0
文件: Neurone.cs 项目: Sorenly/neuron
        private static void ResizeBox(FlowLayoutPanel flp, GraphMap <FeatureVector, WeightMatrix> .Box box)
        {
            flp.Width = flp.Parent.Width - 6;
            int numPerRow = flp.Width / 16;
            int rows      = box.Data.size / numPerRow;

            flp.Height = (rows + 1) * 16;
        }
示例#21
0
 public MovieClue(GraphMap.Clue mapClue, char representation, string pickupMovie, string description)
     : base(mapClue, ColorPresets.LimeGreen, pickupMovie)
 {
     Setup(mapClue);
     this.pickupMovie = pickupMovie;
     this.representation = representation;
     this.description = description;
 }
示例#22
0
        public void NoNodeTest()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
            };

            map.Invoking(x => x.GetLeafNodes(null)).Should().Throw <ArgumentNullException>();
        }
示例#23
0
        public Response Refresh(string graphName, XDocument xDocument)
        {
            Response response = new Response();

            response.StatusList = new List <Status>();

            Status status = new Status();

            status.Messages = new Messages();

            try
            {
                status.Identifier = graphName;

                DateTime startTime = DateTime.Now;
                _graphMap = _mapping.FindGraphMap(graphName);

                // create xdoc from rdf xelement
                Uri         graphUri    = new Uri(_graphNs.NamespaceName + graphName);
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(xDocument.ToString());
                xDocument.Root.RemoveAll();

                // load xdoc to graph
                RdfXmlParser parser = new RdfXmlParser();
                _graph.Clear();
                _graph.BaseUri = graphUri;
                parser.Load(_graph, xmlDocument);
                xmlDocument.RemoveAll();

                // delete old graph and save new one
                DeleteGraph(graphUri);
                _tripleStore.SaveGraph(_graph);

                DateTime endTime  = DateTime.Now;
                TimeSpan duration = endTime.Subtract(startTime);

                status.Messages.Add("Graph [" + graphName + "] has been refreshed in triple store successfully.");
                status.Messages.Add(
                    String.Format("Execution time [{0}:{1}.{2}] minutes.",
                                  duration.Minutes,
                                  duration.Seconds,
                                  duration.Milliseconds
                                  )
                    );
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Error refreshing graph [{0}]. {1}", graphName, ex));

                status.Level = StatusLevel.Error;
                status.Messages.Add(String.Format("Error refreshing graph [{0}]. {1}", graphName, ex));
            }

            response.Append(status);
            return(response);
        }
示例#24
0
        public void OneNodeTest()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
            };

            map.Nodes.Count.Should().Be(1);
            map.Edges.Count.Should().Be(0);
        }
示例#25
0
        public void VerifyGraphMapModelRequiredAnnotations()
        {
            var graphForValidation = new GraphMap
            {
                GraphString = string.Empty
            };
            var errorCount = CheckPropertyValidation.Validate(graphForValidation).Count;

            Assert.AreEqual(ClassValidationError, errorCount);
        }
示例#26
0
 public OutboundDtoTask(ManualResetEvent doneEvent, DtoProjectionEngine projectionLayer, DataLayerGateway dataLayerGateway,
                        GraphMap graphMap, DataObject dataObject, List <string> identifiers)
 {
     _doneEvent        = doneEvent;
     _dataLayerGateway = dataLayerGateway;
     _projectionLayer  = projectionLayer;
     _projectionLayer.dataLayerGateway = dataLayerGateway;
     _graphMap    = graphMap;
     _dataObject  = dataObject;
     _identifiers = identifiers;
 }
示例#27
0
 public DataTransferObjectsTask(ManualResetEvent doneEvent, DtoProjectionEngine projectionLayer, DataLayerGateway dataLayerGateway,
                                GraphMap graphMap, DataObject objectType, DataTransferObjects dataTransferObjects)
 {
     _doneEvent        = doneEvent;
     _dataLayerGateway = dataLayerGateway;
     _projectionLayer  = projectionLayer;
     _projectionLayer.dataLayerGateway = dataLayerGateway;
     _objectType          = objectType;
     _graphMap            = graphMap;
     _dataTransferObjects = dataTransferObjects;
 }
示例#28
0
        public void OneNodeTest()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
            };

            IReadOnlyList <IGraphNode <string> > nodes = map.GetLeafNodes(map.Nodes["Node1"]);

            nodes.Should().NotBeNull();
            nodes.Count.Should().Be(0);
        }
示例#29
0
        public void TwoNodesCountTest()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
                new GraphNode <string>("Node2"),
                new GraphEdge <string>("Node1", "Node2"),
            };

            map.Nodes.Count.Should().Be(2);
            map.Edges.Count.Should().Be(1);
        }
示例#30
0
 public LookForState(GameObject inv, List <Transition> trans, float lookSpeed)
 {
     //Store path following script from gameobject
     invocant      = inv;
     transitions   = trans;
     name          = "look";
     pathFollowing = invocant.GetComponent <GraphPathFollowing>();
     speed         = lookSpeed;
     graph         = GameObject.Find("Map Graph").GetComponent <GraphMap>();
     newTargetNode = -1;
     pathFollowing.astar_target = null;       //Set to null just in case
 }
示例#31
0
        public void TwoNodesSameKeyOverwriteTest()
        {
            GraphMap <string, IGraphNode <string>, IGraphEdge <string> > map = null !;

            map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
                new GraphNode <string>("Node1"),
            };

            map.Nodes.Count.Should().Be(1);
            map.Edges.Count.Should().Be(0);
        }
示例#32
0
 //TODO:
 public DtiTask(ManualResetEvent doneEvent, DtoProjectionEngine projectionLayer, DataLayerGateway dataLayerGateway,
                DataDictionary dictionary, GraphMap graphMap, DataFilter filter, int pageSize, int startIndex)
 {
     _doneEvent        = doneEvent;
     _dataLayerGateway = dataLayerGateway;
     _projectionLayer  = projectionLayer;
     _projectionLayer.dataLayerGateway = dataLayerGateway;
     _dictionary = dictionary;
     _graphMap   = graphMap;
     _filter     = Utility.CloneDataContractObject <DataFilter>(filter);
     _pageSize   = pageSize;
     _startIndex = startIndex;
 }
示例#33
0
        public void NoTopologicalTest()
        {
            var map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
            {
                new GraphNode <string>("Node1"),
                new GraphNode <string>("Node2"),
            };

            IList <IList <IGraphNode <string> > > sort = map.TopologicalSort();

            sort.Count.Should().Be(1);
            sort[0].Count.Should().Be(2);
        }
示例#34
0
        public void AdjacentTest()
        {
            IGraph <int> graph = GraphMap.New <int>();

            for (int i = 1; i <= 5; i++)
            {
                graph.Add(i);
            }
            graph.Add(1, 5);
            graph.Add(2, 5);
            graph.Add(3, 5);
            graph.Add(4, 5);
            Assert.IsTrue(graph.Adjacent(1, 5));
        }
示例#35
0
        public void TwoNodesWithEdgeErrorsTest()
        {
            GraphMap <string, IGraphNode <string>, IGraphEdge <string> > map = null;

            Action test = () =>
            {
                map = new GraphMap <string, IGraphNode <string>, IGraphEdge <string> >()
                {
                    new GraphNode <string>("Node1"),
                    new GraphNode <string>("Node2"),
                    new GraphEdge <string>("Node2", "Node-fake"),
                };
            };

            test.Should().Throw <ArgumentException>();
        }
示例#36
0
 public AntennaeObjective(GraphMap.Objective objective, IEnumerable<Clue> objectiveProducesClues)
     : base(objective, objectiveProducesClues)
 {
 }
 public SelfDestructObjective(GraphMap.Objective objective, IEnumerable<Clue> objectiveProducesClues)
     : base(objective, objectiveProducesClues)
 {
 }
示例#38
0
 void OnEnable()
 {
     graphMap = (GraphMap)target;
 }
示例#39
0
        private void Setup(GraphMap.Clue mapClue)
        {
            this.mapClue = mapClue;

            if (mapClue.LockedDoor != null)
            {
                parentId = mapClue.LockedDoor.Id;
            }
            else
            {
                parentId = mapClue.LockedObjective.Id;
            }
        }
示例#40
0
        private void SetActions(GraphMap<FeatureVector>.Box box)
        {
            if (box.Data.layer != Layer.OUTPUT)
            {
                box.AddAction("Link", self =>
                {
                    gm.SelectNode(node =>
                    {
                        if (node.Data.layer != Layer.INPUT)
                        {
                            self.LinkTo(node);
                        }
                    });
                });
            }

            box.AddAction("Edit", self =>
            {
                EditFeatureVector editfv = new EditFeatureVector(self.Data);
                editfv.ShowDialog();
                self.Data.size = editfv.NumOfUnits;
                self.Data.name = editfv.FVName;
                self.Name = editfv.FVName;
            });
        }
示例#41
0
 public ClueAutoPickup(GraphMap.Clue mapClue)
     : base(mapClue)
 {
 }
示例#42
0
 private static void ResizeBox(FlowLayoutPanel flp, GraphMap<FeatureVector, WeightMatrix>.Box box)
 {
     flp.Width = flp.Parent.Width - 6;
     int numPerRow = flp.Width / 16;
     int rows = box.Data.size / numPerRow;
     flp.Height = (rows + 1) * 16;
 }
示例#43
0
 private static void UpdateLinks(GraphMap<FeatureVector, WeightMatrix>.ILinkable self)
 {
 }
 public SimpleLockedDoorWithMovie(GraphMap.Door door, string openMovie, string cantOpenMovie, string idToReport, Color color)
     : base(door, idToReport, color)
 {
     this.openMovie = openMovie;
     this.cantOpenMovie = cantOpenMovie;
 }
示例#45
0
        private void SetActions(GraphMap<FeatureVector, WeightMatrix>.Box box)
        {
            box.Data.sourcenames.Add(box.Data.name);
            box.Data.state = new Matrix(box.Data.size, 1);

            if (box.Data.layer != LayerType.OUTPUT)
            {
                box.AddAction("Link", self =>
                {
                    gm.SelectNode(node =>
                    {
                        if (node.Data.layer != LayerType.INPUT)
                        {
                            LinkNodes((GraphMap<FeatureVector, WeightMatrix>.ILinkable)self, node);
                            return;
                        }
                    });
                });
            }

            //box.AddAction("Edit", self =>
            //{
            //    EditFeatureVector editfv = new EditFeatureVector(self.Data);
            //    editfv.ShowDialog();
            //    self.Data.size = editfv.NumOfUnits;
            //    self.Data.name = editfv.FVName;
            //    self.Name = editfv.FVName;
            //});
        }
示例#46
0
 public SimpleLockedDoor(GraphMap.Door door, string idToReport, Color color)
 {
     this.mapDoor = door;
     this.idToReport = idToReport;
     this.color = color;
 }
示例#47
0
 public SimpleObjective(GraphMap.Objective objective, IEnumerable<Clue> objectiveProducesClues)
 {
     this.obj = objective;
     this.objectiveProducesClues = objectiveProducesClues;
 }
示例#48
0
 private void Setup(GraphMap.Clue mapClue)
 {
     this.mapClue = mapClue;
 }
示例#49
0
        private void SetupStatePanel(FlowLayoutPanel flp, GraphMap<FeatureVector, WeightMatrix>.Box box)
        {
            foreach (CheckBox cb in flp.Controls)
            {
                cb.CheckedChanged += new EventHandler((o, ev) =>
                {
                    var chk = (o as CheckBox);
                    int num = (int)chk.Tag;
                    box.Data.state[num, 0] = chk.Checked ? 1 : 0;
                    btn_forwardProp_Click(o, ev);
                    chk.BackColor = chk.Checked ? Color.White : Color.Black;
                });
                flp.Width = 10;
                flp.Parent.Resize += new EventHandler((o, ev) =>
                {
                    ResizeBox(flp, box);
                });

                ResizeBox(flp, box);
            }
        }
示例#50
0
 public SimpleLockedDoor(GraphMap.Door door)
 {
     this.mapDoor = door;
     this.idToReport = door.Id;
 }