$darkmode
DENOPTIM
SymmetricVertexes.java
Go to the documentation of this file.
1package denoptim.graph;
2
3import java.lang.reflect.Type;
4import java.util.ArrayList;
5import java.util.List;
6
7import com.google.gson.JsonElement;
8import com.google.gson.JsonSerializationContext;
9import com.google.gson.JsonSerializer;
10
17public class SymmetricVertexes extends SymmetricSet<Vertex>
18{
19
23 private static final long serialVersionUID = 4L;
24
25//------------------------------------------------------------------------------
26
28 {
29 super();
30 }
31
32//------------------------------------------------------------------------------
33
34 public SymmetricVertexes(List<Vertex> selVrtxs)
35 {
36 super();
37 this.addAll(selVrtxs);
38 }
39
40//------------------------------------------------------------------------------
41
42 public String toString()
43 {
44 StringBuilder sb = new StringBuilder();
45 sb.append("SymmetricVertexes [");
46 for (int i=0; i<this.size(); i++)
47 {
48 sb.append(this.get(i).getVertexId());
49 if (i<(this.size()-1))
50 sb.append(", ");
51 }
52 sb.append("]");
53 return sb.toString();
54 }
55
56//------------------------------------------------------------------------------
57
58 public static class SymmetricVertexesSerializer
59 implements JsonSerializer<SymmetricVertexes>
60 {
61 @Override
62 public JsonElement serialize(SymmetricVertexes list, Type typeOfSrc,
63 JsonSerializationContext context)
64 {
65 List<Long> vertexIDs = new ArrayList<Long>();
66 for (Vertex v : list)
67 {
68 vertexIDs.add(v.getVertexId());
69 }
70 return context.serialize(vertexIDs);
71 }
72 }
73
74 //NB: deserialization is done in the Graph deserializer
75
76//------------------------------------------------------------------------------
77
78}
Class representing a list of references pointing to instances that are related by some conventional c...
JsonElement serialize(SymmetricVertexes list, Type typeOfSrc, JsonSerializationContext context)
A collection of Vertexs that are related by a relation that we call "symmetry", even though this clas...
SymmetricVertexes(List< Vertex > selVrtxs)
static final long serialVersionUID
Version ID.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
Definition: Vertex.java:61