コード例 #1
0
 public void ToDataTable_ThrowsIfEdgeAttribMgrIsNull()
 {
     SimpleAdjList net = SimpleAdjListGenerator.GenerateAdjList(0, 0, true) as SimpleAdjList;
     net.EdgeAttributeMgr = null;
     SimpleAdjListEdgeAttributeExtractor xtor = new SimpleAdjListEdgeAttributeExtractor();
     DataTable table = xtor.ToDataTable(net);
 }
コード例 #2
0
        public void ToDataTable_MatchesNodeIndexToRowIndex(int testId, int numNodes, int numEdges, bool isDirected, bool selfLoops, bool multiEdges, int[] dataVals, int targetIndex)
        {
            // *** targetIndex is the node index for which the row value of the column will be set to -7
            // so the row index of the resulting table should match the node index

            ISimpleAdjList net = SimpleAdjListGenerator.GenerateAdjList(numNodes, numEdges, isDirected);
            SimpleAdjListAttributeListDataBuilder builder = new SimpleAdjListAttributeListDataBuilder(AttributeListType.Edge);
            builder.AddList<int>(net, dataVals);

            SimpleAdjListEdgeAttributeExtractor xtor = new SimpleAdjListEdgeAttributeExtractor();

            DataTable table = xtor.ToDataTable(net);
            Assert.IsNotNull(table, "table should not be null");

            Assert.AreEqual(1, table.Columns.Count, "Columns.Count should match expected");
            Assert.AreEqual(numEdges, table.Rows.Count, "table.Rows.Count should match expected");

            DataColumn col = table.Columns[0];
            Assert.IsNotNull(col, "col should not be null");
            Assert.AreEqual(typeof(int), col.DataType, "Columns.DataType should match expected");

            // get the value of the table at row[targetIndex]
            int result = (int)table.Rows[targetIndex][0];

            Assert.AreEqual(-7, result, "The val should match expected");
        }
コード例 #3
0
        public void ToDataTable_ThrowsIfNetworkIsIncorrectType()
        {
            INetwork net = new BlueSpider.Blob.TestSupport.Network.Dummies.DummySimpleAdjList();

            SimpleAdjListEdgeAttributeExtractor xtor = new SimpleAdjListEdgeAttributeExtractor();

            DataTable table = xtor.ToDataTable(net);
        }
コード例 #4
0
        public void ToDataTable_ThrowsIfNetworkIsNull()
        {
            ISimpleAdjList net = null;

            SimpleAdjListEdgeAttributeExtractor xtor = new SimpleAdjListEdgeAttributeExtractor();

            DataTable table = xtor.ToDataTable(net);
        }
コード例 #5
0
        public void ToFrame_WithZeroLists(int numNodes, int numEdges, bool isDirected)
        {
            ISimpleAdjList net = SimpleAdjListGenerator.GenerateAdjList(numNodes, numEdges, isDirected);

            SimpleAdjListEdgeAttributeExtractor xtor = new SimpleAdjListEdgeAttributeExtractor();

            SimpleFrame table = xtor.ToFrame(net) as SimpleFrame;
            Assert.IsNotNull(table, "table should not be null");

            Assert.AreEqual(0, table.Columns.Count, "Columns.Count should match expected");
            Assert.AreEqual(0, table.Rows.Count, "table.Rows.Count should match expected");
        }
コード例 #6
0
        public void ToFrame_WithOneList(int testId, int numNodes, int numEdges, bool isDirected, int[] dataVals)
        {
            ISimpleAdjList net = SimpleAdjListGenerator.GenerateAdjList(numNodes, numEdges, isDirected);
            SimpleAdjListAttributeListDataBuilder builder = new SimpleAdjListAttributeListDataBuilder(AttributeListType.Edge);
            builder.AddList<int>(net, dataVals);

            SimpleAdjListEdgeAttributeExtractor xtor = new SimpleAdjListEdgeAttributeExtractor();

            SimpleFrame table = xtor.ToFrame(net) as SimpleFrame;
            Assert.IsNotNull(table, "table should not be null");

            Assert.AreEqual(1, table.Columns.Count, "Columns.Count should match expected");
            Assert.AreEqual(numEdges, table.Rows.Count, "table.Rows.Count should match expected");

            DataColumn col = table.Columns[0];
            Assert.IsNotNull(col, "col should not be null");
            Assert.AreEqual(typeof(int), col.DataType, "Columns.DataType should match expected");

            string colName = col.ColumnName;

            object objVal = null;
            int val = -1;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                objVal = table.Rows[i][colName];
                Assert.IsNotNull(objVal, "objVal should not be null");
                Assert.IsInstanceOfType(typeof(int), objVal, "objVal should match expected type");
                val = (int)objVal;
                Assert.AreEqual(dataVals[i], val, "val should match expected");
            }
        }
コード例 #7
0
        public void ToFrame_WithMultipleListsWithIdenticalNames(int testId, int numNodes, int numEdges, bool isDirected, int[] intVals, double[] doubleVals, bool[] boolVals, string[] stringVals)
        {
            ISimpleAdjList net = SimpleAdjListGenerator.GenerateAdjList(numNodes, numEdges, isDirected);
            SimpleAdjListAttributeListDataBuilder builder = new SimpleAdjListAttributeListDataBuilder(AttributeListType.Edge);
            builder.AddList<int>(net, intVals, "list");
            builder.AddList<double>(net, doubleVals, "list");
            builder.AddList<bool>(net, boolVals, "list");
            builder.AddList<string>(net, stringVals, "list");

            SimpleAdjListEdgeAttributeExtractor xtor = new SimpleAdjListEdgeAttributeExtractor();

            SimpleFrame table = xtor.ToFrame(net) as SimpleFrame;
            Assert.IsNotNull(table, "table should not be null");

            Assert.AreEqual(4, table.Columns.Count, "Columns.Count should match expected");
            Assert.AreEqual(numEdges, table.Rows.Count, "table.Rows.Count should match expected");

            //--
            DataColumn intCol = table.Columns[0];
            Assert.IsNotNull(intCol, "col should not be null");
            Assert.AreEqual(typeof(int), intCol.DataType, "Columns.DataType should match expected");
            string intColName = intCol.ColumnName;

            //--
            DataColumn doubleCol = table.Columns[1];
            Assert.IsNotNull(doubleCol, "col should not be null");
            Assert.AreEqual(typeof(double), doubleCol.DataType, "Columns.DataType should match expected");
            string doubleColName = doubleCol.ColumnName;

            //--
            DataColumn boolCol = table.Columns[2];
            Assert.IsNotNull(boolCol, "col should not be null");
            Assert.AreEqual(typeof(bool), boolCol.DataType, "Columns.DataType should match expected");
            string boolColName = boolCol.ColumnName;

            //--
            DataColumn stringCol = table.Columns[3];
            Assert.IsNotNull(stringCol, "col should not be null");
            Assert.AreEqual(typeof(string), stringCol.DataType, "Columns.DataType should match expected");
            string stringColName = stringCol.ColumnName;

            object objVal = null;

            //-- ints
            int intVal = -1;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                objVal = table.Rows[i][intColName];
                Assert.IsNotNull(objVal, "objVal should not be null");
                Assert.IsInstanceOfType(typeof(int), objVal, "objVal should match expected type");
                intVal = (int)objVal;
                Assert.AreEqual(intVals[i], intVal, "val should match expected");
            }

            //-- doubles
            double doubleVal = -1.1;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                objVal = table.Rows[i][doubleColName];
                Assert.IsNotNull(objVal, "objVal should not be null");
                Assert.IsInstanceOfType(typeof(double), objVal, "objVal should match expected type");
                doubleVal = (double)objVal;
                Assert.AreEqual(doubleVals[i], doubleVal, "val should match expected");
            }

            //-- bools
            bool boolVal = false;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                objVal = table.Rows[i][boolColName];
                Assert.IsNotNull(objVal, "objVal should not be null");
                Assert.IsInstanceOfType(typeof(bool), objVal, "objVal should match expected type");
                boolVal = (bool)objVal;
                Assert.AreEqual(boolVals[i], boolVal, "val should match expected");
            }

            //-- strings
            string stringVal = null;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                objVal = table.Rows[i][stringColName];
                Assert.IsNotNull(objVal, "objVal should not be null");
                Assert.IsInstanceOfType(typeof(string), objVal, "objVal should match expected type");
                stringVal = (string)objVal;
                Assert.AreEqual(stringVals[i], stringVal, "val should match expected");
            }
        }
コード例 #8
0
 internal IEdgeDataExtractor _CreateEdgeDataExtractor(INetwork network)
 {
     IEdgeDataExtractor tool = null;
     if (network != null)
     {
         if (network is BlueSpider.Blob.Regular.Network.AdjList.SimpleAdjList)
         {
             tool = new SimpleAdjListEdgeAttributeExtractor();
         }
     }
     return tool;
 }