Esempio n. 1
0
        public void EdgeContainerConstructorUnitTest()
        {
            Assert.Inconclusive("TODO");

            ushort           edgePropertyId = 0;    // TODO: Initialize to an appropriate value
            List <EdgeModel> edges          = null; // TODO: Initialize to an appropriate value
            var target = new EdgeContainer(edgePropertyId, edges);
        }
 public bool addVertex(TV vertex)
 {
     if (container.DataSet.ContainsKey(vertex))
     {
         return(false);
     }
     else
     {
         IEdgeContainer <TE> ec = new EdgeContainer <TE>(); ec.outgoing = new List <TE> (); ec.incoming = new List <TE> ();
         container.DataSet[vertex] = ec;
         return(true);
     }
 }
 public Network(int n)
 {
     ec = EdgeContainer.Instance;
     nc = NodeContainer.Instance;
     m  = new AdjacencyMatrix(n);
 }
Esempio n. 4
0
        private void InternDrawExpandSpanningTree()
        {
            Graphics grph = Graphics.FromImage(MyImage);
            int      n;
            Point    pt0, pt1;
            int      cnt = 0;

            if (chkBoxHullsSpanTree.Checked)
            {
                string key;
                int    indx1, indx2;

                indx1 = Math.Min(cmbBoxHulls1.SelectedIndex, cmbBoxHulls2.SelectedIndex);
                indx2 = Math.Max(cmbBoxHulls1.SelectedIndex, cmbBoxHulls2.SelectedIndex);
                if (indx1 != indx2)
                {
                    key = string.Format("{0}-{1}", indx1, indx2);
                    EdgeContainer eST = MyTSP.HullsSpanningTrees[key];
                    n = eST.Count;
                    for (int i = 0; i < n; i++)
                    {
                        var edg = MyTSP.Graph.GetEdge(eST.GetEdge(i));
                        pt0 = GetNewPoint(MyTSP.Graph.GetNode(edg.Node1).Attributes);
                        pt1 = GetNewPoint(MyTSP.Graph.GetNode(edg.Node2).Attributes);
                        grph.DrawLine(MyPM.MyPen, pt0, pt1);
                        cnt++;
                    }
                }
            }
            else
            {
                // take uniques
                List <int> edges = new List <int>();
                foreach (EdgeContainer eST in MyTSP.HullsSpanningTrees.Values)
                {
                    n = eST.Count;
                    for (int i = 0; i < n; i++)
                    {
                        if (!edges.Contains(eST.GetEdge(i)))
                        {
                            edges.Add(eST.GetEdge(i));
                        }
                    }
                }

                foreach (int e in edges)
                {
                    var edg = MyTSP.Graph.GetEdge(e);
                    if (edg.Active)
                    {
                        pt0 = GetNewPoint(MyTSP.Graph.GetNode(edg.Node1).Attributes);
                        pt1 = GetNewPoint(MyTSP.Graph.GetNode(edg.Node2).Attributes);
                        grph.DrawLine(MyPM.MyPen, pt0, pt1);
                        cnt++;
                    }
                }
            }

            lblNumEdges.Text       = string.Format("{0}", cnt);
            lblEdgesPerNode.Text   = string.Format("{0:F2}", (double)2 * cnt / MyTSP.Graph.NumberNodes);
            lblEdgeTotalRatio.Text = string.Format("{0:P2}", (double)cnt / MyTSP.Graph.NumberEdges);
            lblEdgeNodeRatio.Text  = string.Format("{0:F2}", (double)cnt / MyTSP.Graph.NumberNodes);
        }