21import static org.junit.jupiter.api.Assertions.assertEquals;
22import static org.junit.jupiter.api.Assertions.assertFalse;
24import java.util.ArrayList;
27import org.junit.jupiter.api.Test;
29import denoptim.graph.AttachmentPoint;
30import denoptim.graph.DGraph;
31import denoptim.graph.DGraphTest;
32import denoptim.graph.Template;
33import denoptim.graph.Vertex;
34import denoptim.utils.CrossoverType;
56 List<Template> pathA =
new ArrayList<Template>();
57 List<Template> pathB =
new ArrayList<Template>();
58 DGraph refToThisLayerGraphB = gB;
60 DGraph refToThisLayerGraphA = gA;
62 for (
int embeddingLevel=0; embeddingLevel<9; embeddingLevel++)
64 refToThisLayerVrtxA = (
Template) refToThisLayerGraphA
65 .getVertexList().stream()
69 pathA.add(refToThisLayerVrtxA);
72 refToThisLayerVrtxB = (
Template) refToThisLayerGraphB
73 .getVertexList().stream()
77 pathB.add(refToThisLayerVrtxB);
81 DGraph gEmeddedA = pathA.get(8).getInnerGraph();
82 DGraph gEmeddedB = pathB.get(8).getInnerGraph();
84 List<Vertex> lstA =
new ArrayList<Vertex>();
87 List<AttachmentPoint> lstNeedyAPsA =
88 new ArrayList<AttachmentPoint>();
89 lstNeedyAPsA.add(lstA.get(0).getAP(2));
90 List<Vertex> lstB =
new ArrayList<Vertex>();
93 List<AttachmentPoint> lstNeedyAPsB =
94 new ArrayList<AttachmentPoint>();
95 lstNeedyAPsB.add(lstB.get(0).getAP(2));
102 assertFalse(xos.
getA().get(0)==xosOnClone.
getA().get(0));
103 assertFalse(xos.
getB().get(0)==xosOnClone.
getB().get(0));
105 List<Template> pathSiteA = xos.
getA().get(0).getGraphOwner()
107 List<Template> pathClonedSiteA = xosOnClone.
getA().get(0)
108 .getGraphOwner().getEmbeddingPath();
109 assertEquals(pathSiteA.size(),pathClonedSiteA.size());
110 List<Template> pathSiteB = xos.
getB().get(0).getGraphOwner()
112 List<Template> pathClonedSiteB = xosOnClone.
getB().get(0)
113 .getGraphOwner().getEmbeddingPath();
114 assertEquals(pathSiteB.size(),pathClonedSiteB.size());
116 assertEquals(xosOnClone.
getA().get(0).getAP(2),
118 assertEquals(xosOnClone.
getB().get(0).getAP(2),
This class collects the data identifying the subgraphs that would be swapped by a crossover event.
XoverSite projectToClonedGraphs()
Creates a new instance of this class that contains the list of vertexes that correspond to those cont...
List< AttachmentPoint > getAPsNeedingMappingA()
Returns the collection of attachment points that need to be mapped in order to achieve a valid crosso...
List< AttachmentPoint > getAPsNeedingMappingB()
Returns the collection of attachment points that need to be mapped in order to achieve a valid crosso...
List< Vertex > getA()
Returns the collection of vertexes belonging to the first subgraph.
List< Vertex > getB()
Returns the collection of vertexes belonging to the second subgraph.
void testProjectToClonedGraphs()
Container for the list of vertices and the edges that connect them.
Vertex getVertexAtPosition(int pos)
Returns the vertex that is in the given position of the list of vertices belonging to this graph.
Unit test for DENOPTIMGraph.
static DGraph makeDeeplyEmbeddedGraph()
Returns a graph that contains a 10-layered recursive structure.
static FragmentSpace prepare()
Types of crossover defined.
BRANCH
Swaps the entire branch starting from a given vertex.