private static void SinglePath <TShape, TMat>(Fusing.FusedGraph <TShape, TMat> fusedGraph, Attributes.IAttribute from, Attributes.IAttribute to) where TShape : Shape { var module = fusedGraph.Module as FusedModule; var starts = module.Info.AllModules.Where(m => m.Attributes.Contains(from)).ToList(); starts.Count.Should().Be(1); var start = starts[0]; var ups = module.Info.Upstreams; var owner = module.Info.OutOwners; var currentModule = start; while (true) { var copied = currentModule as CopiedModule; if (copied != null && copied.Attributes.And(copied.CopyOf.Attributes).Contains(to)) { break; } if (currentModule.Attributes.Contains(to)) { break; } var outs = ups.Where(u => currentModule.InPorts.Contains(u.Key)).Select(x => x.Value).ToList(); outs.Count.Should().Be(1); currentModule = owner[outs[0]]; } }
private static void Verify <TShape, TMat>(Fusing.FusedGraph <TShape, TMat> fused, int modules, int downstreams) where TShape : Shape { var module = fused.Module as FusedModule; module.SubModules.Length.Should().Be(modules); module.Downstreams.Count.Should().Be(modules - 1); module.Info.Downstreams.Count.Should().BeGreaterOrEqualTo(downstreams); module.Info.Upstreams.Count.Should().BeGreaterOrEqualTo(downstreams); SinglePath(fused, new Attributes.Name("mainSink"), new Attributes.Name("unfold")); SinglePath(fused, new Attributes.Name("otherSink"), new Attributes.Name("unfold")); }