public void AddDirectEdge(BirdsNestRelationship edge) { BirdsNestNode workingnode; VForLabelledNodeList nodelist; //figure out inbound or outbound edge if (edge.Source == this.Node.DbId) { if (this._relatedNodes.TryGetValue(edge.Target, out workingnode) == false) { throw new System.Exception("Unable to resolve target node with DbId: " + edge.Target); } nodelist = this.OutNodesByLabel; this.OutNodesByEdgeLabel.AddNode(workingnode, edge.Label); } else { if (this._relatedNodes.TryGetValue(edge.Source, out workingnode) == false) { throw new System.Exception("Unable to resolve source node with DbId: " + edge.Source); } nodelist = this.InNodesByLabel; this.InNodesByEdgeLabel.AddNode(workingnode, edge.Label); } foreach (string label in workingnode.Labels) { nodelist.AddNode(workingnode, label); } }
public static BirdsNestRelationship GetRelationship(IRelationship relrecord) { BirdsNestRelationship newrel = new BirdsNestRelationship(); newrel.DbId = relrecord.Id; newrel.Properties = relrecord.Properties; newrel.Label = relrecord.Type; newrel.Source = relrecord.StartNodeId; newrel.Target = relrecord.EndNodeId; return(newrel); }
private void AddToResultSet(object o, ResultSet results) { INode node = o as INode; if (node != null) { results.Nodes.Add(BirdsNestNode.GetNode(node)); return; } List <object> nodelist = o as List <object>; if (nodelist != null) { foreach (object obj in nodelist) { AddToResultSet(obj, results); } return; } IRelationship rel = o as IRelationship; if (rel != null) { results.Edges.Add(BirdsNestRelationship.GetRelationship(rel)); return; } IPath path = o as IPath; if (path != null) { foreach (INode n in path.Nodes) { results.Nodes.Add(BirdsNestNode.GetNode(n)); } foreach (IRelationship r in path.Relationships) { results.Edges.Add(BirdsNestRelationship.GetRelationship(r)); } return; } }