Example #1
0
    void SpawnNodesButton()
    {
        if (GUILayout.Button("Spawn Nodes"))
        {
            GameObject _nodeHolderIns = (GameObject)Instantiate(nodeHolder, Vector3.zero, Quaternion.identity);
            _nodeHolderIns.name = "NodeHolder";
            _nodeHolderScript   = _nodeHolderIns.GetComponent <NodeHolder>();

            List <GameObject> createdNodes    = new List <GameObject>();
            List <Vector3>    createdNodesPos = new List <Vector3>();

            if (_nodeShape == NodeShape.NodeArrayShape.Cylinder)
            {
                SpawnCylinderNodeArray(_nodeHolderIns.transform, ref createdNodes, ref createdNodesPos);
            }
            else if (_nodeShape == NodeShape.NodeArrayShape.Cube)
            {
                SpawnCubeNodeArray(_nodeHolderIns.transform, ref createdNodes, ref createdNodesPos);
            }
            else if (_nodeShape == NodeShape.NodeArrayShape.Sphere)
            {
                SpawnSphereNodeArray(_nodeHolderIns.transform, ref createdNodes, ref createdNodesPos);
            }

            _nodeHolderScript.SetNodes(createdNodes, createdNodesPos);
            _nodeHolderScript.SetShape(_nodeShape);
        }
    }
        public override void Generate(int nodeCount, NodeHolder nodeHolder, EdgeHolder edgeHolder, AlgorithmType SelectedAlgorithm)
        {
            base.Generate(nodeCount, nodeHolder, edgeHolder, SelectedAlgorithm);

            var queue = new Queue <int>();

            for (int i = 1; i < nodeCount; i++)
            {
                queue.Enqueue(i);
            }

            for (int i = 0; i < nodeCount; i++)
            {
                var parent = nodeHolder.GetNodeAt(i);

                for (int j = 0; j < 3; j++)
                {
                    if (!queue.Any())
                    {
                        break;
                    }

                    var firstChildId = queue.Dequeue();
                    var child        = nodeHolder.GetNodeAt(firstChildId);

                    edgeHolder.AddEgde(new ConsoleEdge(parent, child));
                }
            }
        }
Example #3
0
    void Start()
    {
        hx = new HexNode();
        hx.initCoords(0, 0);
        hx.addHexNbrs();
        HexNode[] hhh = new HexNode[hx.HexNbrs.Count];
        hx.HexNbrs.Values.CopyTo(hhh, 0);
        foreach (HexNode h in hhh)
        {
            h.addHexNbrs();
        }
        foreach (HexNode h in NodeHolder.instance().HexList.Values)
        {
            GameObject go = GameObject.Instantiate(hex);
            go.transform.position = h.coordTransform();
            h.addSettNbrs();

/*			Debug.Log ("Hex at " + h.coords.asString() + " with neighbours at " +
 *                                 h.HexNbrs[0].coords.asString() + ", " +
 *                                 h.HexNbrs[1].coords.asString() + ", " +
 *                                 h.HexNbrs[2].coords.asString() + ", " +
 *                                 h.HexNbrs[3].coords.asString() + ", " +
 *                                 h.HexNbrs[4].coords.asString() + ", " +
 *                                 h.HexNbrs[5].coords.asString() + ", ");*/
        }
        foreach (SettNode s in NodeHolder.instance().SettList.Values)
        {
            GameObject whamo = GameObject.Instantiate(sett);
            whamo.transform.position = s.coordTransform();
        }
    }
Example #4
0
        /// <summary>
        /// Initiates the presenter form.
        /// </summary>
        public Presenter()
        {
            InitializeComponent();

            cb_choose_alg.Items.AddRange(Algorithms.ToArray());
            cb_choose_alg.SelectedIndex = 0;
            SelectedAlgorithm           = Algorithms[cb_choose_alg.SelectedIndex];

            cb_graph_type.Items.AddRange(Enum.GetNames(typeof(GraphType)));
            cb_graph_type.SelectedIndex = 0;

            DrawingPanelHelper     = new DrawingPanelHelper(this, drawing_panel, SelectedAlgorithm);
            EdgeHolder             = new EdgeHolder();
            NodeHolder             = new NodeHolder();
            NodeHolder.Terminated += TerminationDetected;

            clb_algorithmTypes.Items.AddRange(Algorithms.ToArray());
            clb_graphTypes.Items.AddRange(Enum.GetNames(typeof(GraphType)));

            visualSimulatorPanel.Dock = DockStyle.Fill; // remove this

            PerformanceAnalyserFormOperations = new PerformanceAnalyserFormOperations(this);
            btn_cancel.Click += new EventHandler(PerformanceAnalyserFormOperations.btn_cancel_Click);
            btn_runPerformanceAnalysis.Click += new EventHandler(PerformanceAnalyserFormOperations.btn_runPerformanceAnalysis_Click);

            GraphPersister = new GraphPersister(this);
            saveTopologyToolStripMenuItem.Click   += GraphPersister.SaveTopology;
            importTopologyToolStripMenuItem.Click += GraphPersister.ImportTopology;
        }
Example #5
0
        public override void Generate(int nodeCount, NodeHolder nodeHolder, EdgeHolder edgeHolder, string SelectedAlgorithm)
        {
            var arg = new PaintEventArgs(Drawing_panel.CreateGraphics(), new Rectangle());

            var radius = (Math.Min(Drawing_panel.Height, Drawing_panel.Width) - 80) / 2;
            var origin = new Point(Drawing_panel.Width / 2, Drawing_panel.Height / 2);

            for (int i = 0; i < nodeCount; i++)
            {
                var angle = 360 / (float)(nodeCount - 1) * i;

                var p = i == 0 ? origin : PointOnCircle(radius, angle, origin);

                if (!nodeHolder.AnyIntersecting(p))
                {
                    var node = NodeFactory.Create(SelectedAlgorithm, nodeHolder.NodeCount, new WinformsNodeVisualiser(arg, p.X, p.Y, nodeHolder.NodeCount, ParentForm), ParentForm.cb_selfStab.Checked, nodeHolder);

                    nodeHolder.AddNode(node);
                }
                else
                {
                    i--;
                }
            }
            ;

            for (int i = 0; i < nodeCount; i++)
            {
                var node1 = nodeHolder.GetNodeAt(0);
                var node2 = nodeHolder.GetNodeAt(i);

                edgeHolder.AddEgde(new WinformsEdge(arg, node1, node2));
            }
        }
Example #6
0
        public void Remove(object value)
        {
            this.CheckUpdateState();
            NodeHolder node = this.GetNode(value);

            this.RemoveNode(node.Node);
        }
Example #7
0
        public override void Generate(int nodeCount, NodeHolder nodeHolder, EdgeHolder edgeHolder, string SelectedAlgorithm)
        {
            var arg = new PaintEventArgs(Drawing_panel.CreateGraphics(), new Rectangle());

            for (int i = 0; i < nodeCount; i++)
            {
                var interval = (Drawing_panel.Width - 80) / (nodeCount - 1);

                var p = new Point(40 + (interval * i), Drawing_panel.Height / 2);

                if (!nodeHolder.AnyIntersecting(p))
                {
                    var node = NodeFactory.Create(SelectedAlgorithm, nodeHolder.NodeCount, new WinformsNodeVisualiser(arg, p.X, p.Y, nodeHolder.NodeCount, ParentForm), ParentForm.cb_selfStab.Checked, nodeHolder);

                    nodeHolder.AddNode(node);
                }
                else
                {
                    MessageBox.Show("Nodes do not fit in screen");
                    break;
                }
            }
            ;

            for (int i = 0; i < nodeCount; i++)
            {
                if (i != nodeCount - 1)
                {
                    var node1 = nodeHolder.GetNodeAt(i);
                    var node2 = nodeHolder.GetNodeAt(i + 1);

                    edgeHolder.AddEgde(new WinformsEdge(arg, node1, node2));
                }
            }
        }
Example #8
0
 private void InitializeHolders()
 {
     EdgeHolder             = new EdgeHolder();
     NodeHolder             = new NodeHolder();
     NodeHolder.Terminated += NodeHolder_Terminated;
     RunReport              = new RunReport(AlgorithmType, GraphType, NodeCount);
 }
        public void GenerateGraph(NodeHolder nodeHolder, EdgeHolder edgeHolder)
        {
            foreach (var tuple in Topology.Neighbourhoods)
            {
                var node1 = nodeHolder.GetNodeById(tuple.Item1);
                var node2 = nodeHolder.GetNodeById(tuple.Item2);

                if (node1 == null)
                {
                    node1 = Topology.States != null?
                            NodeFactory.Create(AlgorithmType, tuple.Item1, new ConsoleNodeVisualizer(tuple.Item1, edgeHolder), false, nodeHolder, Topology.States[tuple.Item1]) :
                                NodeFactory.Create(AlgorithmType, tuple.Item1, new ConsoleNodeVisualizer(tuple.Item1, edgeHolder), false, nodeHolder);

                    nodeHolder.AddNode(node1);
                }

                if (node2 == null)
                {
                    node2 = Topology.States != null?
                            NodeFactory.Create(AlgorithmType, tuple.Item2, new ConsoleNodeVisualizer(tuple.Item2, edgeHolder), false, nodeHolder, Topology.States[tuple.Item2]) :
                                NodeFactory.Create(AlgorithmType, tuple.Item2, new ConsoleNodeVisualizer(tuple.Item2, edgeHolder), false, nodeHolder);

                    nodeHolder.AddNode(node2);
                }

                if (!node1.IsNeigbourOf(node2.Id))
                {
                    edgeHolder.AddEgde(new ConsoleEdge(node1, node2));
                }
            }
        }
Example #10
0
    public void addHexNbr(int location)
    {
        int x = this.coords.x;
        int y = this.coords.y;

        if (location != 3 && location != 0)
        {
            if (location < 3)
            {
                x++;
            }
            else
            {
                x--;
            }
        }
        if (location != 1 && location != 4)
        {
            if (location < 4 && location > 1)
            {
                y--;
            }
            else
            {
                y++;
            }
        }
        HexNbrs[location] = new HexNode();
        if (!HexNbrs[location].initCoords(x, y))
        {
            HexNbrs[location] = NodeHolder.instance().HexList[new Point(x, y)];
        }
        HexNbrs[location].HexNbrs[(location + 3) % 6] = this;
    }
Example #11
0
        /// <summary>
        /// Removes the first instance of the specified object found.
        /// </summary>
        /// <param name="value">The object to remove</param>
        public void Remove(object value)
        {
            CheckUpdateState();
            NodeHolder nh = GetNode(value);

            RemoveNode(nh.Node);
        }
 public virtual void Generate(int nodeCount, NodeHolder nodeHolder, EdgeHolder edgeHolder, AlgorithmType SelectedAlgorithm)
 {
     for (int i = 0; i < nodeCount; i++)
     {
         var node = NodeFactory.Create(SelectedAlgorithm, nodeHolder.NodeCount, new ConsoleNodeVisualizer(nodeHolder.NodeCount, edgeHolder), SelfStab, nodeHolder);
         nodeHolder.AddNode(node);
     }
 }
Example #13
0
 void Awake()
 {
     astar           = GetComponent <AStar>();
     nodeHolder      = GetComponent <NodeHolder>();
     nodeHolder.Size = 20;
     nodeHolder.CreateNodeHolder(nodeHolder);
     pathFound = false;
 }
        public override void Generate(int nodeCount, NodeHolder nodeHolder, EdgeHolder edgeHolder, string SelectedAlgorithm)
        {
            var arg = new PaintEventArgs(Drawing_panel.CreateGraphics(), new Rectangle());

            var queue = new Queue <int>();

            var totalHeight = Math.Floor(Math.Log(nodeCount, 2)) + 1;

            var verticalInterval = (int)((Drawing_panel.Height - 80) / (totalHeight - 1));

            for (int i = 0; i < nodeCount; i++)
            {
                var currentDepth = (int)Math.Floor(Math.Log(i + 1, 2));

                var horizontalInterval = (int)((Drawing_panel.Width) / (Math.Pow(2, currentDepth) + 1));

                var currentIndex = (int)(i - (Math.Pow(2, currentDepth) - 1) + 1);

                Console.WriteLine("i: {0}, depth: {1}, currentIndex: {2}", i, currentDepth, currentIndex);

                var p = new Point((currentIndex) * horizontalInterval, (currentDepth) * verticalInterval + 40);

                if (!nodeHolder.AnyIntersecting(p))
                {
                    var node = NodeFactory.Create(SelectedAlgorithm, nodeHolder.NodeCount, new WinformsNodeVisualiser(arg, p.X, p.Y, nodeHolder.NodeCount, ParentForm), ParentForm.cb_selfStab.Checked, nodeHolder);

                    nodeHolder.AddNode(node);
                }
                else
                {
                    throw new Exception("Reached to screen limits");
                }
            }
            ;

            for (int i = 1; i < nodeCount; i++)
            {
                queue.Enqueue(i);
            }

            for (int i = 0; i < nodeCount; i++)
            {
                var parent = nodeHolder.GetNodeAt(i);

                for (int j = 0; j < 2; j++)
                {
                    if (!queue.Any())
                    {
                        break;
                    }

                    var firstChildId = queue.Dequeue();
                    var child        = nodeHolder.GetNodeAt(firstChildId);

                    edgeHolder.AddEgde(new WinformsEdge(arg, parent, child));
                }
            }
        }
Example #15
0
        static void Main(string[] args)
        {
            NodeHolder nodes = new NodeHolder();

            nodes.AddNode(new Node(LABEL_NAME, "Paul"));
            nodes.AddNode(new Node(LABEL_NAME, "John"));
            nodes.AddNode(new Node(LABEL_GAME, "Dota 2"));
            nodes.AddNode(new Node(LABEL_GAME, "AOE II"));
        }
Example #16
0
	public static NodeHolder instance(){
		if(master!=null){
			return master;
		}
		else{
			master = new NodeHolder();
			return master;
		}
	}
Example #17
0
        /// <summary>
        /// Returns the index of the first instance of the specified
        /// <paramref name="value"/> found.
        /// </summary>
        /// <param name="value">The object to search for</param>
        /// <returns>
        /// The index of the first instance found, or -1 if the element was not
        /// found.
        /// </returns>
        public int IndexOf(object value)
        {
            NodeHolder nh = GetNode(value);

            if (nh == null)
            {
                return(-1);
            }
            return(nh.Index);
        }
Example #18
0
        public int IndexOf(object value)
        {
            NodeHolder node = this.GetNode(value);

            if (node == null)
            {
                return(-1);
            }
            return(node.Index);
        }
Example #19
0
        private void ShowVisualSimulator(object sender, EventArgs e)
        {
            performanceAnalyserPanel.Dock = DockStyle.Fill; // remove this
            visualSimulatorPanel.Dock     = DockStyle.Fill; // remove this

            performanceAnalyserPanel.Visible = false;
            visualSimulatorPanel.Visible     = true;

            NodeHolder.RedrawAllNodes();
        }
Example #20
0
        private void InitializeHolders()
        {
            EdgeHolder = new EdgeHolder();
            NodeHolder = new NodeHolder();

            var graphGenerator = new TopologyGivenGraphGenerator(Topologies[IndexToRunForEachNodeCount], AlgorithmType);

            graphGenerator.GenerateGraph(NodeHolder, EdgeHolder);

            NodeHolder.Terminated += NodeHolder_Terminated;
            RunReport              = new RunReport(AlgorithmType, GraphType, NodeHolder.NodeCount);
        }
Example #21
0
 public static NodeHolder instance()
 {
     if (master != null)
     {
         return(master);
     }
     else
     {
         master = new NodeHolder();
         return(master);
     }
 }
Example #22
0
        public override void Generate(int nodeCount, NodeHolder nodeHolder, EdgeHolder edgeHolder, AlgorithmType SelectedAlgorithm)
        {
            base.Generate(nodeCount, nodeHolder, edgeHolder, SelectedAlgorithm);

            for (int i = 0; i < nodeCount; i++)
            {
                var node1 = nodeHolder.GetNodeAt(0);
                var node2 = nodeHolder.GetNodeAt(i);

                edgeHolder.AddEgde(new ConsoleEdge(node1, node2));
            }
        }
Example #23
0
 /// <summary>
 /// Starts the simulation of the algorithm run.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_run_Click(object sender, EventArgs e)
 {
     foreach (var node in NodeHolder.GetCopyList().AsParallel())
     {
         Task.Run(() =>
         {
             node.UserDefined_SingleInitiatorProcedure();
         });
     }
     ;
     NodeHolder.StartTerminationDetection();
 }
Example #24
0
        private void HandleReport()
        {
            RunReport.ReportNodes(NodeHolder.GetCopyList(), false);
            RunReport.GatherMessageCounts(NodeHolder.GetCopyList());
            RunReport.GatherMoveCount(NodeHolder.GetCopyList());
            RunReport.ReportInvalidNodes(NodeHolder.GetCopyList());
            RunReport.ReportDegrees(NodeHolder.GetCopyList());
            RunReport.ReportCongestions(NodeHolder.GetCopyList());
            RunReport.SetDuration(Duration.TotalSeconds);

            using (var streamWriter = new StreamWriter("test.txt", true))
                streamWriter.WriteLine(RunReport.ToString());
        }
Example #25
0
    public void CardinalMovement(Transform inputTransform, NodeHolder nodeHolder, float speed)
    {
        float distance = Vector2.Distance((Vector2)inputTransform.position, nodeHolder.Path[0]);

        if (distance > .025)
        {
            inputTransform.position = Vector3.MoveTowards(inputTransform.position, nodeHolder.Path[0], Time.deltaTime * speed);
        }
        else
        {
            inputTransform.position = nodeHolder.Path[0];
            nodeHolder.Path.Remove(nodeHolder.Path[0]);
        }
    }
Example #26
0
    public Stack <Vector2> MakePathFromNodes()
    {
        Stack <Vector2> path        = new Stack <Vector2> ();
        NodeHolder      currentNode = m_finalNode;

        path.Push(currentNode.GetTile().position);
        while (currentNode.GetPreviousNode() != null)
        {
            Debug.DrawLine(currentNode.GetTile().position, currentNode.GetPreviousNode().GetTile().position, Color.yellow, 10);
            currentNode = currentNode.GetPreviousNode();
            path.Push(currentNode.GetTile().position);
        }
        return(path);
    }
Example #27
0
    public bool initCoords(int x, int y)
    {
        if (!NodeHolder.instance().HexList.ContainsKey(new Point(x, y)))
        {
            coords.x = x;
            coords.y = y;
            NodeHolder.instance().HexList.Add((new Point(x, y)), this);
            Debug("Hex created at " + x + "," + y);

            updateNbrs();
            return(true);
        }
        Debug("Already a Hex at " + x + "," + y);
        return(false);
    }
Example #28
0
        /// <summary>
        /// Clears the drawing panel.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_clear_Click(object sender, EventArgs e)
        {
            DrawingPanelHelper.ClearPanel();

            NodeHolder.EmptyAllNodes();
            EdgeHolder.EmptyAllEdges();

            tb_console.Clear();

            cb_choose_alg.Enabled = true;
            if (cb_choose_alg.SelectedIndex == -1)
            {
                cb_choose_alg.SelectedIndex = 1;
            }
        }
Example #29
0
        /// <summary>
        /// Not implemented.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_proof_Click(object sender, EventArgs e)
        {
            var invalidNodes = NodeHolder.GetCopyList().Where(n => !n.IsValid());

            var runCountReport = string.Join("\n", NodeHolder.GetCopyList().Select(n => string.Format("node: {0}\t runCount: {1}", n.Id, n.MoveCount)));

            runCountReport += string.Format("\ntotal run count: {0}", NodeHolder.GetCopyList().Sum(n => n.MoveCount));

            if (!invalidNodes.Any())
            {
                MessageBox.Show(string.Format("{0}\nRun count report:\n{1}", "Each node is valid", runCountReport));
            }
            else
            {
                MessageBox.Show(string.Format("Some nodes are invalid: {0}", string.Join(",", invalidNodes.Select(n => n.Id.ToString()))));
            }
        }
Example #30
0
 public void updateNbrs()
 {
     if (direction == 0)
     {
         if (NodeHolder.instance().SettList.ContainsKey(new Point(coords.x + 1, coords.y + 1)))
         {
             SettNbrs[0]             = NodeHolder.instance().SettList[new Point(coords.x + 1, coords.y + 1)];
             SettNbrs[0].SettNbrs[1] = this;
             Debug("Connecting " + this.coords.asString() + " to " + SettNbrs[0].coords.asString() + " (0)");
         }
         if (NodeHolder.instance().SettList.ContainsKey(new Point(coords.x, coords.y - 2)))
         {
             SettNbrs[1]             = NodeHolder.instance().SettList[new Point(coords.x, coords.y - 2)];
             SettNbrs[1].SettNbrs[2] = this;
             Debug("Connecting " + this.coords.asString() + " to " + SettNbrs[1].coords.asString() + " (1)");
         }
         if (NodeHolder.instance().SettList.ContainsKey(new Point(coords.x - 1, coords.y + 1)))
         {
             SettNbrs[2]             = NodeHolder.instance().SettList[new Point(coords.x - 1, coords.y + 1)];
             SettNbrs[2].SettNbrs[0] = this;
             Debug("Connecting " + this.coords.asString() + " to " + SettNbrs[2].coords.asString() + " (2)");
         }
     }
     else
     {
         if (NodeHolder.instance().SettList.ContainsKey(new Point(coords.x + 1, coords.y - 1)))
         {
             SettNbrs[0]             = NodeHolder.instance().SettList[new Point(coords.x + 1, coords.y - 1)];
             SettNbrs[0].SettNbrs[2] = this;
             Debug("Connecting " + this.coords.asString() + " to " + SettNbrs[0].coords.asString() + " (0)");
         }
         if (NodeHolder.instance().SettList.ContainsKey(new Point(coords.x - 1, coords.y - 1)))
         {
             SettNbrs[1]             = NodeHolder.instance().SettList[new Point(coords.x - 1, coords.y - 1)];
             SettNbrs[1].SettNbrs[0] = this;
             Debug("Connecting " + this.coords.asString() + " to " + SettNbrs[1].coords.asString() + " (1)");
         }
         if (NodeHolder.instance().SettList.ContainsKey(new Point(coords.x, coords.y + 2)))
         {
             SettNbrs[2]             = NodeHolder.instance().SettList[new Point(coords.x, coords.y + 2)];
             SettNbrs[2].SettNbrs[1] = this;
             Debug("Connecting " + this.coords.asString() + " to " + SettNbrs[2].coords.asString() + " (2)");
         }
     }
 }
Example #31
0
    public void CreateNodeHolder(NodeHolder grid)
    {
        grid.Holder = new Node[grid.Size, grid.Size];

        for (int a = 0; a < grid.Size; a++)
        {
            for (int b = 0; b < grid.Size; b++)
            {
                grid.Holder[a, b] = new Node()
                {
                    Position    = new Vector2(a, b),
                    Traversable = true,
                    CellCost    = 10,
                    Affinity    = 10
                };
            }
        }
    }
Example #32
0
    public static string GetData()
    {
        //attempt login to xero now
        IOAuthSession session = null;
        try
        {
            session = new XeroApi.OAuth.XeroApiPrivateSession(
                "XeroAPI mini app",
                "9BMWMQ19COBLNVKIGZVXLDHL2095RB",
                new X509Certificate2(@"C:\hackfest\public_privatekey.pfx", "hackfest"));
        }
        catch (Exception ex)
        {
            //TODO notify user
            return "";
        }

        Repository repository = new Repository(session);

        List<Payment> list = repository.Payments.ToList();
        List<Contact> contacts = repository.Contacts.ToList();

        //associate contact ID with contact
        Dictionary<Guid, Contact> contactDict = new Dictionary<Guid, Contact>();

        foreach (Contact c in contacts)
        {
            contactDict.Add(c.ContactID, c);
        }
        /*
        //populate purchase list
        List<Purchase> purchases = new List<Purchase>();

        foreach (Payment payment in list)
        {
            Purchase p = new Purchase(payment, contactDict[payment.Invoice.Contact.ContactID]);
            purchases.Add(p);
        }*/

        // Populates the node dictionary
        Dictionary<String, Node> nodes = new Dictionary<String, Node>(); // A list of nodes to be displayed

        foreach (Payment payment in list)
        {
            Purchase p = new Purchase(payment, contactDict[payment.Invoice.Contact.ContactID]);
            if (!nodes.ContainsKey(p.Address))
            {
                nodes.Add(p.Address, new Node(p));
            }
            else
            {
                Node node = null;
                nodes.TryGetValue(p.Address, out node);
                node.addPurchase(p);
            }
        }

        //   PurchaseHolder holder = new PurchaseHolder(purchases);
        NodeHolder holder = new NodeHolder(nodes);

        //PurchaseHolder holder = new PurchaseHolder(purchases);

        //finally send the JSON data
        string json = JsonConvert.SerializeObject(holder);
        return json;
    }