Esempio n. 1
0
 /// <summary>
 /// Reads in a key element as the appropriate type of <see cref="Key"/> object, and depending on if the
 /// key is for node or edge, places it in <see cref="NodeDataMapKeys"/> or <see cref="EdgeDataMapKeys"/> accordingly.
 /// </summary>
 /// <param name="keyReader"></param>
 /// <param name="reader"></param>
 internal void ReadKey(KeyReader keyReader, XmlReader reader)
 {
     Key key = null;
     keyReader.Read(out key, reader);
     // Note:  The index is used for the colIndex when the node/edge attribs are mapped
     if (key.Domain == Domain.graph)
     {
         key.Index = GraphKeys.Count;
         GraphKeys.Add(key.Id, key);
     }
     else if (key.Domain == Domain.node)
     {
         key.Index = NodeDataMapKeys.Count;
         NodeDataMapKeys.Add(key.Id, key);
     }
     else if (key.Domain == Domain.edge)
     {
         key.Index = EdgeDataMapKeys.Count;
         EdgeDataMapKeys.Add(key.Id, key);
     }
 }
Esempio n. 2
0
        //P1
        /// <summary>
        /// Reads the graphml element and reads keys, nodes and edge markers
        /// </summary>
        /// <param name="network">The network created from this method</param>
        /// <param name="reader"></param>
        /// <remarks>Assumes reader.Name == "graphml" and reader.IsStartElement() == true</remarks>
        internal void ReadGraphML1(out IAdjList network, XmlReader reader)
        {
            // Create the keys and read the nodes
            network = null;

            if (reader.Name == "graphml" && reader.IsStartElement() && !reader.IsEmptyElement)
            {
                KeyReader kReader = new KeyReader();
                while (reader.Read() && reader.IsStartElement() && !IsCancellationPending)
                {
                    if (reader.Name == "key" && reader.IsStartElement())
                    {
                        ReadKey(kReader, reader);
                    }
                    else if (reader.Name == "graph" && reader.IsStartElement())
                    {
                        ReadNetwork(out network, reader);
                    }
                    else
                        throw new InvalidOperationException(string.Format("{0} elements are not supported yet.", reader.Name));
                }
            }
        }