Пример #1
0
        public Connector Connect(Partite a, Partite b)
        {
            Connector connector = new Connector(a, b);

            mConnectors.Add(connector);
            return(connector);
        }
Пример #2
0
        public Partite CreatePartite(string name)
        {
            Partite partite = new Partite(name);

            mPartites.Add(partite);
            return(partite);
        }
Пример #3
0
 public void PrintVertex()
 {
     List <Partite> .Enumerator e = mPartites.GetEnumerator();
     while (e.MoveNext())
     {
         Partite v = e.Current;
         v.Print();
     }
 }
Пример #4
0
        public Partite GetPartite(string name)
        {
            List <Partite> .Enumerator e = mPartites.GetEnumerator();
            while (e.MoveNext())
            {
                Partite p = e.Current;
                if (p.GetName().CompareTo(name) == 0)
                {
                    return(p);
                }
            }

            return(null);
        }
Пример #5
0
        public void Init()
        {
            XmlNode graphNode =
                xDoc.SelectSingleNode("Graph");

            mGraph = new Graph();
            qGraph = new AdjacencyGraph <string, Edge <string> >(true);

            XmlNodeList partiteList =
                graphNode.SelectNodes("Partite");

            foreach (XmlNode nodeP in partiteList)
            {
                Partite partite = mGraph.CreatePartite(nodeP.Attributes
                                                       .GetNamedItem("name").Value);

                XmlNodeList vertexList =
                    nodeP.SelectNodes("Vertex");

                foreach (XmlNode nodeV in vertexList)
                {
                    Vertex vertex = mGraph.CreateVertex(nodeV.Attributes
                                                        .GetNamedItem("name").Value);

                    partite.AddVertex(vertex);

                    qGraph.AddVertex(nodeV.Attributes
                                     .GetNamedItem("name").Value);
                }
            }

            XmlNodeList connectorList = graphNode.SelectNodes("Connector");

            foreach (XmlNode nodeC in connectorList)
            {
                Partite partiteA = mGraph.GetPartite(nodeC.Attributes
                                                     .GetNamedItem("partite1").Value);
                Partite partiteB = mGraph.GetPartite(nodeC.Attributes
                                                     .GetNamedItem("partite2").Value);
                Connector connector = mGraph.Connect(partiteA, partiteB);

                XmlNodeList edgeList =
                    nodeC.SelectNodes("Edge");

                foreach (XmlNode nodeE in edgeList)
                {
                    Vertex vertexA = mGraph.GetVertex(nodeE.Attributes
                                                      .GetNamedItem("node1").Value);
                    Vertex vertexB = mGraph.GetVertex(nodeE.Attributes
                                                      .GetNamedItem("node2").Value);
                    Edge edge = mGraph.Connect(vertexA, vertexB);

                    connector.AddEdge(edge);

                    Edge <string> a_e = new Edge <string>(nodeE.Attributes
                                                          .GetNamedItem("node1").Value,
                                                          nodeE.Attributes
                                                          .GetNamedItem("node2").Value);
                    qGraph.AddEdge(a_e);
                }
            }

            foreach (var v in qGraph.Vertices)
            {
                Console.WriteLine("VERTEX: " + v);
            }
            foreach (var e in qGraph.Edges)
            {
                Console.WriteLine("EDGE: " + e);
            }
        }
Пример #6
0
 public Connector(Partite a, Partite b)
 {
     mPartiteA = a;
     mPartiteB = b;
     mEdges    = new List <Edge>();
 }