예제 #1
0
 private static DirectedLabeledGraph <ElementInstantiation, ModelEntity.Connector> Merge(
     DirectedLabeledGraph <ModelEntity.Element, ModelEntity.Connector> problemSpace,
     DirectedLabeledGraph <ModelEntity.Element, ModelEntity.Connector> solution)
 {
     return(problemSpace.MapNodeLabels <ElementInstantiation>(problemItem =>
     {
         var instance = solution.NodeLabels.FirstOption(solutionItem => solutionItem.EaObject.ClassifierID == problemItem.Id);
         return new ElementInstantiation(problemItem, instance);
     }));
 }
예제 #2
0
        public void MapNodesInSimpleGraph()
        {
            var graph = new DirectedLabeledGraph <int, char>(1)
                        .Connect(1, 'a', 2)
                        .Connect(2, 'b', 3);

            var calls = 0;

            var mappedGraph = graph.MapNodeLabels((int n) => {
                calls++;
                return(n.ToString());
            });

            Assert.AreEqual(3, calls);
            Assert.IsTrue(mappedGraph.Edges.Any(e => e.Item1 == "1" && e.Item2 == 'a' && e.Item3 == "2"));
            Assert.IsTrue(mappedGraph.Edges.Any(e => e.Item1 == "2" && e.Item2 == 'b' && e.Item3 == "3"));
        }