public GraphContainer <TNodeId, TNodeData, TEdgeId, TEdgeData> GetNodeExpansions( TNodeId nodeId, bool isSource = true, bool isTarget = true, string[] nodeFilter = null, string[] edgeFilter = null, Pagination nodePagination = null, Pagination edgePagination = null ) { HashSet <Edge <TEdgeData, TEdgeId, TNodeId> > edges; if (!isSource && !isTarget) { throw new BadExpansionRequest("Either parameters \"isSource\" or \"isTarget\" must be true"); } else if (isSource && isTarget) { edges = _edgeService.GetEdgesBySideId(nodeId, edgeFilter).ToHashSet(); } else if (isSource) { edges = _edgeService.GetEdgesBySourceId(nodeId, edgeFilter).ToHashSet(); } else { edges = _edgeService.GetEdgesByTargetId(nodeId, edgeFilter).ToHashSet(); } var filteredNodes = _nodeService.GetNodesByFilter(nodeFilter, nodePagination); var filteredNodesIds = filteredNodes.Select(fn => fn.Id); var sourceTargetNodeIds = edges.SelectMany(edge => new TNodeId[] { edge.Source, edge.Target }).ToHashSet(); var sourceTargetNodes = _nodeService.GetNodesById(sourceTargetNodeIds.ToArray()); var allNodeIds = filteredNodesIds.Intersect(sourceTargetNodeIds).ToHashSet(); var allNodes = filteredNodes.Intersect(sourceTargetNodes).ToHashSet(); edges = edges.Where( e => allNodeIds.Contains(e.Source) && allNodeIds.Contains(e.Target)) .ToHashSet(); return(new GraphContainer <TNodeId, TNodeData, TEdgeId, TEdgeData>( allNodes.ToList(), edges.ToList() )); }
public IActionResult GetEdgeBySideId(string sideNodeId) { return(Ok(_edgeService.GetEdgesBySideId(sideNodeId))); }