$darkmode
DENOPTIM
EdgeQuery.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 Vishwesh Venkatraman <vishwesh.venkatraman@ntnu.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.graph;
20
21import denoptim.graph.Edge.BondType;
22
27public class EdgeQuery
28{
33
38
43
48
52 private BondType bondType = null;
53
54
55//------------------------------------------------------------------------------
56
60 public EdgeQuery()
61 {
62 this.srcVertexQuery = null;
63 this.trgVertexQuery = null;
64 this.srcAPQuery = null;
65 this.trgAPQuery = null;
66 this.bondType = null;
67 }
68
69//------------------------------------------------------------------------------
70
82 {
83 this.srcVertexQuery = srcVertexQuery;
84 this.trgVertexQuery = trgVertexQuery;
85 this.srcAPQuery = srcAPQuery;
86 this.trgAPQuery = trgAPQuery;
87 this.bondType = bondType;
88 }
89
90//------------------------------------------------------------------------------
91
97 public boolean matches(Edge e)
98 {
99 if (e == null)
100 {
101 return false;
102 }
103
104 if (bondType != null && e.getBondType() != bondType)
105 {
106 return false;
107 }
108
109 if (srcVertexQuery != null
111 {
112 return false;
113 }
114
115 if (trgVertexQuery != null
117 {
118 return false;
119 }
120
121 if (srcAPQuery != null && !srcAPQuery.matches(e.getSrcAP()))
122 {
123 return false;
124 }
125
126 if (trgAPQuery != null && !trgAPQuery.matches(e.getTrgAP()))
127 {
128 return false;
129 }
130
131 return true;
132 }
133
134//------------------------------------------------------------------------------
135}
Query for searching AttachmentPoints.
boolean matches(AttachmentPoint ap)
Tests whether the given attachment point satisfies all non-null criteria in this query.
This class represents the edge between two vertices.
Definition: Edge.java:38
AttachmentPoint getTrgAP()
Definition: Edge.java:115
AttachmentPoint getSrcAP()
Definition: Edge.java:94
BondType getBondType()
Definition: Edge.java:166
A query for edges: a list of properties that target edges should possess in order to match this query...
Definition: EdgeQuery.java:28
VertexQuery trgVertexQuery
Query for trg vertex.
Definition: EdgeQuery.java:37
EdgeQuery()
Constructor from empty queries.
Definition: EdgeQuery.java:60
boolean matches(Edge e)
Tests whether the given edge satisfies this query.
Definition: EdgeQuery.java:97
AttachmentPointQuery srcAPQuery
Query for src AP.
Definition: EdgeQuery.java:42
VertexQuery srcVertexQuery
Query for src vertex.
Definition: EdgeQuery.java:32
EdgeQuery(VertexQuery srcVertexQuery, VertexQuery trgVertexQuery, AttachmentPointQuery srcAPQuery, AttachmentPointQuery trgAPQuery, BondType bondType)
Constructor from nested vertex and attachment point queries.
Definition: EdgeQuery.java:79
BondType bondType
The bond type associated with the connection between the fragments.
Definition: EdgeQuery.java:52
AttachmentPointQuery trgAPQuery
Query for trg AP.
Definition: EdgeQuery.java:47
Query for searching vertices.
boolean matches(Vertex v)
Tests whether the given vertex satisfies all non-null criteria in this query.
Possible chemical bond types an edge can represent.
Definition: Edge.java:305