public TreatyGraphExecuter(TreatyGraph _graph) { graph = _graph; }
public Graph Build() { //Make all graph nodes for Graph List <GraphNode> IntitialGraphNodes = new List <GraphNode>(); ContractExtractor contract; if (expData.TreatyExposure) { contract = new TreatyContractExtractor(expData, graphChache); } else { contract = new PrimaryContractExtractor(expData); } //Get All Cover Nodes contract.Extract(); List <Subject> graphSubs = contract.GetAllCoverSubjects(); IntitialGraphNodes.AddRange(GetCoverNodes(contract, graphSubs)); //Get All Term Nodes if (!expData.TreatyExposure) { PrimaryContractExtractor primaryContract = (PrimaryContractExtractor)contract; List <PrimarySubject> termgraphSubs = primaryContract.GetAllTermSubjects(); IntitialGraphNodes.AddRange(GetTermNodes(primaryContract, termgraphSubs)); } //Build Hasse Diagram from Graph Nodes HasseDiagramGenerator HasseBuilder = new HasseDiagramGenerator(); HasseDiagram HasseDiagram = HasseBuilder.Generate(IntitialGraphNodes); //Convert Hasse Diagram to Reference.Graph object List <GraphNode> TopGraphNodes = new List <GraphNode>(); List <GraphNode> FinalGraphNodes = HasseDiagram.HasseDiagramNodes.Where(pair => pair.Key != "{}") .Select(pair => pair.Value) .Cast <GraphNode>() .ToList(); Dictionary <GraphNode, List <GraphNode> > ParentToChildrenMap = new Dictionary <GraphNode, List <GraphNode> >(); foreach (GraphNode graphnode in FinalGraphNodes) { List <GraphNode> childrenList = graphnode.EdgesToCovered.Select(edge => edge.LowerNode) .Where(node => node.KeyString != "") .Cast <GraphNode>().ToList(); if (childrenList.Count > 0) { ParentToChildrenMap.Add(graphnode, childrenList); } if (graphnode.EdgesToCovering.Count == 0) { TopGraphNodes.Add(graphnode); } } Graph graph; if (expData.TreatyExposure) { graph = new TreatyGraph(expData.ContractID, TopGraphNodes, FinalGraphNodes, ParentToChildrenMap, contract.Declarations); } else { graph = new PrimaryGraph(expData.ContractID, TopGraphNodes, FinalGraphNodes, ParentToChildrenMap, contract.Declarations); } //graph.BuildAtomicRITEs(); //graph.AssignLevelToNode(); //graph.GraphReady = true; return(graph); }