Esempio n. 1
0
        public override bool AddEdge(TEdge e)
        {
            if (base.AddEdge(e))
            {
                //add edge to the source collections
                TypedEdgeCollectionWrapper sourceEdgeCollection = _typedEdgeCollections[e.Source];
                switch (e.Type)
                {
                case EdgeTypes.General:
                    sourceEdgeCollection.OutGeneralEdges.Add(e);
                    break;

                case EdgeTypes.Hierarchical:
                    sourceEdgeCollection.OutHierarchicalEdges.Add(e);
                    break;
                }

                //add edge to the target collections
                TypedEdgeCollectionWrapper targetEdgeCollection = _typedEdgeCollections[e.Target];
                switch (e.Type)
                {
                case EdgeTypes.General:
                    targetEdgeCollection.InGeneralEdges.Add(e);
                    break;

                case EdgeTypes.Hierarchical:
                    targetEdgeCollection.InHierarchicalEdges.Add(e);
                    break;
                }

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public override bool RemoveVertex(TVertex v)
        {
            bool ret = base.RemoveVertex(v);

            if (ret)
            {
                //remove the edges from the typedEdgeCollections
                TypedEdgeCollectionWrapper edgeCollection = typedEdgeCollections[v];
                foreach (TEdge e in edgeCollection.InGeneralEdges)
                {
                    typedEdgeCollections[e.Source].OutGeneralEdges.Remove(e);
                }
                foreach (TEdge e in edgeCollection.OutGeneralEdges)
                {
                    typedEdgeCollections[e.Target].InGeneralEdges.Remove(e);
                }

                foreach (TEdge e in edgeCollection.InHierarchicalEdges)
                {
                    typedEdgeCollections[e.Source].OutHierarchicalEdges.Remove(e);
                }
                foreach (TEdge e in edgeCollection.OutHierarchicalEdges)
                {
                    typedEdgeCollections[e.Target].InHierarchicalEdges.Remove(e);
                }

                typedEdgeCollections.Remove(v);
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        /// <inheritdoc />
        public int OutGeneralEdgeCount(TVertex vertex)
        {
            TypedEdgeCollectionWrapper collections = GetCollectionsAndAssertFor(vertex);

            return(collections.OutGeneralEdges.Count
                   + collections.SelfGeneralEdges.Count);
        }
Esempio n. 4
0
        /// <inheritdoc />
        public override bool RemoveVertex(TVertex vertex)
        {
            bool removed = base.RemoveVertex(vertex);

            if (removed)
            {
                // Remove the edges from the _typedEdgeCollections
                TypedEdgeCollectionWrapper edgeCollection = _typedEdgeCollections[vertex];
                foreach (TEdge edge in edgeCollection.InGeneralEdges)
                {
                    _typedEdgeCollections[edge.Source].OutGeneralEdges.Remove(edge);
                }
                foreach (TEdge edge in edgeCollection.OutGeneralEdges)
                {
                    _typedEdgeCollections[edge.Target].InGeneralEdges.Remove(edge);
                }

                foreach (TEdge edge in edgeCollection.InHierarchicalEdges)
                {
                    _typedEdgeCollections[edge.Source].OutHierarchicalEdges.Remove(edge);
                }
                foreach (TEdge edge in edgeCollection.OutHierarchicalEdges)
                {
                    _typedEdgeCollections[edge.Target].InHierarchicalEdges.Remove(edge);
                }

                _typedEdgeCollections.Remove(vertex);
                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        /// <inheritdoc />
        public int InHierarchicalEdgeCount(TVertex vertex)
        {
            TypedEdgeCollectionWrapper collections = GetCollectionsAndAssertFor(vertex);

            return(collections.InHierarchicalEdges.Count
                   + collections.SelfHierarchicalEdges.Count);
        }
Esempio n. 6
0
        /// <inheritdoc />
        public IEnumerable <TEdge> GeneralEdgesFor(TVertex vertex)
        {
            TypedEdgeCollectionWrapper collections = GetCollectionsAndAssertFor(vertex);

            return(collections.InGeneralEdges
                   .Concat(collections.OutGeneralEdges)
                   .Concat(collections.SelfGeneralEdges));
        }
Esempio n. 7
0
 public override bool AddVertex(TVertex v)
 {
     base.AddVertex(v);
     if (!typedEdgeCollections.ContainsKey(v))
     {
         typedEdgeCollections[v] = new TypedEdgeCollectionWrapper();
     }
     return(true);
 }
Esempio n. 8
0
        /// <inheritdoc />
        public override bool AddVertex(TVertex vertex)
        {
            bool added = base.AddVertex(vertex);

            if (!_typedEdgeCollections.ContainsKey(vertex))
            {
                _typedEdgeCollections[vertex] = new TypedEdgeCollectionWrapper();
            }
            return(added);
        }
Esempio n. 9
0
        /// <inheritdoc />
        public override bool RemoveEdge(TEdge edge)
        {
            if (!base.RemoveEdge(edge))
            {
                return(false);
            }

            if (edge.IsSelfEdge())
            {
                // Remove edge from the collections (same for source and target)
                TypedEdgeCollectionWrapper edgeCollection = _typedEdgeCollections[edge.Source];
                switch (edge.Type)
                {
                case EdgeTypes.General:
                    edgeCollection.SelfGeneralEdges.Remove(edge);
                    break;

                case EdgeTypes.Hierarchical:
                    edgeCollection.SelfHierarchicalEdges.Remove(edge);
                    break;
                }
            }
            else
            {
                // Remove edge from the source collections
                TypedEdgeCollectionWrapper sourceEdgeCollection = _typedEdgeCollections[edge.Source];
                switch (edge.Type)
                {
                case EdgeTypes.General:
                    sourceEdgeCollection.OutGeneralEdges.Remove(edge);
                    break;

                case EdgeTypes.Hierarchical:
                    sourceEdgeCollection.OutHierarchicalEdges.Remove(edge);
                    break;
                }

                // Remove edge from the target collections
                TypedEdgeCollectionWrapper targetEdgeCollection = _typedEdgeCollections[edge.Target];
                switch (edge.Type)
                {
                case EdgeTypes.General:
                    targetEdgeCollection.InGeneralEdges.Remove(edge);
                    break;

                case EdgeTypes.Hierarchical:
                    targetEdgeCollection.InHierarchicalEdges.Remove(edge);
                    break;
                }
            }

            return(true);
        }
Esempio n. 10
0
        public IEnumerable <TEdge> GeneralEdgesFor(TVertex v)
        {
            TypedEdgeCollectionWrapper collections = typedEdgeCollections[v];

            foreach (TEdge e in collections.InGeneralEdges)
            {
                yield return(e);
            }
            foreach (TEdge e in collections.OutGeneralEdges)
            {
                yield return(e);
            }
        }
Esempio n. 11
0
        public override bool RemoveEdge(TEdge e)
        {
            if (base.RemoveEdge(e))
            {
                //remove edge from the source collections
                TypedEdgeCollectionWrapper sourceEdgeCollection = typedEdgeCollections[e.Source];
                switch (e.Type)
                {
                case EdgeTypes.General:
                    sourceEdgeCollection.OutGeneralEdges.Remove(e);
                    break;

                case EdgeTypes.Hierarchical:
                    sourceEdgeCollection.OutHierarchicalEdges.Remove(e);
                    break;

                default:
                    break;
                }

                //remove edge from the target collections
                TypedEdgeCollectionWrapper targetEdgeCollection = typedEdgeCollections[e.Target];
                switch (e.Type)
                {
                case EdgeTypes.General:
                    targetEdgeCollection.InGeneralEdges.Remove(e);
                    break;

                case EdgeTypes.Hierarchical:
                    targetEdgeCollection.InHierarchicalEdges.Remove(e);
                    break;

                default:
                    break;
                }
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
        public IEnumerable <TEdge> HierarchicalEdgesFor(TVertex v)
        {
            TypedEdgeCollectionWrapper collections = typedEdgeCollections[v];

            return(collections.InHierarchicalEdges.Concat(collections.OutHierarchicalEdges));
        }
Esempio n. 13
0
        /// <inheritdoc />
        public IEnumerable <TEdge> OutHierarchicalEdges(TVertex vertex)
        {
            TypedEdgeCollectionWrapper collections = GetCollectionsAndAssertFor(vertex);

            return(collections.OutHierarchicalEdges.Concat(collections.SelfHierarchicalEdges));
        }