public bool AreTwoVerticessOnSameCRAInstance()

in src/CRA.ClientLibrary/Main/ShardedCRAClientLibrary.cs [239:284]


        public bool AreTwoVerticessOnSameCRAInstance(string fromVertexName, ConcurrentDictionary<string, int> fromVertexShards, string toVertexName, ConcurrentDictionary<string, int> toVertexShards)
        {
            string fromVertexInstance = null;
            string fromVertexId = fromVertexName.Substring(fromVertexName.Length - 2);
            int fromVerticesCount = CountVertexShards(fromVertexShards);
            int currentCount = 0;
            foreach (var key in fromVertexShards.Keys)
            {
                for (int i = currentCount; i < currentCount + fromVertexShards[key]; i++)
                {
                    if (fromVertexId.Equals("$" + i))
                    {
                        fromVertexInstance = key;
                        break;
                    }
                }

                if (fromVertexInstance != null)
                    break;

                currentCount += fromVertexShards[key];
            }

            string toVertexInstance = null;
            string toVertexId = toVertexName.Substring(toVertexName.Length - 2);
            int toVerticesCount = CountVertexShards(toVertexShards);
            currentCount = 0;
            foreach (var key in toVertexShards.Keys)
            {
                for (int i = currentCount; i < currentCount + toVertexShards[key]; i++)
                {
                    if (toVertexId.Equals("$" + i))
                    {
                        toVertexInstance = key;
                        break;
                    }
                }

                if (toVertexInstance != null)
                    break;

                currentCount += toVertexShards[key];
            }

            return (fromVertexInstance != null) && (toVertexInstance != null) && (fromVertexInstance.Equals(toVertexInstance));
        }