vasia / gelly-streaming

An experimental Graph Streaming API for Apache Flink
Apache License 2.0
138 stars 44 forks source link

Why run IterativeConnectedComponents is similar to the death cycle #35

Closed lilicao701 closed 7 years ago

lilicao701 commented 7 years ago

Hi, I try to run IterativeConnectedComponents with socketStream, when input of: 1,3 1,4,,1,5 the result is OK, when input "5,6", the result print so many "6,1": (1,1) (3,1) (4,1) (4,1) (4,1) (4,1) (4,1) (4,1) (4,1) (4,1) (4,1) (4,1) (4,4) (5,4) (4,1) (5,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1) (6,1)

Process finished with exit code -1 could you tell me how to run this algorithm? thank you very much.

vasia commented 7 years ago

Hi @lilicao701, this algorithm is simply a proof of concept and not the recommended way to run connected components. We are working on adding proper iterations in gelly-stream soon. Until then, I would suggest you use the single-pass connected components algorithm.

lilicao701 commented 7 years ago

Hi, I fixed this bug, about the function of "addToExistingComponent" , the vertices.add(toAdd); is not right. The right code is like this:

private void addToExistingComponent(long componentId, long toAdd, Collector<Tuple2<Long, Long>> out) {
        HashSet<Long> vertices = components.remove(componentId);
        vertices.add(toAdd);
        //System.out.println("************addToExistingComponent componentId=" + componentId + ",toAdd = " + toAdd);
        if (componentId >= toAdd) {
            // output and update component ID
            for (long v: vertices) {
                out.collect(new Tuple2<Long, Long>(v, toAdd));
            }

            components.put(toAdd, vertices);
        }
        else {
            components.put(componentId, vertices);
            out.collect(new Tuple2<Long, Long>(toAdd, componentId));

        }
    }