public BidirectionalGraph <Resource.Resource, AssociationViewEdge> CreateResourceLoadGraph() { var resourceModel = _resourceModelProvider.GetResourceModel(); var resourceGraph = new BidirectionalGraph <Resource.Resource, AssociationViewEdge>(); var resources = resourceModel.GetAllResources() .Where(r => !r.IsAbstract() && !r.FullName.IsEdFiSchoolYearType()) .ToArray(); resourceGraph.AddVertexRange(resources); var edges = resources // Abstract resources are already covered by their concrete resources in the model .Where(res => !res.IsAbstract()) // Add edges for all references (incoming associations) and descriptor usages .SelectMany( res => // Add all incoming reference in the entire resource res.AllContainedReferences.SelectMany(AssociationViewEdge.CreateEdges) // Add direct descriptor associations .Concat( res.AllContainedItemTypesOrSelf.SelectMany( rc => rc.Properties.Where(p => p.IsDirectLookup) .Select( p => new AssociationViewEdge( p.DescriptorResource, p.Parent.ResourceRoot, p.EntityProperty.IncomingAssociations.Single()))))) // Eliminate redundant edges .Distinct(AssociationViewEdge.Comparer); resourceGraph.AddEdgeRange(edges.Where(e => !e.Source.FullName.IsEdFiSchoolYearType())); // Apply predefined graph transformations if (_graphTransformers.Any()) { foreach (var graphTransformer in _graphTransformers) { graphTransformer.Transform(resourceGraph); } } resourceGraph.BreakCycles(edge => edge.AssociationView.IsSoftDependency); return(resourceGraph); }