예제 #1
0
  public void write(StructureWriter outs) throws IOException {
    outs.writeComment("num components");
    outs.writeInt(components.length);
    for (int i = 0; i < components.length; i++) {
      outs.writeComment("component " + i);
      outs.writeDouble(weights[i]);
      outs.writeString(components[i].getClass().getName());
      outs.blockBegin();
      components[i].write(outs);
      outs.blockEnd();
    }

    Attributes.write(attributes, outs);
  }
예제 #2
0
  public void read(StructureReader ins) throws IOException {
    int ncomponents = ins.readInt();
    components = new GEdge[ncomponents];
    weights = new double[ncomponents];

    for (int i = 0; i < components.length; i++) {
      weights[i] = ins.readDouble();
      String cls = ins.readString();
      components[i] = (GEdge) ReflectUtil.createObject(cls);
      ins.blockBegin();
      components[i].read(ins);
      ins.blockEnd();
    }

    attributes = Attributes.read(ins);

    nodes = LinAlg.copy(components[0].nodes);
  }