public void TestEdgeIsInferibleTrue()
        {
            var edge      = new Edge(0, "?prop0", 0, 1, new[] { "http://www.wikidata.org/prop/direct/P25" });
            var queryEdge = new QueryEdge(edge);

            Assert.True(queryEdge.IsInferible());
        }
        public void TestEdgeIsInferibleFalse()
        {
            var edge      = new Edge(0, "?prop0", 0, 1);
            var queryEdge = new QueryEdge(edge);

            Assert.False(queryEdge.IsInferible());
        }
        public void TestEdgeIsInferibleFalseInstanceOf()
        {
            var edge      = new Edge(0, "?prop0", 0, 1, new[] { "http://www.wikidata.org/prop/direct/P31" });
            var queryEdge = new QueryEdge(edge);

            Assert.False(queryEdge.IsInferible());
        }
        public void TestEdgeHasInstanceOfTrue()
        {
            var edge      = new Edge(0, "?prop0", 0, 1, new[] { "http://www.wikidata.org/prop/direct/P31" });
            var queryEdge = new QueryEdge(edge);

            Assert.True(queryEdge.HasInstanceOf());
        }
        public void TestEdgeHasInstanceOfFalse()
        {
            var edge      = new Edge(0, "?prop0", 0, 1);
            var queryEdge = new QueryEdge(edge);

            Assert.False(queryEdge.HasInstanceOf());
        }
        private static QueryEdge CreateEdge(GraphImplementations.Schema.Edge schemaEdge, IEnumerable <QueryVertex> queryVertices)
        {
            var queryEdge = new QueryEdge(
                queryVertices.First(v => v.Value.TypeId == schemaEdge.From.Value.TypeId),
                queryVertices.First(v => v.Value.TypeId == schemaEdge.To.Value.TypeId),
                schemaEdge.Value);

            return(queryEdge);
        }
        public static SparqlQuery ToSparql(this QueryEdge edge, QueryGraph graph)
        {
            var queryBuilder = QueryBuilder.SelectAll().Distinct();

            var source = edge.GetSourceNode(graph);
            var target = edge.GetTargetNode(graph);

            source.TraverseNodeToSparql(queryBuilder, graph);
            target.TraverseNodeToSparql(queryBuilder, graph);

            queryBuilder.Limit(100);

            return(queryBuilder.BuildQuery());
        }
 private static TriplePatternObjectPart ToPredicate(this TriplePatternPredicatePart subject, QueryEdge edge)
 {
     return(edge.IsConstant
         ? subject.PredicateUri(new Uri(edge.uris.First().ToPropertyIri()))
         : subject.Predicate(edge.name));
 }
 public static bool IsInferible(this QueryEdge edge)
 {
     return(edge.uris.Any() && !edge.HasInstanceOf());
 }
 /// <summary>
 /// Given an Edge, checks if the Edge.uris has any value ending with "P31" (InstanceOf)
 /// </summary>
 public static bool HasInstanceOf(this QueryEdge edge)
 {
     return(edge.uris.HasInstanceOf());
 }
 /// <summary>
 /// Given an Edge, get the Graph's Node, where Node.Id equals Edge.TargetId
 /// </summary>
 public static QueryNode GetTargetNode(this QueryEdge edge, QueryGraph graph)
 {
     return(graph.Nodes.FirstOrDefault(x => x.Key.Equals(edge.targetId)).Value);
 }