19package denoptim.graph;
21import java.lang.reflect.Type;
22import java.util.ArrayList;
23import java.util.Collections;
26import com.google.gson.JsonElement;
27import com.google.gson.JsonObject;
28import com.google.gson.JsonSerializationContext;
29import com.google.gson.JsonSerializer;
31import denoptim.exception.DENOPTIMException;
32import denoptim.graph.Edge.BondType;
160 this.bndTyp = bndType;
189 boolean result =
false;
192 if (v.getVertexId() == vid)
209 return "DENOPTIMRing [vertices=" +
vertices +
"]";
215 return Collections.unmodifiableList(
vertices);
221 implements JsonSerializer<Ring>
225 JsonSerializationContext context)
227 JsonObject jsonObject =
new JsonObject();
228 ArrayList<Long> vertexIDs =
new ArrayList<Long>();
229 for (
int i=0; i<ring.
getSize(); i++)
234 jsonObject.add(
"vertices",context.serialize(vertexIDs));
235 jsonObject.add(
"bndTyp",context.serialize(ring.
getBondType()));
244 int idx =
vertices.indexOf(oldVrtx);
257 int idx =
vertices.indexOf(oldVrtx);
329 +
"because " + v1 +
" does not belong ring " +
this);
332 +
"because " + v2 +
" does not belong ring " +
this);
337 return Math.max(pV1,pV2) - Math.min(pV1, pV2);
381 int dA = -1, dB = -1;
JsonElement serialize(Ring ring, Type typeOfSrc, JsonSerializationContext context)
This class represents the closure of a ring in a spanning tree.
void replaceVertex(Vertex oldVrtx, Vertex newVrtx)
Replaces a vertex that belong to this ring with a new one.
int getPositionOf(Vertex v)
Vertex getCloserToHead(Vertex vA, Vertex vB)
Chooses among the two given vertices the one that is closer to the head vertex.
void addVertex(Vertex v)
Append a DENOPTIMVertex to the list.
boolean containsID(int vid)
Checks whether a given vertex is part of this ring.
Vertex getVertexAtPosition(int i)
void removeVertex(Vertex oldVrtx)
void setBondType(BondType bndType)
Set the bond type (i.e., bond order) of the chord connecting the head and the tail vertices.
boolean contains(Vertex v)
Checks whether a given vertex is part of this ring.
int getDistance(Vertex v1, Vertex v2)
Measures how many edges there are between two edges along the sequence of vertices that defined this ...
List< Vertex > vertices
List of DENOPTIMVertex involved in the ring.
List< Vertex > getVertices()
int indexOf(Vertex v)
Returns the index of the first occurrence of the specified element in this ring, or -1 if this list d...
Ring(List< Vertex > vertices)
boolean insertVertex(int position, Vertex newLink)
Adds a vertex to the ring, in the given position.
BondType bndTyp
Bond type (i.e., bond order) to be used between head and tail vertices.
Vertex getCloserTo(Vertex vA, Vertex vB, Vertex vT)
Chooses among the two given vertices the one that is closer to the target vertex.
boolean insertVertex(Vertex newLink, Vertex vA, Vertex vB)
Adds a vertex to the ring, and in between two defined vertices.
Vertex getCloserToTail(Vertex vA, Vertex vB)
Chooses among the two given vertices the one that is closer to the tail vertex.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
Possible chemical bond types an edge can represent.