Пример #1
0
        /// <summary>
        /// Create an instance identifier set
        /// </summary>
        /// <param name="versionedDomainIdentifier"></param>
        /// <returns></returns>
        public SET <II> CreateIISet(MARC.HI.EHRS.SVC.Core.DataTypes.VersionedDomainIdentifier id)
        {
            SET <II> retVal = new SET <II>(2, II.Comparator);

            retVal.Add(new II(id.Domain, id.Identifier)
            {
                Scope = IdentifierScope.BusinessIdentifier
            });
            retVal.Add(new II(id.Domain, id.Version)
            {
                Scope = IdentifierScope.VersionIdentifier
            });
            return(retVal);
        }
Пример #2
0
        /// <summary>
        /// Returns a random simple digraph containing <tt>V</tt> vertices and <tt>E</tt> edges.
        /// </summary>
        /// <param name="v">V the number of vertices</param>
        /// <param name="e">E the number of vertices</param>
        /// <returns>a random simple digraph on <tt>V</tt> vertices, containing a total of <tt>E</tt> edges</returns>
        /// <exception cref="ArgumentException">if no such simple digraph exists</exception>
        public static Digraph Simple(int v, int e)
        {
            if (e > (long)v * (v - 1))
            {
                throw new ArgumentException("Too many edges");
            }
            if (e < 0)
            {
                throw new ArgumentException("Too few edges");
            }
            var g   = new Digraph(v);
            var set = new SET <EdgeD>();

            while (g.E < e)
            {
                var ve   = StdRandom.Uniform(v);
                var we   = StdRandom.Uniform(v);
                var edge = new EdgeD(ve, we);
                if ((ve != we) && !set.Contains(edge))
                {
                    set.Add(edge);
                    g.AddEdge(ve, we);
                }
            }
            return(g);
        }
Пример #3
0
        /// <summary>
        /// Returns a random simple DAG containing <tt>V</tt> vertices and <tt>E</tt> edges.
        /// Note: it is not uniformly selected at random among all such DAGs.
        /// </summary>
        /// <param name="v">V the number of vertices</param>
        /// <param name="e">E the number of vertices</param>
        /// <returns>a random simple DAG on <tt>V</tt> vertices, containing a total of <tt>E</tt> edges</returns>
        /// <exception cref="ArgumentException">if no such simple DAG exists</exception>
        public static Digraph Dag(int v, int e)
        {
            if (e > (long)v * (v - 1) / 2)
            {
                throw new ArgumentException("Too many edges");
            }
            if (e < 0)
            {
                throw new ArgumentException("Too few edges");
            }
            var g        = new Digraph(v);
            var set      = new SET <EdgeD>();
            var vertices = new int[v];

            for (var i = 0; i < v; i++)
            {
                vertices[i] = i;
            }
            StdRandom.Shuffle(vertices);
            while (g.E < e)
            {
                var ve   = StdRandom.Uniform(v);
                var we   = StdRandom.Uniform(v);
                var edge = new EdgeD(ve, we);
                if ((ve < we) && !set.Contains(edge))
                {
                    set.Add(edge);
                    g.AddEdge(vertices[ve], vertices[we]);
                }
            }
            return(g);
        }
Пример #4
0
        /// <summary>
        /// Returns a random simple graph containing <tt>V</tt> vertices and <tt>E</tt> edges.
        /// </summary>
        /// <param name="v">V the number of vertices</param>
        /// <param name="e">E the number of edges</param>
        /// <returns> random simple graph on <tt>V</tt> vertices, containing a total of <tt>E</tt> edges</returns>
        /// <exception cref="ArgumentException">if no such simple graph exists</exception>
        public static Graph Simple(int v, int e)
        {
            if (e > (long)v * (v - 1) / 2)
            {
                throw new ArgumentException("Too many edges");
            }
            if (e < 0)
            {
                throw new ArgumentException("Too few edges");
            }
            var g   = new Graph(v);
            var set = new SET <EdgeU>();

            while (g.E < e)
            {
                var ve   = StdRandom.Uniform(v);
                var we   = StdRandom.Uniform(v);
                var edge = new EdgeU(ve, we);
                if ((ve == we) || set.Contains(edge))
                {
                    continue;
                }
                set.Add(edge);
                g.AddEdge(ve, we);
            }
            return(g);
        }
Пример #5
0
        /// <summary>
        /// Returns a random rooted-out DAG on <tt>V</tt> vertices and <tt>E</tt> edges.
        /// A rooted out-tree is a DAG in which every vertex is reachable from a
        /// single vertex.
        /// The DAG returned is not chosen uniformly at random among all such DAGs.
        /// </summary>
        /// <param name="v">V the number of vertices</param>
        /// <param name="e">E the number of edges</param>
        /// <returns>a random rooted-out DAG on <tt>V</tt> vertices and <tt>E</tt> edges</returns>
        public static Digraph RootedOutDag(int v, int e)
        {
            if (e > (long)v * (v - 1) / 2)
            {
                throw new ArgumentException("Too many edges");
            }
            if (e < v - 1)
            {
                throw new ArgumentException("Too few edges");
            }
            var g   = new Digraph(v);
            var set = new SET <EdgeD>();

            // fix a topological order
            var vertices = new int[v];

            for (var i = 0; i < v; i++)
            {
                vertices[i] = i;
            }
            StdRandom.Shuffle(vertices);

            // one edge pointing from each vertex, other than the root = vertices[V-1]
            for (var ve = 0; ve < v - 1; ve++)
            {
                var we   = StdRandom.Uniform(ve + 1, v);
                var edge = new EdgeD(we, ve);
                set.Add(edge);
                g.AddEdge(vertices[we], vertices[ve]);
            }

            while (g.E < e)
            {
                var ve   = StdRandom.Uniform(v);
                var we   = StdRandom.Uniform(v);
                var edge = new EdgeD(we, ve);
                if ((ve < we) && !set.Contains(edge))
                {
                    set.Add(edge);
                    g.AddEdge(vertices[we], vertices[ve]);
                }
            }
            return(g);
        }
Пример #6
0
        /// <summary>
        /// Translates a dictionary of oid/ids to a set of II
        /// </summary>
        public static SET <II> CreateIdList(List <KeyValuePair <string, string> > identifiers)
        {
            SET <II> retVal = new SET <II>();

            foreach (var id in identifiers)
            {
                retVal.Add(new II(id.Key, id.Value));
            }
            return(retVal);
        }
Пример #7
0
        /// <summary>
        /// Create a set of II from a list of DomainIdentifier
        /// </summary>
        public SET <II> CreateIISet(List <DomainIdentifier> identifiers, List <IResultDetail> dtls)
        {
            SET <II> retVal = new SET <II>(identifiers.Count, II.Comparator);

            foreach (var id in identifiers)
            {
                retVal.Add(CreateII(id, dtls));
            }
            return(retVal);
        }
Пример #8
0
        internal static SET <string> getAdjacents(SymbolGraph sg, string vertice)
        {
            SET <string> set = new SET <string>();
            Graph        g   = sg.G;
            int          s   = sg.Index(vertice);

            foreach (int v in g.Adj(s))
            {
                set.Add(sg.Name(v));
            }
            return(set);
        }
        /// <summary>
        /// Create a set of II from a list of DomainIdentifier
        /// </summary>
        public SET <II> CreateIISet(List <DomainIdentifier> identifiers)
        {
            SET <II> retVal = new SET <II>(identifiers.Count, II.Comparator);

            foreach (var id in identifiers)
            {
                retVal.Add(new II()
                {
                    Root = id.Domain, Extension = id.Identifier
                });
            }
            return(retVal);
        }
Пример #10
0
        public void AddingDupesToSetTest01()
        {
            // Create the SET
            SET <INT> ints = new SET <INT>();

            // Add numbers 0 through 9
            for (var i = 0; i <= 9; i++)
            {
                ints.Add(i);
            }

            try
            {
                ints.Add(5);    // 5 already exists in the set. Exception is thrown
            }
            catch (DuplicateItemException e)
            {
                Console.WriteLine("Cannot add duplicate item.");
            }

            ints.NullFlavor = null;
            Assert.IsTrue(ints.Validate());
        }
Пример #11
0
        public static ClinicalDocument CreateAPSDocument(PatientData recordTarget, PatientData father, PhysicianData author, DateTime docDate, params Section[] sections)
        {
            var doc = CreateCDA(
                LIST <II> .CreateList(new II("1.3.6.1.4.1.19376.1.5.3.1.1.2"), new II("1.3.6.1.4.1.19376.1.5.3.1.1.11.2")),
                new CE <String>("57055-6", "2.16.840.1.113883.6.1", "LOINC", null, "Antepartum Summary Note", null),
                "Antepartum Summary",
                docDate,
                recordTarget,
                null,
                null,
                author,
                sections
                );

            // Father of fetus
            if (father != null)
            {
                SET <II> fatherIds = new SET <II>();
                foreach (var id in father.OtherIds)
                {
                    fatherIds.Add(new II(id.Key, id.Value));
                }

                doc.Participant.Add(new Participant1(ParticipationType.IND, ContextControl.OverridingNonpropagating, null, new IVL <TS>(new TS(recordTarget.DateOfBirth, DatePrecision.Year)), null)
                {
                    AssociatedEntity = new AssociatedEntity(RoleClassAssociative.NextOfKin,
                                                            fatherIds,
                                                            new CE <string>("xx - fatherofbaby ", " 2.16.840.1.113883.6.96 ", null, null, " Father of fetus ", null),
                                                            SET <AD> .CreateSET(AD.FromSimpleAddress(PostalAddressUse.HomeAddress, father.Address, null, father.City, father.State, " CA ", null)),
                                                            SET <TEL> .CreateSET(new TEL()
                    {
                        NullFlavor = NullFlavor.NoInformation
                    }),
                                                            new Person(SET <PN> .CreateSET(PN.FromFamilyGiven(EntityNameUse.Legal, father.FamilyName, father.GivenName))),
                                                            null)
                });
            }

            return(doc);
        }
Пример #12
0
        /// <summary>
        /// Returns a random simple bipartite graph on <tt>V1</tt> and <tt>V2</tt> vertices
        /// with <tt>E</tt> edges.
        /// </summary>
        /// <param name="v1">V1 the number of vertices in one partition</param>
        /// <param name="v2">V2 the number of vertices in the other partition</param>
        /// <param name="e">E the number of edges</param>
        /// <returns>a random simple bipartite graph on <tt>V1</tt> and <tt>V2</tt> vertices, containing a total of <tt>E</tt> edges</returns>
        /// <exception cref="ArgumentException">if no such simple bipartite graph exists</exception>
        public static Graph Bipartite(int v1, int v2, int e)
        {
            if (e > (long)v1 * v2) throw new ArgumentException("Too many edges");
            if (e < 0) throw new ArgumentException("Too few edges");
            var g = new Graph(v1 + v2);

            var vertices = new int[v1 + v2];
            for (var i = 0; i < v1 + v2; i++)
                vertices[i] = i;
            StdRandom.Shuffle(vertices);

            var set = new SET<EdgeU>();
            while (g.E < e)
            {
                var i = StdRandom.Uniform(v1);
                var j = v1 + StdRandom.Uniform(v2);
                var edge = new EdgeU(vertices[i], vertices[j]);
                if (set.Contains(edge)) continue;
                set.Add(edge);
                g.AddEdge(vertices[i], vertices[j]);
            }
            return g;
        }
Пример #13
0
        public void SETExceptionOps01()
        {
            // Create a set of all integers from 0 to 9
            SET <INT> ints = new SET <INT>(10);

            for (var i = 0; i <= 9; i++)
            {
                ints.Add(i);
            }

            // Get a set of even numbers
            SET <INT> evens = SET <INT> .CreateSET(2, 4, 6, 8);

            // Get a resultant set
            SET <INT> results = ints.Except(evens);

            foreach (var i in results)
            {
                Console.Write(i);
            }

            results.NullFlavor = null;
            Assert.IsTrue(results.Validate());
        }
Пример #14
0
        /// <summary>
        /// Returns a random simple bipartite graph on <tt>V1</tt> and <tt>V2</tt> vertices
        /// with <tt>E</tt> edges.
        /// </summary>
        /// <param name="v1">V1 the number of vertices in one partition</param>
        /// <param name="v2">V2 the number of vertices in the other partition</param>
        /// <param name="e">E the number of edges</param>
        /// <returns>a random simple bipartite graph on <tt>V1</tt> and <tt>V2</tt> vertices, containing a total of <tt>E</tt> edges</returns>
        /// <exception cref="ArgumentException">if no such simple bipartite graph exists</exception>
        public static Graph Bipartite(int v1, int v2, int e)
        {
            if (e > (long)v1 * v2)
            {
                throw new ArgumentException("Too many edges");
            }
            if (e < 0)
            {
                throw new ArgumentException("Too few edges");
            }
            var g = new Graph(v1 + v2);

            var vertices = new int[v1 + v2];

            for (var i = 0; i < v1 + v2; i++)
            {
                vertices[i] = i;
            }
            StdRandom.Shuffle(vertices);

            var set = new SET <EdgeU>();

            while (g.E < e)
            {
                var i    = StdRandom.Uniform(v1);
                var j    = v1 + StdRandom.Uniform(v2);
                var edge = new EdgeU(vertices[i], vertices[j]);
                if (set.Contains(edge))
                {
                    continue;
                }
                set.Add(edge);
                g.AddEdge(vertices[i], vertices[j]);
            }
            return(g);
        }
Пример #15
0
        /// <summary>
        /// Parse the PQ back into a structure
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Create the base formatter
            PDVFormatter baseFormatter = new PDVFormatter();

            baseFormatter.Host = this.Host;

            // Read temporary values
            string tUnit = null;

            if (s.GetAttribute("unit") != null)
            {
                tUnit = s.GetAttribute("unit");
            }
            SET <CodingRationale> tRationale = null;

            if (s.GetAttribute("codingRationale") != null)
            {
                tRationale = Util.Convert <SET <CodingRationale> >(s.GetAttribute("codingRationale"));
            }

            // Parse PDV content (only attributes)
            var retVal = baseFormatter.ParseAttributes <PQ>(s, result);

            // Set PDV content
            retVal.Unit            = tUnit;
            retVal.CodingRationale = tRationale;

            // Process elements
            // This requires a QTY formatter as QTY elements may be
            // in the stream as well
            #region Elements
            if (!s.IsEmptyElement)
            {
                // Prepare a formatter to process QTY elements
                QTYFormatter qtyFormatter = new QTYFormatter();
                qtyFormatter.Host = this.Host;

                // Exit markers
                int    sDepth = s.Depth;
                string sName  = s.Name;

                // Translations
                SET <PQR> translations = new SET <PQR>();

                // Read the next element
                s.Read();

                // Read until exit condition is fulfilled
                while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName))
                {
                    string oldName = s.Name; // Name
                    try
                    {
                        if (s.LocalName == "translation") // Format using ED
                        {
                            var hostResult = Host.Parse(s, typeof(PQR));
                            result.Code = hostResult.Code;
                            result.AddResultDetail(hostResult.Details);
                            translations.Add(hostResult.Structure as PQR);
                        }
                        else
                        {
                            qtyFormatter.ParseElementsInline(s, retVal, result);
                        }
                    }
                    catch (MessageValidationException e)
                    {
                        result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, s.ToString(), e));
                    }
                    finally
                    {
                        if (s.Name == oldName)
                        {
                            s.Read();
                        }
                    }
                }

                // Set translations
                if (!translations.IsEmpty)
                {
                    retVal.Translation = translations;
                }
            }
            #endregion

            // Validate
            ANYFormatter anyFormatter = new ANYFormatter();
            string       pathName     = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name;
            anyFormatter.Validate(retVal as ANY, pathName, result);

            // REturn instance
            return(retVal);
        }
Пример #16
0
        public void AddingDupesToSetTest01()
        {
            // Create the SET
            SET<INT> ints = new SET<INT>();

            // Add numbers 0 through 9
            for (var i = 0; i <= 9; i++)
            {
                ints.Add(i);
            }

            try
            {
                ints.Add(5);    // 5 already exists in the set. Exception is thrown
            }
            catch (DuplicateItemException e)
            {
                Console.WriteLine("Cannot add duplicate item.");
            }

            ints.NullFlavor = null;
            Assert.IsTrue(ints.Validate());
        }
Пример #17
0
 /// <summary>
 /// Returns a random simple DAG containing <tt>V</tt> vertices and <tt>E</tt> edges.
 /// Note: it is not uniformly selected at random among all such DAGs.
 /// </summary>
 /// <param name="v">V the number of vertices</param>
 /// <param name="e">E the number of vertices</param>
 /// <returns>a random simple DAG on <tt>V</tt> vertices, containing a total of <tt>E</tt> edges</returns>
 /// <exception cref="ArgumentException">if no such simple DAG exists</exception>
 public static Digraph Dag(int v, int e)
 {
     if (e > (long)v * (v - 1) / 2) throw new ArgumentException("Too many edges");
     if (e < 0) throw new ArgumentException("Too few edges");
     var g = new Digraph(v);
     var set = new SET<EdgeD>();
     var vertices = new int[v];
     for (var i = 0; i < v; i++)
         vertices[i] = i;
     StdRandom.Shuffle(vertices);
     while (g.E < e)
     {
         var ve = StdRandom.Uniform(v);
         var we = StdRandom.Uniform(v);
         var edge = new EdgeD(ve, we);
         if ((ve < we) && !set.Contains(edge))
         {
             set.Add(edge);
             g.AddEdge(vertices[ve], vertices[we]);
         }
     }
     return g;
 }
Пример #18
0
        public void SETExceptionOps01()
        {
            // Create a set of all integers from 0 to 9
            SET<INT> ints= new SET<INT>(10);
            for (var i = 0; i <= 9; i++ )
            {
                ints.Add(i);
            }

            // Get a set of even numbers
            SET<INT> evens = SET<INT>.CreateSET(2, 4, 6, 8);

            // Get a resultant set
            SET<INT> results = ints.Except(evens);

            foreach (var i in results)
            {
                Console.Write(i);
            }

            results.NullFlavor = null;
            Assert.IsTrue(results.Validate());
        }
Пример #19
0
 /// <summary>
 /// Returns a random simple digraph containing <tt>V</tt> vertices and <tt>E</tt> edges.
 /// </summary>
 /// <param name="v">V the number of vertices</param>
 /// <param name="e">E the number of vertices</param>
 /// <returns>a random simple digraph on <tt>V</tt> vertices, containing a total of <tt>E</tt> edges</returns>
 /// <exception cref="ArgumentException">if no such simple digraph exists</exception>
 public static Digraph Simple(int v, int e)
 {
     if (e > (long)v * (v - 1)) throw new ArgumentException("Too many edges");
     if (e < 0) throw new ArgumentException("Too few edges");
     var g = new Digraph(v);
     var set = new SET<EdgeD>();
     while (g.E < e)
     {
         var ve = StdRandom.Uniform(v);
         var we = StdRandom.Uniform(v);
         var edge = new EdgeD(ve, we);
         if ((ve != we) && !set.Contains(edge))
         {
             set.Add(edge);
             g.AddEdge(ve, we);
         }
     }
     return g;
 }
Пример #20
0
        /// <summary>
        /// Returns a random simple digraph on <tt>V</tt> vertices, <tt>E</tt>
        /// edges and (at least) <tt>c</tt> strong components. The vertices are randomly
        /// assigned integer labels between <tt>0</tt> and <tt>c-1</tt> (corresponding to
        /// strong components). Then, a strong component is creates among the vertices
        /// with the same label. Next, random edges (either between two vertices with
        /// the same labels or from a vetex with a smaller label to a vertex with a
        /// larger label). The number of components will be equal to the number of
        /// distinct labels that are assigned to vertices.
        /// </summary>
        /// <param name="v">V the number of vertices</param>
        /// <param name="e">E the number of edges</param>
        /// <param name="c">c the (maximum) number of strong components</param>
        /// <returns>a random simple digraph on <tt>V</tt> vertices and <tt>E</tt> edges, with (at most) <tt>c</tt> strong components</returns>
        /// <exception cref="ArgumentException">if <tt>c</tt> is larger than <tt>V</tt></exception>
        public static Digraph Strong(int v, int e, int c)
        {
            if (c >= v || c <= 0)
                throw new ArgumentException("Number of components must be between 1 and V");
            if (e <= 2 * (v - c))
                throw new ArgumentException("Number of edges must be at least 2(V-c)");
            if (e > (long)v * (v - 1) / 2)
                throw new ArgumentException("Too many edges");

            // the digraph
            var g = new Digraph(v);

            // edges added to G (to avoid duplicate edges)
            var set = new SET<EdgeD>();

            var label = new int[v];
            for (var i = 0; i < v; i++)
                label[i] = StdRandom.Uniform(c);

            // make all vertices with label c a strong component by
            // combining a rooted in-tree and a rooted out-tree
            for (var i = 0; i < c; i++)
            {
                // how many vertices in component c
                var count = 0;
                for (var ii = 0; ii < g.V; ii++)
                {
                    if (label[ii] == i) count++;
                }

                // if (count == 0) System.err.println("less than desired number of strong components");

                var vertices = new int[count];
                var j = 0;
                for (var jj = 0; jj < v; jj++)
                {
                    if (label[jj] == i) vertices[j++] = jj;
                }
                StdRandom.Shuffle(vertices);

                // rooted-in tree with root = vertices[count-1]
                for (var ve = 0; ve < count - 1; ve++)
                {
                    var we = StdRandom.Uniform(ve + 1, count);
                    var edge = new EdgeD(we, ve);
                    set.Add(edge);
                    g.AddEdge(vertices[we], vertices[ve]);
                }

                // rooted-out tree with root = vertices[count-1]
                for (var ve = 0; ve < count - 1; ve++)
                {
                    var we = StdRandom.Uniform(ve + 1, count);
                    var edge = new EdgeD(ve, we);
                    set.Add(edge);
                    g.AddEdge(vertices[ve], vertices[we]);
                }
            }

            while (g.E < e)
            {
                var ve = StdRandom.Uniform(v);
                var we = StdRandom.Uniform(v);
                var edge = new EdgeD(ve, we);
                if (!set.Contains(edge) && ve != we && label[ve] <= label[we])
                {
                    set.Add(edge);
                    g.AddEdge(ve, we);
                }
            }

            return g;
        }
Пример #21
0
 //internal IfcFillAreaStyle(IfcFillAreaStyle i) : base(i) { mFillStyles = new List<int>(i.mFillStyles.ToArray()); }
 public IfcFillAreaStyle(IfcFillStyleSelect style) : base(style.Database)
 {
     mFillStyles.Add(style);
 }
Пример #22
0
        /// <summary>
        /// Returns a random rooted-out DAG on <tt>V</tt> vertices and <tt>E</tt> edges.
        /// A rooted out-tree is a DAG in which every vertex is reachable from a
        /// single vertex.
        /// The DAG returned is not chosen uniformly at random among all such DAGs.
        /// </summary>
        /// <param name="v">V the number of vertices</param>
        /// <param name="e">E the number of edges</param>
        /// <returns>a random rooted-out DAG on <tt>V</tt> vertices and <tt>E</tt> edges</returns>
        public static Digraph RootedOutDag(int v, int e)
        {
            if (e > (long)v * (v - 1) / 2) throw new ArgumentException("Too many edges");
            if (e < v - 1) throw new ArgumentException("Too few edges");
            var g = new Digraph(v);
            var set = new SET<EdgeD>();

            // fix a topological order
            var vertices = new int[v];
            for (var i = 0; i < v; i++)
                vertices[i] = i;
            StdRandom.Shuffle(vertices);

            // one edge pointing from each vertex, other than the root = vertices[V-1]
            for (var ve = 0; ve < v - 1; ve++)
            {
                var we = StdRandom.Uniform(ve + 1, v);
                var edge = new EdgeD(we, ve);
                set.Add(edge);
                g.AddEdge(vertices[we], vertices[ve]);
            }

            while (g.E < e)
            {
                var ve = StdRandom.Uniform(v);
                var we = StdRandom.Uniform(v);
                var edge = new EdgeD(we, ve);
                if ((ve < we) && !set.Contains(edge))
                {
                    set.Add(edge);
                    g.AddEdge(vertices[we], vertices[ve]);
                }
            }
            return g;
        }
Пример #23
0
 public IfcFace(IfcFaceOuterBound outer) : base(outer.mDatabase)
 {
     mBounds.Add(outer);
 }
Пример #24
0
        /// <summary>
        /// Returns a random simple digraph on <tt>V</tt> vertices, <tt>E</tt>
        /// edges and (at least) <tt>c</tt> strong components. The vertices are randomly
        /// assigned integer labels between <tt>0</tt> and <tt>c-1</tt> (corresponding to
        /// strong components). Then, a strong component is creates among the vertices
        /// with the same label. Next, random edges (either between two vertices with
        /// the same labels or from a vetex with a smaller label to a vertex with a
        /// larger label). The number of components will be equal to the number of
        /// distinct labels that are assigned to vertices.
        /// </summary>
        /// <param name="v">V the number of vertices</param>
        /// <param name="e">E the number of edges</param>
        /// <param name="c">c the (maximum) number of strong components</param>
        /// <returns>a random simple digraph on <tt>V</tt> vertices and <tt>E</tt> edges, with (at most) <tt>c</tt> strong components</returns>
        /// <exception cref="ArgumentException">if <tt>c</tt> is larger than <tt>V</tt></exception>
        public static Digraph Strong(int v, int e, int c)
        {
            if (c >= v || c <= 0)
            {
                throw new ArgumentException("Number of components must be between 1 and V");
            }
            if (e <= 2 * (v - c))
            {
                throw new ArgumentException("Number of edges must be at least 2(V-c)");
            }
            if (e > (long)v * (v - 1) / 2)
            {
                throw new ArgumentException("Too many edges");
            }

            // the digraph
            var g = new Digraph(v);

            // edges added to G (to avoid duplicate edges)
            var set = new SET <EdgeD>();

            var label = new int[v];

            for (var i = 0; i < v; i++)
            {
                label[i] = StdRandom.Uniform(c);
            }

            // make all vertices with label c a strong component by
            // combining a rooted in-tree and a rooted out-tree
            for (var i = 0; i < c; i++)
            {
                // how many vertices in component c
                var count = 0;
                for (var ii = 0; ii < g.V; ii++)
                {
                    if (label[ii] == i)
                    {
                        count++;
                    }
                }

                // if (count == 0) System.err.println("less than desired number of strong components");

                var vertices = new int[count];
                var j        = 0;
                for (var jj = 0; jj < v; jj++)
                {
                    if (label[jj] == i)
                    {
                        vertices[j++] = jj;
                    }
                }
                StdRandom.Shuffle(vertices);

                // rooted-in tree with root = vertices[count-1]
                for (var ve = 0; ve < count - 1; ve++)
                {
                    var we   = StdRandom.Uniform(ve + 1, count);
                    var edge = new EdgeD(we, ve);
                    set.Add(edge);
                    g.AddEdge(vertices[we], vertices[ve]);
                }

                // rooted-out tree with root = vertices[count-1]
                for (var ve = 0; ve < count - 1; ve++)
                {
                    var we   = StdRandom.Uniform(ve + 1, count);
                    var edge = new EdgeD(ve, we);
                    set.Add(edge);
                    g.AddEdge(vertices[ve], vertices[we]);
                }
            }

            while (g.E < e)
            {
                var ve   = StdRandom.Uniform(v);
                var we   = StdRandom.Uniform(v);
                var edge = new EdgeD(ve, we);
                if (!set.Contains(edge) && ve != we && label[ve] <= label[we])
                {
                    set.Add(edge);
                    g.AddEdge(ve, we);
                }
            }

            return(g);
        }
Пример #25
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            
            // XP is special, it does not extend anything so we have to graph from scratch
            var instance = o as ENXP;

            // Null flavor?
            if (instance.NullFlavor != null)
                s.WriteAttributeString("nullFlavor", Util.ToWireFormat(instance.NullFlavor));
            else
            {
                // Validate 
                DatatypeR2FormatterParseResult tResult = new DatatypeR2FormatterParseResult(result.ValidateConformance);
                new ANYFormatter().Validate(instance, s.ToString(), tResult);
                result.AddResultDetail(tResult.Details);
                
                // Qualifiers (copy for modification)
                SET<CS<EntityNamePartQualifier>> qualifiers = new SET<CS<EntityNamePartQualifier>>();
                if(instance.Qualifier != null)
                    foreach (var qlf in instance.Qualifier)
                        qualifiers.Add(qlf.Clone() as CS<EntityNamePartQualifier>);

                // Unsupported properties
                if (instance.ControlActExt != null)
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ControlActExt", "ENXP", s.ToString()));
                if (instance.ControlActRoot != null)
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ControlActRoot", "ENXP", s.ToString()));
                if (instance.ValidTimeHigh != null)
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ValidTimeHigh", "ENXP", s.ToString()));
                if (instance.ValidTimeLow != null)
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ValidTimeLow", "ENXP", s.ToString()));
                if (instance.Flavor != null)
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Flavor", "ENXP", s.ToString()));
                if (instance.UpdateMode != null)
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "UpdateMode", "ENXP", s.ToString()));

                // Output the supported properties
                if (instance.Value != null)
                    s.WriteAttributeString("value", instance.Value);
                if (instance.Code != null)
                    s.WriteAttributeString("code", instance.Code);
                if (instance.CodeSystem != null)
                    s.WriteAttributeString("codeSystem", instance.CodeSystem);
                if (instance.CodeSystemVersion != null)
                    s.WriteAttributeString("codeSystemVersion", instance.CodeSystemVersion);
                if (instance.Type != null)
                {
                    // Qualifiers that count as TITLE
                    EntityNamePartQualifier[] titleQualifiers = new EntityNamePartQualifier[] {
                        EntityNamePartQualifier.Professional,
                        EntityNamePartQualifier.Nobility,
                        EntityNamePartQualifier.Academic ,
                        EntityNamePartQualifier.LegalStatus
                    };

                    // If type is not SFX or PFX then output the type,
                    // if it is either SFX or PFX then don't output the type
                    // but do modify the qualifier
                    switch(instance.Type.Value)
                    {
                        case EntityNamePartType.Prefix:
                            if (instance.Qualifier == null)
                                instance.Qualifier = new SET<CS<EntityNamePartQualifier>>();
                            if(!qualifiers.Contains(EntityNamePartQualifier.Prefix))
                                qualifiers.Add(EntityNamePartQualifier.Prefix);

                            // Change the instance type
                            if(Array.Exists(titleQualifiers, q => qualifiers.Contains(q)))
                                s.WriteAttributeString("type", "TITLE");

                            break;
                        case EntityNamePartType.Suffix:
                            if (instance.Qualifier == null)
                                instance.Qualifier = new SET<CS<EntityNamePartQualifier>>();
                            if (!qualifiers.Contains(EntityNamePartQualifier.Suffix))
                                qualifiers.Add(EntityNamePartQualifier.Suffix);
                            
                            // Change the instance type
                            if (Array.Exists(titleQualifiers, q => qualifiers.Contains(q)))
                                s.WriteAttributeString("type", "TITLE");

                            break;
                        default:
                            s.WriteAttributeString("type", Util.ToWireFormat(instance.Type));
                            break;
                    }
                }
                if (!qualifiers.IsEmpty)
                    s.WriteAttributeString("qualifier", Util.ToWireFormat(qualifiers));

            }
        }
Пример #26
0
 public IfcGroup(List <IfcObjectDefinition> ods) : base(ods[0].mDatabase)
 {
     mIsGroupedBy.Add(new IfcRelAssignsToGroup(ods, this));
 }
Пример #27
0
        public void Run()
        {
            Console.WriteLine("Choose file:");    // Prompt
            Console.WriteLine("1 - tinySET.txt"); // Prompt
            Console.WriteLine("or quit");         // Prompt

            var fileNumber = Console.ReadLine();
            var fieName    = string.Empty;

            switch (fileNumber)
            {
            case "1":
                fieName = "tinySET.txt";
                break;

            case "quit":
                return;

            default:
                return;
            }


            var @in  = new In($"Files\\Searching\\{fieName}");
            var keys = @in.ReadAllLines();

            //var list = words.Select(word => new StringComparable(word)).ToList();

            //var listComparable = list.Cast<IComparable>().ToList();
            //var arrayComparable = list.Cast<IComparable>().ToArray();
            //var listStrings = words.ToList();


            var set = new SET <string>();


            foreach (var key in keys)
            {
                set.Add(key);
            }
            // print results
            foreach (var item in set)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine(set.Contains("www.cs.princeton.edu"));
            Console.WriteLine(!set.Contains("www.harvardsucks.com"));
            Console.WriteLine(set.Contains("www.simpsons.com"));
            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine();


            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine("ceiling(www.simpsonr.com) = " + set.Ceiling("www.simpsonr.com"));
            Console.WriteLine("ceiling(www.simpsons.com) = " + set.Ceiling("www.simpsons.com"));
            Console.WriteLine("ceiling(www.simpsont.com) = " + set.Ceiling("www.simpsont.com"));
            Console.WriteLine("floor(www.simpsonr.com)   = " + set.Floor("www.simpsonr.com"));
            Console.WriteLine("floor(www.simpsons.com)   = " + set.Floor("www.simpsons.com"));
            Console.WriteLine("floor(www.simpsont.com)   = " + set.Floor("www.simpsont.com"));
            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine();

            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine(set.Max());
            Console.WriteLine(set.Min());
            Console.WriteLine();

            Console.ReadLine();
        }
Пример #28
0
        public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            EN instance = o as EN;

            // Do a base format
            base.Graph(s, o as ANY, result);

            // Null flavor
            if (instance.NullFlavor != null)
            {
                return;
            }

            // use
            if (instance.Use != null)
            {
                s.WriteAttributeString("use", Util.ToWireFormat(instance.Use));
            }

            // parts
            if (instance.Part != null)
            {
                foreach (ENXP part in instance.Part)
                {
                    EntityNamePartType?pt = part.Type;
                    SET <CS <EntityNamePartQualifier> > qualifiers = new SET <CS <EntityNamePartQualifier> >();
                    if (part.Qualifier != null)
                    {
                        foreach (var qlf in part.Qualifier)
                        {
                            qualifiers.Add(qlf.Clone() as CS <EntityNamePartQualifier>);
                        }
                    }

                    // Title part type?
                    if (pt == EntityNamePartType.Title)
                    {
                        part.Qualifier.Add(new CS <EntityNamePartQualifier>()
                        {
                            Code = CodeValue <EntityNamePartQualifier> .Parse("TITLE")
                        }
                                           );
                        pt = null;
                    }

                    // Possible to match qualifier to a part tpye if none specified!
                    if (!qualifiers.IsEmpty)
                    {
                        CS <EntityNamePartQualifier> pfx = qualifiers.Find(a => a.Code.Equals(EntityNamePartQualifier.Prefix)),
                                                     sfx = qualifiers.Find(a => a.Code.Equals(EntityNamePartQualifier.Suffix));
                        if (pfx != null)
                        {
                            pt = EntityNamePartType.Prefix;
                            qualifiers.Remove(pfx);
                        }
                        else if (sfx != null)
                        {
                            pt = EntityNamePartType.Suffix;
                            qualifiers.Remove(sfx);
                        }
                    }

                    // Part type is not set so do it inline
                    if (pt == null)
                    {
                        if (!qualifiers.IsEmpty)
                        {
                            result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Warning, "Part has qualifier but is not being rendered as a type element, qualifier will be dropped", s.ToString(), null));
                        }
                        s.WriteString(part.Value);
                    }
                    else if (mapping.ContainsKey(pt))
                    {
                        var prt = part.Clone() as ENXP;
                        prt.Type      = pt;
                        prt.Qualifier = qualifiers;
                        s.WriteStartElement(mapping[pt], "urn:hl7-org:v3");
                        ENXPFormatter enFormatter = new ENXPFormatter();
                        enFormatter.Graph(s, prt, result);
                        s.WriteEndElement();
                    }
                    else
                    {
                        throw new MessageValidationException(string.Format("Can't represent entity name part '{0}' in datatypes R1 at '{1}'", pt, (s as XmlStateWriter).CurrentPath));
                    }
                }
            }

            // Bug: 2102 - Graph the validTime element. Since the HXIT
            // class in R2 already has validTimeLow and validTimeHigh
            // what we'll do is map these attributes to the validTime element
            if (instance.ValidTimeLow != null || instance.ValidTimeHigh != null)
            {
                IVL <TS> validTime = new IVL <TS>(instance.ValidTimeLow, instance.ValidTimeHigh);
                s.WriteStartElement("validTime", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, validTime);
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement(); // valid time
            }
        }
Пример #29
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // XP is special, it does not extend anything so we have to graph from scratch
            var instance = o as ENXP;

            // Null flavor?
            if (instance.NullFlavor != null)
            {
                s.WriteAttributeString("nullFlavor", Util.ToWireFormat(instance.NullFlavor));
            }
            else
            {
                // Validate
                DatatypeR2FormatterParseResult tResult = new DatatypeR2FormatterParseResult(result.ValidateConformance);
                new ANYFormatter().Validate(instance, s.ToString(), tResult);
                result.AddResultDetail(tResult.Details);

                // Qualifiers (copy for modification)
                SET <CS <EntityNamePartQualifier> > qualifiers = new SET <CS <EntityNamePartQualifier> >();
                if (instance.Qualifier != null)
                {
                    foreach (var qlf in instance.Qualifier)
                    {
                        qualifiers.Add(qlf.Clone() as CS <EntityNamePartQualifier>);
                    }
                }

                // Unsupported properties
                if (instance.ControlActExt != null)
                {
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ControlActExt", "ENXP", s.ToString()));
                }
                if (instance.ControlActRoot != null)
                {
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ControlActRoot", "ENXP", s.ToString()));
                }
                if (instance.ValidTimeHigh != null)
                {
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ValidTimeHigh", "ENXP", s.ToString()));
                }
                if (instance.ValidTimeLow != null)
                {
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "ValidTimeLow", "ENXP", s.ToString()));
                }
                if (instance.Flavor != null)
                {
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Flavor", "ENXP", s.ToString()));
                }
                if (instance.UpdateMode != null)
                {
                    result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "UpdateMode", "ENXP", s.ToString()));
                }

                // Output the supported properties
                if (instance.Value != null)
                {
                    s.WriteAttributeString("value", instance.Value);
                }
                if (instance.Code != null)
                {
                    s.WriteAttributeString("code", instance.Code);
                }
                if (instance.CodeSystem != null)
                {
                    s.WriteAttributeString("codeSystem", instance.CodeSystem);
                }
                if (instance.CodeSystemVersion != null)
                {
                    s.WriteAttributeString("codeSystemVersion", instance.CodeSystemVersion);
                }
                if (instance.Type != null)
                {
                    // Qualifiers that count as TITLE
                    EntityNamePartQualifier[] titleQualifiers = new EntityNamePartQualifier[] {
                        EntityNamePartQualifier.Professional,
                        EntityNamePartQualifier.Nobility,
                        EntityNamePartQualifier.Academic,
                        EntityNamePartQualifier.LegalStatus
                    };

                    // If type is not SFX or PFX then output the type,
                    // if it is either SFX or PFX then don't output the type
                    // but do modify the qualifier
                    switch (instance.Type.Value)
                    {
                    case EntityNamePartType.Prefix:
                        if (instance.Qualifier == null)
                        {
                            instance.Qualifier = new SET <CS <EntityNamePartQualifier> >();
                        }
                        if (!qualifiers.Contains(EntityNamePartQualifier.Prefix))
                        {
                            qualifiers.Add(EntityNamePartQualifier.Prefix);
                        }

                        // Change the instance type
                        if (Array.Exists(titleQualifiers, q => qualifiers.Contains(q)))
                        {
                            s.WriteAttributeString("type", "TITLE");
                        }

                        break;

                    case EntityNamePartType.Suffix:
                        if (instance.Qualifier == null)
                        {
                            instance.Qualifier = new SET <CS <EntityNamePartQualifier> >();
                        }
                        if (!qualifiers.Contains(EntityNamePartQualifier.Suffix))
                        {
                            qualifiers.Add(EntityNamePartQualifier.Suffix);
                        }

                        // Change the instance type
                        if (Array.Exists(titleQualifiers, q => qualifiers.Contains(q)))
                        {
                            s.WriteAttributeString("type", "TITLE");
                        }

                        break;

                    default:
                        s.WriteAttributeString("type", Util.ToWireFormat(instance.Type));
                        break;
                    }
                }
                if (!qualifiers.IsEmpty)
                {
                    s.WriteAttributeString("qualifier", Util.ToWireFormat(qualifiers));
                }
            }
        }
Пример #30
0
 public IfcGeometricSet(IfcGeometricSetSelect element) : base(element.Database)
 {
     mElements.Add(element);
 }
Пример #31
0
        /// <summary>
        /// Parse the PQ back into a structure
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Create the base formatter
            PDVFormatter baseFormatter = new PDVFormatter();
            baseFormatter.Host = this.Host;

            // Read temporary values
            string tUnit = null;
            if(s.GetAttribute("unit") != null)
                tUnit = s.GetAttribute("unit");
            SET<CodingRationale> tRationale = null;
            if (s.GetAttribute("codingRationale") != null)
                tRationale = Util.Convert<SET<CodingRationale>>(s.GetAttribute("codingRationale"));

            // Parse PDV content (only attributes)
            var retVal = baseFormatter.ParseAttributes<PQ>(s, result);

            // Set PDV content
            retVal.Unit = tUnit;
            retVal.CodingRationale = tRationale;

            // Process elements 
            // This requires a QTY formatter as QTY elements may be 
            // in the stream as well
            #region Elements
            if (!s.IsEmptyElement)
            {
                // Prepare a formatter to process QTY elements
                QTYFormatter qtyFormatter = new QTYFormatter();
                qtyFormatter.Host = this.Host;

                // Exit markers
                int sDepth = s.Depth;
                string sName = s.Name;

                // Translations
                SET<PQR> translations = new SET<PQR>();

                // Read the next element
                s.Read();

                // Read until exit condition is fulfilled
                while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName))
                {
                    string oldName = s.Name; // Name
                    try
                    {
                        if (s.LocalName == "translation") // Format using ED
                        {
                            var hostResult = Host.Parse(s, typeof(PQR));
                            result.Code = hostResult.Code;
                            result.AddResultDetail(hostResult.Details);
                            translations.Add(hostResult.Structure as PQR);
                        }
                        else
                            qtyFormatter.ParseElementsInline(s, retVal, result);

                    }
                    catch (MessageValidationException e)
                    {
                        result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, s.ToString(), e));
                    }
                    finally
                    {
                        if (s.Name == oldName) s.Read();
                    }
                }

                // Set translations
                if (!translations.IsEmpty)
                    retVal.Translation = translations;
            }
            #endregion

            // Validate
            ANYFormatter anyFormatter = new ANYFormatter();
            string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name;
            anyFormatter.Validate(retVal as ANY, pathName, result);
            
            // REturn instance
            return retVal;
        }
Пример #32
0
        public void Run()
        {
            Console.WriteLine("Choose file:"); // Prompt
            Console.WriteLine("1 - tinySET.txt"); // Prompt
            Console.WriteLine("or quit"); // Prompt

            var fileNumber = Console.ReadLine();
            var fieName = string.Empty;
            switch (fileNumber)
            {
                case "1":
                    fieName = "tinySET.txt";
                    break;
                case "quit":
                    return;
                default:
                    return;
            }

            var @in = new In($"Files\\Searching\\{fieName}");
            var keys = @in.ReadAllLines();

            //var list = words.Select(word => new StringComparable(word)).ToList();

            //var listComparable = list.Cast<IComparable>().ToList();
            //var arrayComparable = list.Cast<IComparable>().ToArray();
            //var listStrings = words.ToList();

            var set = new SET<string>();

            foreach (var key in keys)
            {

                set.Add(key);
            }
            // print results
            foreach (var item in set)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine(set.Contains("www.cs.princeton.edu"));
            Console.WriteLine(!set.Contains("www.harvardsucks.com"));
            Console.WriteLine(set.Contains("www.simpsons.com"));
            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine();

            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine("ceiling(www.simpsonr.com) = " + set.Ceiling("www.simpsonr.com"));
            Console.WriteLine("ceiling(www.simpsons.com) = " + set.Ceiling("www.simpsons.com"));
            Console.WriteLine("ceiling(www.simpsont.com) = " + set.Ceiling("www.simpsont.com"));
            Console.WriteLine("floor(www.simpsonr.com)   = " + set.Floor("www.simpsonr.com"));
            Console.WriteLine("floor(www.simpsons.com)   = " + set.Floor("www.simpsons.com"));
            Console.WriteLine("floor(www.simpsont.com)   = " + set.Floor("www.simpsont.com"));
            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine();

            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine(set.Max());
            Console.WriteLine(set.Min());
            Console.WriteLine();

            Console.ReadLine();
        }
Пример #33
0
 /// <summary>
 /// Returns a random simple graph containing <tt>V</tt> vertices and <tt>E</tt> edges.
 /// </summary>
 /// <param name="v">V the number of vertices</param>
 /// <param name="e">E the number of edges</param>
 /// <returns> random simple graph on <tt>V</tt> vertices, containing a total of <tt>E</tt> edges</returns>
 /// <exception cref="ArgumentException">if no such simple graph exists</exception>
 public static Graph Simple(int v, int e)
 {
     if (e > (long)v * (v - 1) / 2) throw new ArgumentException("Too many edges");
     if (e < 0) throw new ArgumentException("Too few edges");
     var g = new Graph(v);
     var set = new SET<EdgeU>();
     while (g.E < e)
     {
         var ve = StdRandom.Uniform(v);
         var we = StdRandom.Uniform(v);
         var edge = new EdgeU(ve, we);
         if ((ve == we) || set.Contains(edge)) continue;
         set.Add(edge);
         g.AddEdge(ve, we);
     }
     return g;
 }