public void CopyMapToFrame_ForDoubles(double[] vals, bool directed)
        {
            int nodeCount = vals.Length;
            INetworkAdjList srcNetwork = NetGenerator.GenerateAdjList(nodeCount, 0, directed);
            AdjListNodeDataBuilder builder = new AdjListNodeDataBuilder();

            INodeDoubleMap map = builder.SetDoubleValues(srcNetwork, 0, vals);

            SimpleFrameFactory fFac = new SimpleFrameFactory();
            SimpleFrame frame = fFac.Create(Guid.NewGuid()) as SimpleFrame;

            _Ingester.CopyMapToFrame(srcNetwork, map, frame);

            Assert.AreEqual(1, frame.ColumnCount, "frame column count should match expected.");
            Assert.AreEqual(nodeCount, frame.RowCount, "frame rows should match expected.");

            for (int i = 0; i < vals.Length; i++)
            {
                Assert.AreEqual(vals[i], frame.Rows[i][0], "Values should match");
            }
        }
        public void CopyMapToFrame_ForBools(int nodeCount, int edgeCount, bool[] vals, bool directed)
        {
            INetworkAdjList srcNetwork = NetGenerator.GenerateAdjList(nodeCount, 0, directed);
            NetGenerator.CreateEdges(srcNetwork, edgeCount);
            AdjListEdgeDataBuilder builder = new AdjListEdgeDataBuilder();

            IEdgeBoolMap map = builder.SetBoolValues(srcNetwork, 0, vals);

            SimpleFrameFactory fFac = new SimpleFrameFactory();
            SimpleFrame frame = fFac.Create(Guid.NewGuid()) as SimpleFrame;

            _Ingester.CopyMapToFrame(srcNetwork, map, frame);

            Assert.AreEqual(1, frame.ColumnCount, "frame column count should match expected.");
            Assert.AreEqual(edgeCount, frame.RowCount, "frame rows should match expected.");

            IColumnAccessor<bool> ca = new SimpleFrameColumnAccessor<bool>(0, frame);
            for (int i = 0; i < vals.Length; i++)
            {
                Assert.AreEqual(vals[i], ca[i], "Values should match");
            }
        }
        public BlueSpider.Blob.Common.Data.IFrame ToFrame(INetwork network)
        {
            if (network == null)
                throw new ArgumentNullException("network", "The input network must not be null.");
            if (!(network is IEdgeAttributes))
                throw new ArgumentException(string.Format("The input network must implement {0}.", typeof(IEdgeAttributes).Name), "network");

            IEdgeAttributes src = network as IEdgeAttributes;
            SimpleFrame frame = null;

            using (IFrameFactory fac = new SimpleFrameFactory())
            {
                frame = fac.Create(Guid.NewGuid()) as SimpleFrame;
                frame.Name = "Edge data";
            }

            AttributeListMgr mgr = src.EdgeAttributeMgr as AttributeListMgr;
            if (mgr == null)
                throw new ArgumentException("The EdgeAttributeMgr of the input network must not be null.", "network");

            string[] colNames = EnsureUniqueColNames(mgr);
            int ctr = 0;
            foreach (IAttributeList list in mgr.Lists)
            {
                frame.Columns.Add(new DataColumn(colNames[ctr++], list.DataType));
            }

            if (frame.Columns.Count>0)
                for (int i = 0; i < mgr.Depth; i++)
                {
                    frame.Rows.Add(mgr.GetRow(i));
                }

            frame.AcceptChanges();
            return frame;
        }