Esempio n. 1
0
        public bool RemoveNode(IRelationNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            return(RemoveNode(node.Discriminant));
        }
Esempio n. 2
0
        public IRelationVertex GetVertex(IRelationNode leftNode, IRelationNode rightNode)
        {
            if (leftNode == null)
            {
                throw new ArgumentNullException(nameof(leftNode));
            }

            if (rightNode == null)
            {
                throw new ArgumentNullException(nameof(rightNode));
            }

            return(leftNode.GetVertex(rightNode) ?? rightNode.GetVertex(leftNode));
        }
Esempio n. 3
0
        public bool RemoveVertex(IRelationNode leftNode, IRelationNode rightNode)
        {
            if (leftNode == null)
            {
                throw new ArgumentNullException(nameof(leftNode));
            }

            if (rightNode == null)
            {
                throw new ArgumentNullException(nameof(rightNode));
            }

            return(leftNode.Vertices.Remove(rightNode.Discriminant) & rightNode.Vertices.Remove(leftNode.Discriminant));
        }
Esempio n. 4
0
        public void AddVertex(IRelationNode leftNode, IRelationNode rightNode, ICardinality leftCardinality = null, ICardinality rightCardinality = null)
        {
            if (leftNode == null)
            {
                throw new ArgumentNullException(nameof(leftNode));
            }

            if (rightNode == null)
            {
                throw new ArgumentNullException(nameof(rightNode));
            }

            if (leftNode.Vertices.ContainsKey(rightNode.Discriminant) || rightNode.Vertices.ContainsKey(leftNode.Discriminant))
            {
                throw new ArgumentException(nameof(leftNode.Discriminant));
            }

            var vertex = new RelationVertex(leftNode, rightNode, leftCardinality, rightCardinality);

            leftNode.Vertices.Add(rightNode.Discriminant, vertex);
            rightNode.Vertices.Add(leftNode.Discriminant, vertex);
        }
Esempio n. 5
0
        public RelationVertex(IRelationNode leftNode, IRelationNode rightNode, ICardinality leftCardinality = null, ICardinality rightCardinality = null)
        {
            if (leftNode == null)
            {
                throw new ArgumentNullException(nameof(leftNode));
            }

            if (rightNode == null)
            {
                throw new ArgumentNullException(nameof(rightNode));
            }

            if (leftNode == RightNode || leftNode.Discriminant == rightNode.Discriminant)
            {
                throw new ArgumentException("discriminants should be different");
            }

            LeftNode         = leftNode;
            RightNode        = rightNode;
            LeftCardinality  = leftCardinality ?? new Cardinality();
            RightCardinality = leftCardinality ?? new Cardinality();
        }
Esempio n. 6
0
 public IRelationVertex GetVertex(IRelationNode oppositeNode)
 {
     return(GetVertex(oppositeNode.Discriminant));
 }