//Converts a JSON sparql solution binding row into a graph result private LabelledTreeNode <object, Term> CreateResultGraph(Dictionary <string, Binding> solution, LabelledTreeNode <object, Term> queryModel) { TreeNodeVisitor <object, object> visitor = (object nodeData) => ResolveNode(nodeData, solution); var result = queryModel.Copy().Traverse(visitor); return(result); }
/// <summary> /// Join two trees /// </summary> /// <param name="treeBase">base tree</param> /// <param name="treeJoin">tree to join</param> /// <param name="addressPairList">sites of join</param> /// <returns>a combined tree</returns> public static LabelledTreeNode <object, Term> Join(LabelledTreeNode <object, Term> treeBase, LabelledTreeNode <object, Term> treeJoin, List <JoinAddressPair> addressPairList) { var localTreeBase = treeBase.Copy(); var localTreeJoin = treeJoin.Copy(); foreach (var x in addressPairList) { foreach (var child in localTreeJoin.Find(x.TreeAddress2).Children) { localTreeBase.Find(x.TreeAddress1).Children.Add(new DirectedEdge <Term, object>(child.Edge, child.TerminalNode)); } } return(localTreeBase); }