11package denoptim.graph;
13import static org.junit.jupiter.api.Assertions.assertEquals;
14import static org.junit.jupiter.api.Assertions.assertFalse;
15import static org.junit.jupiter.api.Assertions.assertTrue;
17import java.util.ArrayList;
19import java.util.logging.Logger;
21import org.junit.jupiter.api.BeforeEach;
22import org.junit.jupiter.api.Test;
24import denoptim.exception.DENOPTIMException;
25import denoptim.graph.Edge.BondType;
26import denoptim.graph.Vertex.BBType;
70 (
long)
v1Ap0.
getID(),
null,
null,
null,
null,
null);
103 null,
null,
null,
null,
null);
105 vertexQuery,
null,
null);
124 null, edgeQuery,
null);
128 assertTrue(edgeQuery.
matches(userEdge));
140 if (!ap.isAvailable())
144 if (ap.isAvailable())
148 if (usedAp !=
null && unusedAp !=
null)
155 null, emptyEdgeQuery,
null);
157 assertFalse(query.
matches(unusedAp));
158 assertTrue(query.
matches(usedAp));
170 if (!ap.isAvailable())
174 if (ap.isAvailable())
178 if (usedAp !=
null && unusedAp !=
null)
186 Long.valueOf(linkedAp.
getID()),
null,
191 null,
null, linkedAPQuery);
193 assertTrue(query.
matches(usedAp));
194 assertFalse(query.
matches(unusedAp));
195 assertFalse(query.
matches(linkedAp));
204 null, 0,
null,
null,
null);
207 vertexQuery,
null,
null);
208 Logger logger = Logger.getLogger(
"test");
210 List<AttachmentPoint> fromFind =
graph.
findAPs(query, logger);
211 List<AttachmentPoint> fromMatches =
new ArrayList<>();
220 assertEquals(2, fromFind.size());
221 assertEquals(2, fromMatches.size());
223 assertTrue(fromMatches.containsAll(fromFind));
224 assertTrue(fromFind.containsAll(fromMatches));
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....
AttachmentPoint getLinkedAP()
Gets the attachment point (AP) that is connected to this AP via the edge user.
APClass getAPClass()
Returns the Attachment Point class.
int getID()
Returns a unique integer that is used to sort list of attachment points.
Edge getEdgeUser()
Gets the edge that is using this AP, or null if no edge is using this AP.
Query for searching AttachmentPoints.
boolean matches(AttachmentPoint ap)
Tests whether the given attachment point satisfies all non-null criteria in this query.
Unit tests for AttachmentPointQuery#matches(AttachmentPoint).
void testMatchesAttachmentPointId()
void testMatchesAPClass()
void testFindAPsUsesMatches()
void testMatchesNestedVertexQuery()
void testEmptyEdgeQueryRequiresEdge()
void testMatchesNestedEdgeQuery()
void testMatchesAllNullCriteria()
void testMatchesAttachmentPointIndex()
Container for the list of vertices and the edges that connect them.
ArrayList< AttachmentPoint > getAttachmentPoints()
Returns the list of all attachment points contained in this graph.
Vertex getVertexAtPosition(int pos)
Returns the vertex that is in the given position of the list of vertices belonging to this graph.
List< List< AttachmentPoint > > findAPs(List< AttachmentPointQuery > apQueries, Logger logger)
Search the graph for AttachmentPoints that match the criteria defined in a list of queries.
Unit test for DENOPTIMGraph.
static DGraph makeTestGraphA2()
Build a graph meant to be used in unit tests.
This class represents the edge between two vertices.
A query for edges: a list of properties that target edges should possess in order to match this query...
boolean matches(Edge e)
Tests whether the given edge satisfies this query.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
Query for searching vertices.
Possible chemical bond types an edge can represent.
The type of building block.