4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.kgraph.library.cf;
17 |
18 | /**
19 | * Classes that implement this interface represent the ID of a node in a
20 | * user-item graph. Nodes in this case typically represent either users or items
21 | * and are identified by a number or a string (e.g. an item description). To
22 | * avoid conflicts between user and item ids, this interface defines the type
23 | * of the node as well, not just the identifier. The type is a byte value and
24 | * can by set and interpreted in an application-specific manner.
25 | *
26 | * @author dl
27 | *
28 | * @param
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.kgraph.library.maxbmatching;
17 |
18 | import java.util.Objects;
19 |
20 | import io.kgraph.library.maxbmatching.MBMEdgeValue.State;
21 |
22 | public class MBMMessage {
23 | private final Long vertexID;
24 | private final State state;
25 |
26 | public MBMMessage() {
27 | this.vertexID = 0L;
28 | this.state = State.DEFAULT;
29 | }
30 |
31 | public MBMMessage(Long id, State proposed) {
32 | this.vertexID = id;
33 | this.state = proposed;
34 | }
35 |
36 | public Long getId() {
37 | return vertexID;
38 | }
39 |
40 | public State getState() {
41 | return state;
42 | }
43 |
44 | @Override
45 | public String toString() {
46 | return "(" + vertexID + ", " + state + ")";
47 | }
48 |
49 | @Override
50 | public boolean equals(Object o) {
51 | if (this == o) return true;
52 | if (o == null || getClass() != o.getClass()) return false;
53 | MBMMessage that = (MBMMessage) o;
54 | return Objects.equals(vertexID, that.vertexID) &&
55 | state == that.state;
56 | }
57 |
58 | @Override
59 | public int hashCode() {
60 | return Objects.hash(vertexID, state);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/kafka-graphs-core/src/main/java/io/kgraph/streaming/EdgeFoldFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package io.kgraph.streaming;
20 |
21 | /**
22 | * Interface to be implemented by the function applied to a vertex neighborhood
23 | * in the {@link KGraphWindowedStream#foldNeighbors(Object, EdgeFoldFunction)} method.
24 | *
25 | * @param
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.kgraph.library.clustering;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import io.kgraph.pregel.aggregators.Aggregator;
22 |
23 | public class DoubleListAggregator implements Aggregator
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package io.kgraph.library.clustering;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 | import java.util.Objects;
21 |
22 | /**
23 | * The type of the vertex value in K-means
24 | * It stores the coordinates of the point
25 | * and the currently assigned cluster id
26 | *
27 | */
28 | public class KMeansVertexValue {
29 | private final List> {
24 |
25 | private List