internal static void SetBaseEdgeDomainRanges(this QueryGraph graph, InMemoryQueryEngine InMemoryQueryEngine)
        {
            foreach (var edge in graph.Edges.Select(x => x.Value))
            {
                var sourceNode = edge.GetSourceNode(graph);
                var targetNode = edge.GetTargetNode(graph);

                //If the source is constant/instanceOf, limit the domain and range to the types of that entity.
                if (sourceNode.IsConstant || sourceNode.IsInstanceOf)
                {
                    edge.DomainTypes = sourceNode.ParentTypes;
                }
                else if (edge.IsConstant)
                {
                    edge.DomainTypes = InMemoryQueryEngine.BatchPropertyIdDomainTypesQuery(edge.uris).ToList();
                }

                //If the target is given with a instanceOfEdge, limit the domain and range to the types of that entity.
                if (targetNode.IsConstant && edge.IsInstanceOf)
                {
                    edge.RangeTypes = targetNode.Types;
                }
                else if (targetNode.IsConstant || targetNode.IsInstanceOf)
                {
                    edge.RangeTypes = targetNode.ParentTypes;
                }
                else if (edge.IsConstant)
                {
                    edge.RangeTypes = InMemoryQueryEngine.BatchPropertyIdRangeTypesQuery(edge.uris).ToList();
                }
            }
        }
        //private static readonly InMemoryQueryEngine InMemoryQueryEngine = new InMemoryQueryEngine();

        public static void SetTypesDomainsAndRanges(this QueryGraph graph, InMemoryQueryEngine InMemoryQueryEngine)
        {
            InMemoryQueryEngine.Init(graph.EntitiesIndexPath, graph.PropertiesIndexPath);
            graph.SetBaseNodeTypes();
            graph.SetBaseEdgeDomainRanges(InMemoryQueryEngine);

            graph.SetInferredNodeTypes();
            graph.SetInferredEdgeTypes();
            graph.SetInferredNodeTypes();
            graph.SetInferredEdgeTypes();
        }