Beispiel #1
0
        public IRelationshipSet <T> GetEndingWith(ITrueEntity end)
        {
            IRelationshipSet <T> temp = new RelationshipSet <T>();

            foreach (T t in this.GetItems())
            {
                if (t.Entities != null && t.Entities.Count != 0 && t.Entities[1].Equals(end))
                {
                    temp.Add(t);
                }
            }
            return(temp);
        }
Beispiel #2
0
        /// <summary>
        /// Removes relationship between classes releted by two or more another relationships.
        /// </summary>
        /// <param name="graph"></param>
        public void OptimizeSubclassRelationship()
        {
            List <SubclassRelationship>      list          = new List <SubclassRelationship>(Graph.SubclassRelationships.GetItems());
            IRelationshipSet <IRelationship> relationships = Graph.SubclassRelationships.ConvertAll <IRelationship>(delegate(SubclassRelationship sr) { return(sr as IRelationship); });

            for (int i = 0; i < list.Count; i++)
            {
                if (RelationshipLength(relationships, list[i].Entities[0], list[i].Entities[1]) > 1)
                {
                    list.RemoveAt(i--);
                }
            }

            IRelationshipSet <SubclassRelationship> set = new RelationshipSet <SubclassRelationship>();

            set.Add(list);
            Graph.SubclassRelationships = set;
        }
Beispiel #3
0
        public void OptimizePropertyRelationships()
        {
            //all optimized PropertyRelationships
            IRelationshipSet <PropertyRelationship> optimizedPRs = Graph.PropertyRelationships;

            //all SubclassRelationships
            IRelationshipSet <IRelationship> allSubclassR = Graph.SubclassRelationships.ConvertAll <IRelationship>(delegate(SubclassRelationship sr) { return(sr as IRelationship); });

            //all participated IPropertyEntity
            ISet <ITrueEntity> properties = Graph.PropertyRelationships.GetBeginEntities();

            IRelationshipSet <PropertyRelationship> set = new RelationshipSet <PropertyRelationship>();

            //foreach participated property
            foreach (ITrueEntity property in properties.GetItems())
            {
                //find PropertyRelationships related with this property from optimized
                IRelationshipSet <PropertyRelationship> someOptimizedPR = optimizedPRs.GetBeginningWith(property);

                //find all related classes by optimized PropertyRelationships
                //ISet<ITrueEntity> classes = someOptimizedPR.GetEndEntities();
                List <PropertyRelationship> list = new List <PropertyRelationship>(someOptimizedPR.GetItems());
                for (int i = 0; i < list.Count; i++)
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (RelationshipLength(allSubclassR, list[j].Entities[1], list[i].Entities[1]) > 0)
                        {
                            list.RemoveAt(j--);
                            if (i > j)
                            {
                                i--;
                            }
                        }
                    }
                }
                set.Add(list);
            }

            Graph.PropertyRelationships = set;
        }