Ejemplo n.º 1
0
 /// <summary>
 /// A helper method to create solution instantiation graphs with the correct equality comparers.
 /// </summary>
 /// <param name="edges"></param>
 /// <returns></returns>
 public static SolutionInstantiationGraph Create(
     params Tuple <ElementInstantiation, ModelEntity.Connector, ElementInstantiation>[] edges)
 {
     return(new SolutionInstantiationGraph(null, DirectedLabeledGraph.Create(
                                               EqualityComparer <ElementInstantiation> .Default,
                                               EqualityComparer <ModelEntity.Connector> .Default,
                                               edges)));
 }
        public void OnceFilter()
        {
            var graph = DirectedLabeledGraph.Create(
                Tuple.Create("1", "a", "2"),
                Tuple.Create("2", "a", "1")
                );

            var expected = LabeledTree.Node("1",
                                            LabeledTree.Edge("a", LabeledTree.Node <string, string>("2")));

            var filter = DirectedLabeledGraph.TraverseEdgeOnlyOnce(EqualityComparer <string> .Default);

            AssertEqual(expected, graph.ToTree(filter));
        }
        public void TransformSimpleGraphToTree()
        {
            var graph = DirectedLabeledGraph.Create(
                Tuple.Create(1, "a", 2),
                Tuple.Create(1, "b", 3),
                Tuple.Create(2, "c", 3)
                );

            var expected = LabeledTree.Node(1,
                                            LabeledTree.Edge("a", LabeledTree.Node(2,
                                                                                   LabeledTree.Edge("c", LabeledTree.Node <int, string>(3)))),
                                            LabeledTree.Edge("b", LabeledTree.Node <int, string>(3)));

            AssertEqual(expected, graph.ToTree());
        }