/// <summary>
        /// This method does all the job before calling the simulation window.
        /// </summary>
        private void _generate()
        {
            //initiate all the data including NodeActivator static variables

            int i = 0, j = 0;
            Dictionary <int, int> GraphIDtoID = new Dictionary <int, int>();

            SimWindow                          = new NonThreadedSimulationWin();
            NodeList.Nodes                     = null;
            NodeActivator.MaxFlow              = 0;
            NodeActivator.TotalNumberOfEdges   = 0;
            NodeActivator.NodeNums             = this._Vertexes.Length;
            NodeActivator.EdgeNums             = this._Edges.GetLength(0);
            NodeActivator.CommNums             = this._Commodities.GetLength(0);
            NodeActivator.TotalNumberOfEdges   = (float)this._Edges.GetLength(0);
            NodeActivator.NodeFailureRate      = this._FaiureRate;
            NodeActivator.WakeUpNodeList       = new HashSet <int>();
            NodeActivator.NodeSplitBySourceLog = new Dictionary <int, int>();
            NodeActivator.NodeSplitByTargetLog = new Dictionary <int, int>();
            NodeActivator.Cancel               = false;
            NodeActivator.FailNum              = 0;
            this._MaxThreshold                 = this._Vertexes.Length * this._MaxDemand;

            //set up poision style probability if failure probability is greater than zero
            if (this._FaiureRate > 0)
            {
                this._setNodeFailureNode();
                this._FaiureRate = this._FaiureRate / 10;
            }
            //add nodes to the static nodelist dictionary
            // The node IDs for simulation may be different than GUI ids
            foreach (int id in _Vertexes)
            {
                GraphIDtoID.Add(id, j);
                NodeList.Nodes.Add(j, new AdHocNode(j++, id, this._ProfitVal, this._FaiureRate));
            }
            try
            { //set up node data structures according to the edges in the network
                int to, from;
                for (i = 0; i < _Edges.GetLength(0); i++)
                {
                    from = this._Edges[i, 0];
                    to   = this._Edges[i, 1];
                    from = GraphIDtoID[from];
                    to   = GraphIDtoID[to];
                    NodeList.Nodes[from].Targets.Add(NodeList.Nodes[to].ID, true);
                    NodeList.Nodes[from].MyTargetThresholds.Add(NodeList.Nodes[to].ID, this._MaxThreshold);
                    NodeList.Nodes[from].TargetsAndFlowReached.Add(NodeList.Nodes[to].ID, 0);
                    NodeList.Nodes[from].TargetsAndMyFlowSent.Add(NodeList.Nodes[to].ID, new Dictionary <int, float>());
                    NodeList.Nodes[from].TargetsAndFlowForwarded.Add(NodeList.Nodes[to].ID, new Dictionary <string, float>());
                    NodeList.Nodes[to].Sources.Add(NodeList.Nodes[from].ID);
                    NodeList.Nodes[to].SourcesAndFlowConsumed.Add(NodeList.Nodes[from].ID, new Dictionary <int, float>());
                    NodeList.Nodes[to].SourcesAndFlowForwarded.Add(NodeList.Nodes[from].ID, new Dictionary <string, float[]>());
                    NodeList.Nodes[to].FlowBlockValueForSources.Add(NodeList.Nodes[from].ID, 0);
                    NodeList.Nodes[to].InFlow.Add(NodeList.Nodes[from].ID, new Dictionary <string, AdHocFlow>());
                }
                //update commodities according to the simulation ndoe ids
                for (i = 0; i < this._Commodities.GetLength(0); i++)
                {
                    NodeActivator.MaxFlow += this._Commodities[i, 2];
                    from = (int)this._Commodities[i, 0];
                    to   = (int)this._Commodities[i, 1];
                    this._Commodities[i, 0] = GraphIDtoID[from];
                    this._Commodities[i, 1] = GraphIDtoID[to];
                }
                SimWindow.Show();
                this._SplitNodes();
                this._SplitCommodities();
                this._TableFillAlgo();
                this._TotalSingleFlow        = this._CalculateSingleEdgeFlow();
                NodeActivator.SingleEdgeFlow = this._TotalSingleFlow;
            }
            catch (Exception e)
            {
                ExceptionMessage.Show("There was a problem with Data provided to simulation: " + e.ToString());
            }

            SimWindow.StartSim();
        }
        /// <summary>
        /// This method does all the job before calling the simulation window.
        /// </summary>
        private void _generate()
        {
            //initiate all the data including NodeActivator static variables

            int i = 0, j = 0;
            Dictionary<int, int> GraphIDtoID = new Dictionary<int, int>();
            SimWindow = new NonThreadedSimulationWin();
            NodeList.Nodes = null;
            NodeActivator.MaxFlow = 0;
            NodeActivator.TotalNumberOfEdges = 0;
            NodeActivator.NodeNums = this._Vertexes.Length;
            NodeActivator.EdgeNums = this._Edges.GetLength(0);
            NodeActivator.CommNums = this._Commodities.GetLength(0);
            NodeActivator.TotalNumberOfEdges = (float)this._Edges.GetLength(0);
            NodeActivator.NodeFailureRate = this._FaiureRate;
            NodeActivator.WakeUpNodeList = new HashSet<int>();
            NodeActivator.NodeSplitBySourceLog = new Dictionary<int, int>();
            NodeActivator.NodeSplitByTargetLog = new Dictionary<int, int>();
            NodeActivator.Cancel = false;
            NodeActivator.FailNum = 0;
            this._MaxThreshold = this._Vertexes.Length * this._MaxDemand;

            //set up poision style probability if failure probability is greater than zero
            if (this._FaiureRate > 0)
            {
                this._setNodeFailureNode();
                this._FaiureRate = this._FaiureRate / 10;
            }
            //add nodes to the static nodelist dictionary
            // The node IDs for simulation may be different than GUI ids
            foreach (int id in _Vertexes)
            {
                GraphIDtoID.Add(id, j);
                NodeList.Nodes.Add(j, new AdHocNode(j++, id, this._ProfitVal, this._FaiureRate));
            }
            try
            { //set up node data structures according to the edges in the network
                int to, from;
                for (i = 0; i < _Edges.GetLength(0); i++)
                {
                    from = this._Edges[i, 0];
                    to = this._Edges[i, 1];
                    from = GraphIDtoID[from];
                    to = GraphIDtoID[to];
                    NodeList.Nodes[from].Targets.Add(NodeList.Nodes[to].ID, true);
                    NodeList.Nodes[from].MyTargetThresholds.Add(NodeList.Nodes[to].ID, this._MaxThreshold);
                    NodeList.Nodes[from].TargetsAndFlowReached.Add(NodeList.Nodes[to].ID, 0);
                    NodeList.Nodes[from].TargetsAndMyFlowSent.Add(NodeList.Nodes[to].ID, new Dictionary<int, float>());
                    NodeList.Nodes[from].TargetsAndFlowForwarded.Add(NodeList.Nodes[to].ID, new Dictionary<string, float>());
                    NodeList.Nodes[to].Sources.Add(NodeList.Nodes[from].ID);
                    NodeList.Nodes[to].SourcesAndFlowConsumed.Add(NodeList.Nodes[from].ID, new Dictionary<int, float>());
                    NodeList.Nodes[to].SourcesAndFlowForwarded.Add(NodeList.Nodes[from].ID, new Dictionary<string, float[]>());
                    NodeList.Nodes[to].FlowBlockValueForSources.Add(NodeList.Nodes[from].ID, 0);
                    NodeList.Nodes[to].InFlow.Add(NodeList.Nodes[from].ID, new Dictionary<string, AdHocFlow>());
                }
                //update commodities according to the simulation ndoe ids
                for (i = 0; i < this._Commodities.GetLength(0); i++)
                {
                    NodeActivator.MaxFlow += this._Commodities[i, 2];
                    from = (int)this._Commodities[i, 0];
                    to = (int)this._Commodities[i, 1];
                    this._Commodities[i, 0] = GraphIDtoID[from];
                    this._Commodities[i, 1] = GraphIDtoID[to];
                }
                SimWindow.Show();
                this._SplitNodes();
                this._SplitCommodities();
                this._TableFillAlgo();
                this._TotalSingleFlow = this._CalculateSingleEdgeFlow();
                NodeActivator.SingleEdgeFlow = this._TotalSingleFlow;
            }
            catch (Exception e)
            {
                ExceptionMessage.Show("There was a problem with Data provided to simulation: " + e.ToString());
            }

            SimWindow.StartSim();
        }