Esempio n. 1
0
        //从xml数据中生成节点
        public pNode(XmlElement xNode)
        {
            XmlNode edges_xml;
            Node newNode;
            int intNum, tar, value;

            intNum = Convert.ToInt32(xNode.Attributes.GetNamedItem("num").Value);
            newNode = new Node(intNum);                                            //新建节点
            edges_xml = null;
            foreach (XmlNode curNode in xNode.ChildNodes)       //节点位置设置
            {
                if (curNode.Name == "Edges")//获取连边列表
                {
                    edges_xml = curNode;
                }
            }
            if (edges_xml == null)
            {
                return;
            }
            foreach (XmlNode edge in edges_xml.ChildNodes)                                     //遍历连边列表
            {
                tar = Convert.ToInt32(edge.Attributes.GetNamedItem("Target").Value);//读出目标节点
                value = Convert.ToInt32(edge.InnerText);                           //读出连边权重
                newNode.AddEdge(tar, value);                                        //加入连边
            }
            this.node = newNode;
        }
Esempio n. 2
0
        //从xml数据中生成节点
        public dNode(XmlElement xNode)
        {
            XmlNode x_xml, y_xml, com_xml, edges_xml;
            Node newNode;
            int x, y, intNum, tar, value;

            intNum = Convert.ToInt32(xNode.Attributes.GetNamedItem("num").Value);
            newNode = new Node(intNum);                                            //新建节点
            x_xml = y_xml = edges_xml = com_xml = null;
            foreach (XmlNode curNode in xNode.ChildNodes)       //节点位置设置
            {
                if (curNode.Name == "Xpos")//节点位置
                {
                    x_xml = curNode;
                }
                if (curNode.Name == "Ypos")
                {
                    y_xml = curNode;
                }
                if (curNode.Name == "ComCount")
                {
                    com_xml = curNode;
                }
                if (curNode.Name == "Edges")//获取连边列表
                {
                    edges_xml = curNode;
                }
            }
            if (x_xml == null || y_xml == null || edges_xml == null || com_xml == null)
            {
                return;
            }
            x = Convert.ToInt32(x_xml.InnerText);
            y = Convert.ToInt32(y_xml.InnerText);
            newNode.Location = new Point(x, y);
            this.ComCount = Convert.ToInt32(com_xml.InnerText);
            foreach (XmlNode edge in edges_xml.ChildNodes)                                     //遍历连边列表
            {
                tar = Convert.ToInt32(edge.Attributes.GetNamedItem("Target").Value);//读出目标节点
                value = Convert.ToInt32(edge.InnerText);                           //读出连边权重
                newNode.AddEdge(tar, value);                                        //加入连边
            }
            this.node = newNode;
        }
Esempio n. 3
0
 //方法///////////////////////////////
 public dNode(int iNum)    //构造函数:新建
 {
     this.node = new Node(iNum);
 }
Esempio n. 4
0
        //从xml数据中生成节点
        void IfComBehavior.XMLinput(XmlElement xNode, int intNumOffset)
        {
            XmlNode degree_xml, x_xml, y_xml, com_xml, edges_xml;
            Node newNode;
            int intNum, x, y, tar, value;

            intNum = Convert.ToInt32(xNode.Attributes.GetNamedItem("num").Value) - intNumOffset;
            newNode = new Node(intNum);                                            //新建节点
            degree_xml = x_xml = y_xml = com_xml = edges_xml = null;
            foreach (XmlNode curNode in xNode.ChildNodes)       //节点位置设置
            {
                if (curNode.Name == "Degree")//节点度
                {
                    degree_xml = curNode;
                }
                if (curNode.Name == "Xpos")//节点位置
                {
                    x_xml = curNode;
                }
                if (curNode.Name == "Ypos")
                {
                    y_xml = curNode;
                }
                if (curNode.Name == "ComCount")
                {
                    com_xml = curNode;
                }
                if (curNode.Name == "Edges")//获取连边列表
                {
                    edges_xml = curNode;
                }
            }
            if (x_xml == null || y_xml == null || edges_xml == null || com_xml == null)
            {
                return;
            }
            x = Convert.ToInt32(x_xml.InnerText);
            y = Convert.ToInt32(y_xml.InnerText);
            newNode.Location = new Point(x, y);
            this.intCom = Convert.ToInt32(com_xml.InnerText);

            foreach (XmlNode edge in edges_xml.ChildNodes)                                     //遍历连边列表
            {
                tar = Convert.ToInt32(edge.Attributes.GetNamedItem("Target").Value) - intNumOffset;//读出目标节点
                value = Convert.ToInt32(edge.InnerText);                           //读出连边权重
                newNode.AddEdge(tar, value);                                        //加入连边
            }
            this.node = newNode;
        }
Esempio n. 5
0
 private Node curNode;         //当前节点
 /*
  * Function: Reset
  * Description:实现IEnumerator接口的Reset方法,将集合索引置于第一个元素之前
  * Parameters:
  * Return Value:
  */
 public NodeEnumerator(Node node)
 {
     curNode = node;
     index = -1;
 }
Esempio n. 6
0
 public kNode(int iNum, WordResult word)    //构造函数:新建
 {
     this.node = new Node(iNum);
     this.strWord = word.Word;
     this.strType = word.Type;
     this.intLine = word.Line;
     this.intPosition = word.Position;
 }
Esempio n. 7
0
        //将xml数据转化为节点
        void IfPlatform.XMLinput(XmlElement xNode, int intNumOffset)
        {
            XmlNode degree_xml, x_xml, y_xml, word_xml, type_xml, line_xml, pos_xml, edges_xml;
            Node newNode;
            int intNum, x, y, tar;
            double value;

            intNum = Convert.ToInt32(xNode.Attributes.GetNamedItem("num").Value) - intNumOffset;
            newNode = new Node(intNum);                                            //新建节点

            degree_xml = x_xml = y_xml = edges_xml = null;
            word_xml = type_xml = line_xml = pos_xml = null;
            foreach (XmlNode curNode in xNode.ChildNodes)       //节点位置设置
            {
                if (curNode.Name == "Degree")//节点度
                {
                    degree_xml = curNode;
                }
                if (curNode.Name == "Xpos")//节点位置
                {
                    x_xml = curNode;
                }
                if (curNode.Name == "Ypos")
                {
                    y_xml = curNode;
                }
                if (curNode.Name == "Word")//词语内容
                {
                    word_xml = curNode;
                }
                if (curNode.Name == "Type")//词性
                {
                    type_xml = curNode;
                }
                if (curNode.Name == "Line")//所属语句
                {
                    line_xml = curNode;
                }
                if (curNode.Name == "Position")//所在位置
                {
                    pos_xml = curNode;
                }
                if (curNode.Name == "Edges")//获取连边列表
                {
                    edges_xml = curNode;
                }
            }
            if (x_xml == null || y_xml == null || edges_xml == null || word_xml == null || type_xml == null || line_xml == null || pos_xml == null)
            {
                return;
            }
            x = Convert.ToInt32(x_xml.InnerText);
            y = Convert.ToInt32(y_xml.InnerText);
            newNode.Location = new Point(x, y);
            this.strWord = word_xml.InnerText;
            this.strType = type_xml.InnerText;
            this.intLine = Convert.ToInt32(line_xml.InnerText);
            this.intPosition = Convert.ToInt32(pos_xml.InnerText);

            foreach (XmlNode edge in edges_xml.ChildNodes)                                     //遍历连边列表
            {
                tar = Convert.ToInt32(edge.Attributes.GetNamedItem("Target").Value) - intNumOffset;//读出目标节点
                value = Convert.ToDouble(edge.InnerText);                           //读出连边权重
                newNode.AddEdge(tar, value);                                        //加入连边
            }
            this.node = newNode;
        }