示例#1
0
        /// <summary>
        /// Creates a series of columns in <paramref name="edgeAttribs"/> based on the names in <paramref name="edgeHeaders"/>.
        /// </summary>
        /// <param name="edgeAttribs">An IEdgeAttributes object</param>
        /// <param name="edgeHeaders">The edge header names read in from the file, (items are assumed to be unique).</param>
        /// <param name="writerHelper">An IKnownHeaderNamesHelper object to help</param>
        internal void CreateEdgeAttribs_XXX(IEdgeAttributes edgeAttribs, List<HeaderField> edgeHeaders, IKnownHeaderNamesReaderHelper writerHelper)
        {
            // Assumes nodeHeaders has unique entries

            // for each entry in headHeaderNames
            //  check if it is a known entry
            //  if it is
            //      create an attrib of that type
            //  else
            //      create an attrib of type string (defaut)
            HeaderMatch match = null;
            int attribColIndex = -1;
            foreach (var header in edgeHeaders)
            {
                match = writerHelper.GetKnownEdgeHeader(header.AttribColName);
                if (match != null)
                {
                    attribColIndex = edgeAttribs.EdgeData.AddColumn(match.NameToUse ?? header.AttribColName, match.DataType);
                }
                else
                {
                    attribColIndex = edgeAttribs.EdgeData.AddColumn(header.AttribColName, typeof(string));
                }
                header.AttribColumnIndex = attribColIndex;
            }
        }
        /// <summary>
        /// Populates <paramref name="copyTable"/> with node attribute data from <paramref name="srcNetwork"/>.
        /// The input table is assumed to have the correct structure (columns etc) but be empty of
        /// row data.  
        /// </summary>
        /// <param name="srcNetwork">The srcNetwork to extract node data attribs</param>
        /// <param name="includeEdgeIndices">If true include a col of node indices</param>
        /// <param name="copyTable">The empty, structured, table to be populated</param>
        /// <remarks>The reason for passing in the table is that it can be a plain datatable or a BasicFrame.</remarks>
        internal void PopulateTable(IEdgeAttributes srcNetwork, bool includeEdgeIndices, DataTable copyTable)
        {
            var srcTable = srcNetwork.EdgeData as DataAttributeTable<IEdge>;

            if (!includeEdgeIndices)
            {
                for (int i = 0; i < srcTable.Rows.Count; i++)
                {
                    copyTable.ImportRow(srcTable.Rows[i]);
                }
            }
            else
            {
                DataRow newRow = null;
                foreach (KeyValuePair<IEdge, DataRow> kvp in srcTable.RowOwnerMap)
                {
                    newRow = copyTable.NewRow();
                    newRow[0] = kvp.Key.Index;
                    for (int i = 0; i < srcNetwork.EdgeDataAttributeCount; i++)
                    {
                        newRow[i + 1] = kvp.Value[i];
                    }
                    copyTable.Rows.Add(newRow);
                }
                copyTable.AcceptChanges();
            }
        }
示例#3
0
        /// <summary>
        /// Creates a series of columns in <paramref name="edgeAttribs"/> based on the names in <paramref name="edgeHeaders"/>.
        /// All types are left as strings.
        /// </summary>
        /// <param name="edgeAttribs">An IEdgeAttributes object</param>
        /// <param name="edgeHeaders">The edge header names read in from the file, (items are assumed to be unique).</param>
        internal void CreateEdgeAttribs(IEdgeAttributes edgeAttribs, List<HeaderField> edgeHeaders)
        {
            // Assumes nodeHeaders has unique entries

            // for each entry in edgeHeaders
            // create an attrib of type defined by the header
            // and assign the index of the attrib back to he header
            foreach (var header in edgeHeaders)
            {
                header.AttribColumnIndex = edgeAttribs.EdgeData.AddColumn(header.AttribColName, header.AttribColumnType);
            }
        }
示例#4
0
 /// <summary>
 /// Assigns the value to <paramref name="edge"/> using the appropriate <see cref="IEdgeMap"/>.  The edge map
 /// corresponds to <paramref name="mapKeyId."/>
 /// </summary>
 /// <param name="mapKeyId">The string id of the <see cref="Key"/> object which corresponds to IEdgeMap to use.</param>
 /// <param name="rawVal">The raw string value which is to be converted to its final data type.</param>
 /// <param name="edge">The IEdge which will have the value assigned to it.</param>
 /// <param name="network">The parent network.</param>
 internal void MapEdgeAttrib(string mapKey, string rawVal, IEdge edge, IEdgeAttributes network)
 {
     Key key = EdgeDataMapKeys[mapKey];
     var value = Convert.ChangeType(rawVal, key.DataType);
     network.EdgeData.SetValue(edge, key.Index, value);
 }
示例#5
0
 internal void CreateEdgeMaps(IEdgeAttributes network, IDictionary<string, Key> edgeDataMapKeys)
 {
     foreach (KeyValuePair<string, Key> kvp in edgeDataMapKeys)
     {
         CreateDataAttribute(network, kvp.Value);
     }
 }
示例#6
0
 internal void CreateDataAttribute(IEdgeAttributes network, Key mapKey)
 {
     int index = network.EdgeData.AddColumn(mapKey.Name, mapKey.DataType);
 }
示例#7
0
        /// <summary>
        /// Creates a series of columns in <paramref name="edgeAttribs"/> based on the names in <paramref name="headerFields"/>.
        /// All types are left as strings.
        /// </summary>
        /// <param name="edgeAttribs">An IEdgeAttributes object</param>
        /// <param name="headerFields">The edge header names read in from the file, (items are assumed to be unique).</param>
        internal void CreateEdgeAttribs(IEdgeAttributes edgeAttribs, List<HeaderField> headerFields)
        {
            // Assumes nodeHeaders has unique entries

            // for each entry in headHeaderNames
            //  create an attrib of type string (defaut)
            int attribColIndex = -1;
            foreach (var header in headerFields)
            {
                attribColIndex = edgeAttribs.EdgeData.AddColumn(header.Name, typeof(string));
                header.IndexOfTargetAttribColumn = attribColIndex;
            }
        }