Esempio n. 1
0
        /// <summary>
        /// Find edge with given node
        /// </summary>
        /// <param name="node">The node to filter edges by</param>
        /// <returns>Node with given id or null</returns>
        public EdgesCollection FilterByNode(INode node)
        {
            var nodeId      = node.Id;
            var firstEdges  = _firstIdToEdges[nodeId];
            var secondEdges = _secondIdToEdges[nodeId];
            var result      = new EdgesCollection(firstEdges, secondEdges);

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Find edge by given pair of nodes
        /// </summary>
        /// <param name="first">edge first node</param>
        /// <param name="second">edge second node</param>
        /// <returns>edge on given pair of nodes or null</returns>
        public IEdge FindEdge(INode first, INode second)
        {
            EdgesCollection edges = this.FilterByNode(first).FilterByNode(second);

            if (edges.Count > 0)
            {
                return(edges[0]);
            }

            return(null);
        }
Esempio n. 3
0
        /// <summary>
        /// Find edge with given node
        /// </summary>
        /// <param name="node">The node to filter edges by</param>
        /// <returns>Node with given id or null</returns>
        public EdgesCollection FilterByNode(INode node)
        {
            EdgesCollection result = new EdgesCollection();

            foreach (IEdge edge in this)
            {
                if (edge.First.Id == node.Id || edge.Second.Id == node.Id)
                {
                    result.Add(edge);
                }
            }

            return(result);
        }