Esempio n. 1
0
        /// <summary>
        /// Gets the linked nodes.
        /// </summary>
        /// <param name="centralNodeName">Name of the central node.</param>
        /// <param name="includeBtoALinks">if set to <c>true</c> [include bto a links].</param>
        /// <returns></returns>
        public freeGraphQueryResult GetLinkedNodes(String centralNodeName, Boolean includeBtoALinks = false, freeGraphQueryResult output = null)
        {
            if (output == null)
            {
                output = new freeGraphQueryResult();
            }
            if (!Check())
            {
                output.graphNotReady = true;
                return(output);
            }
            freeGraphNodeBase centralNode = GetNode(centralNodeName, true);

            output.queryNodes.Add(centralNode);
            if (!output.graphNodeNotFound)
            {
                output.AddRange(GetLinksBase(centralNodeName, false, 1, true));
                output.includeBtoALinks = includeBtoALinks;
                if (output.includeBtoALinks)
                {
                    output.AddRange(GetLinksBase(centralNodeName, true, 1, true));
                }
            }
            return(output);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds all nodes from the query into collection that are not already in the island (identified by: <see cref="freeGraphNodeBase.name"/> )
        /// </summary>
        /// <param name="queryResult">The query result.</param>
        public void Add(freeGraphQueryResult queryResult)
        {
            List <freeGraphNodeBase> allNodes = queryResult.ToList();

            allNodes.AddRange(queryResult.queryNodes);

            foreach (freeGraphNodeBase n in allNodes)
            {
                if (!nodes.Contains(n.name))
                {
                    nodes.Add(n.name);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Iterative query for linked nodes.
        /// </summary>
        /// <param name="queryNodeNames">The query node names.</param>
        /// <param name="expansionSteps">The expansion steps - number of iterations in linked nodes collecting process</param>
        /// <param name="includeBtoAlinks">if set to <c>true</c> [include bto alinks].</param>
        /// <param name="includeQueryNodesInResult">if set to <c>true</c> [include query nodes in result].</param>
        /// <returns></returns>
        public freeGraphQueryResult GetLinkedNodes(IEnumerable <String> queryNodeNames, Int32 expansionSteps = 1,
                                                   Boolean includeBtoAlinks     = false, Boolean includeQueryNodesInResult = false,
                                                   Boolean cloneAndAdjustWeight = true, Boolean includeAtoBlinks           = true)
        {
            var output = new freeGraphQueryResult();

            if (!includeAtoBlinks && !includeBtoAlinks)
            {
                //throw new ArgumentException("Both " + nameof(includeAtoBlinks) + " and " + nameof(includeBtoAlinks) + " are set to false. ")
                return(output);
            }

            if (!Check())
            {
                output.graphNotReady = true;
                return(output);
            }
            List <freeGraphNodeBase> queryNodes = GetNodes(queryNodeNames, true).GetQueryResultClones(0);

            output.queryNodes.AddRange(queryNodes);

            if (includeQueryNodesInResult)
            {
                output.AddNewNodes(queryNodes);
            }

            Int32 step = 0;

            while (step < expansionSteps)
            {
                List <freeGraphNodeBase> expansion = new List <freeGraphNodeBase>();

                foreach (var node in queryNodes)
                {
                    if (includeAtoBlinks)
                    {
                        expansion.AddRange(GetLinksBase(node.name, false, 1, cloneAndAdjustWeight));
                    }
                    if (includeBtoAlinks)
                    {
                        expansion.AddRange(GetLinksBase(node.name, true, 1, cloneAndAdjustWeight));
                    }
                }

                queryNodes = output.AddNewNodes(expansion);
                step++;
            }
            return(output);
        }