private GraphContainer <TNodeId, TNodeData, TEdgeId, TEdgeData> GetGraphByFilter( string[] nodeFilter = null, string[] edgeFilter = null, Pagination nodePagination = null, Pagination edgePagination = null ) { // var nodes = _nodeService.GetNodesByFilter(nodeFilter, nodePagination).ToList(); var edges = _edgeService.GetEdgesByFilter(edgeFilter, edgePagination).ToHashSet(); var filteredNodes = _nodeService.GetNodesByFilter(nodeFilter, nodePagination).ToHashSet(); var filteredNodesIds = filteredNodes.Select(fn => fn.Id).ToHashSet(); 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 GetEdgesByFilter([FromQuery] Pagination pagination, [FromQuery] string[] filter) { if (pagination != null && pagination.PageIndex == 0 && pagination.PageSize == 0) { return(Ok(_edgeService.GetEdgesByFilter(filter, null))); } return(Ok(_edgeService.GetEdgesByFilter(filter, pagination))); }