예제 #1
0
 public static VertexModel getVertex(
     Object i, GraphModel g, HashMap<Object, VertexModel> vertices) {
   if (vertices.containsKey(i)) {
     return vertices.get(i);
   } else {
     VertexModel v = new VertexModel();
     v.setLabel(i + "");
     TripNet.setVertexId(v, i);
     vertices.put(i, v);
     g.insertVertex(v);
     return v;
   }
 }
예제 #2
0
 public static GraphModel getACopy(GraphModel g) {
   GraphModel ret = new GraphModel(g.isDirected());
   VertexModel[] map = new VertexModel[g.getVerticesCount()];
   for (VertexModel v : g) {
     VertexModel t = new VertexModel(v);
     map[v.getId()] = t;
     ret.insertVertex(t);
   }
   for (EdgeModel e : g.edges()) {
     EdgeModel t = new EdgeModel(e, map[e.source.getId()], map[e.target.getId()]);
     ret.insertEdge(t);
     setDup(e, t);
   }
   return ret;
 }