Example #1
0
        public static Graph ExampleGraph()
        {
            IGraphService graphService = new GraphService();
            Graph         graph        = graphService.NewGraph(false);

            Node nodeA = graphService.AddNode(ref graph, "nodeA");
            Node nodeB = graphService.AddNode(ref graph, "nodeB");
            Node nodeC = graphService.AddNode(ref graph, "nodeC");

            graphService.AddEdge(nodeA, nodeB, ref graph);
            graphService.AddEdge(nodeA, nodeC, ref graph);
            graphService.AddEdge(nodeB, nodeA, ref graph, 10.0D);
            graphService.AddEdge(nodeC, nodeA, ref graph, 7.0D);

            return(graph);
        }
Example #2
0
        public void OnLeftClick(Transform cameraTransform, bool isHit, RaycastHit raycastHit)
        {
            if (!isHit || raycastHit.collider.gameObject.tag != Constants.PhysicalNodeTag)
            {
                return;
            }

            var gameObjectHit    = raycastHit.collider.gameObject;
            var currentlyHitNode = _graphService.FindNodeByGameObject(gameObjectHit);

            // If not a node, don't do anything
            if (currentlyHitNode == null)
            {
                return;
            }

            if (_previouslyHitNode == null)
            {
                _previouslyHitNode = currentlyHitNode;
                EnableSelectedNodeGlow();
                return;
            }

            _graphService.AddEdge(currentlyHitNode, _previouslyHitNode);
            DeselectNode();
        }
        public void AddEdgeUnitTest()
        {
            Assert.Inconclusive("TODO");

            Fallen8           fallen8    = null;                      // TODO: Initialize to an appropriate value
            var               target     = new GraphService(fallen8); // TODO: Initialize to an appropriate value
            EdgeSpecification definition = null;                      // TODO: Initialize to an appropriate value
            int               expected   = 0;                         // TODO: Initialize to an appropriate value
            int               actual;

            actual = target.AddEdge(definition);
            Assert.AreEqual(expected, actual);
        }
Example #4
0
        public async Task MakeFullName()
        {
            Graph graph = _graphService.NewGraph(true);

            Node nodeA = _graphService.AddNode(ref graph, "nodeA");
            Node nodeB = _graphService.AddNode(ref graph, "nodeB");
            Node nodeC = _graphService.AddNode(ref graph, "nodeC");

            _graphService.AddEdge(nodeA, nodeB, ref graph, 12.0D);
            _graphService.AddEdge(nodeB, nodeA, ref graph, 10.0D);
            _graphService.AddEdge(nodeC, nodeA, ref graph, 7.0D);

            _graphService.RemoveEdge(nodeB, nodeA, ref graph);

            string firstName = _mainView.PersonName;
            string lastName  = _mainView.LastName;
            string fullName  = firstName + " " + lastName;


            new Thread(async x => {
                Graph downloadedGraph = await _apiService.GetGraph(1004);
                if (downloadedGraph != null)
                {
                    _mainView.LogTextBox = downloadedGraph.ToString();
                    _graphService.AddEdge(_graphService.FindSourceNode(downloadedGraph, 1010), _graphService.FindDestinationNode(downloadedGraph, 1008), ref downloadedGraph);
                    Graph updateResult    = await _apiService.UpdateGraph(downloadedGraph);
                    _mainView.LogTextBox += Environment.NewLine + updateResult.ToString();
                }
                else
                {
                    _mainView.LogTextBox = "graph null";
                }
            }).Start();

            _mainView.FullName = fullName;
        }