public void update(ChiVertex<Integer, Integer> vertex, GraphChiContext context) {
        if (context.getIteration() == 0) {
            /* Check vertex value was loaded properly */
            int originalId = context.getVertexIdTranslate().backward(vertex.getId());
            if (loadedVertexValues.containsKey(originalId)) {
                if (!vertex.getValue().equals(loadedVertexValues.get(originalId))) {
                    throw new RuntimeException("Vertex value for vertex " + originalId + " not loaded properly:" +
                            vertex.getValue() + " !=" + loadedVertexValues.get(originalId));
                } else {
                    logger.info("Loaded vertex value correctly: " + originalId + " = " + loadedVertexValues.get(originalId));
                }
            }

            vertex.setValue(vertex.getId() + context.getIteration());
        } else {
            int curval = vertex.getValue();
            int vexpected = vertex.getId() + context.getIteration() - 1;
            if (curval != vexpected) {
                throw new RuntimeException("Mismatch (vertex). Expected: " + vexpected + " but had " +
                        curval);

            }
            for(int i=0; i<vertex.numInEdges(); i++) {
                int has = vertex.inEdge(i).getValue();
                int correction = vertex.getId() > vertex.inEdge(i).getVertexId() ? +1 : 0;
                int expected = vertex.inEdge(i).getVertexId() + context.getIteration() - 1 + correction;
                if (expected != has)
                    throw new RuntimeException("Mismatch (edge): " + expected + " expected but had "+ has +
                            ". Iteration:" + context.getIteration() + ", edge:" + vertex.inEdge(i).getVertexId()
                            + " -> " + vertex.getId());
            }
            vertex.setValue(vertex.getId() + context.getIteration());

        }
        int val = vertex.getValue();
        for(int i=0; i<vertex.numOutEdges(); i++) {
            vertex.outEdge(i).setValue(val);
        }


    }