Java 类名:com.alibaba.alink.operator.batch.graph.RiskAlikeBuildGraphBatchOp
Python 类名:RiskAlikeBuildGraphBatchOp
Risk Alike构图
名称 | 中文名称 | 描述 | 类型 | 是否必须? | 取值范围 | 默认值 |
---|---|---|---|---|---|---|
edgeSourceCol | 边表中起点所在列 | 边表中起点所在列 | String | ✓ | ||
edgeTargetCol | 边表中终点所在列 | 边表中终点所在列 | String | ✓ | ||
vertexCol | 输入点表中点所在列 | 输入点表中点所在列 | String | ✓ | ||
edgeWeightCol | 边权重列 | 表示边权重的列 | String | null | ||
expandDegree | 扩散度数 | 从黑种子节点出发,在输入的边表上进行扩散的度数 | Integer | 2 |
import com.alibaba.alink.operator.batch.BatchOperator; import com.alibaba.alink.operator.batch.source.MemSourceBatchOp; import com.alibaba.alink.testutil.AlinkTestBase; import org.apache.flink.types.Row; import org.junit.Test; public class RiskAlikeBuildGraphBatchOpTest extends AlinkTestBase { @Test public void test() throws Exception { Row[] edges = new Row[] { Row.of(1L, 2L, 1D), Row.of(1L, 3L, 1D), Row.of(1L, 4L, 1D), Row.of(2L, 3L, 1D), Row.of(2L, 4L, 1D), Row.of(3L, 4L, 1D), Row.of(4L, 5L, 1D), Row.of(5L, 6L, 1D), Row.of(5L, 7L, 1D), Row.of(5L, 8L, 1D), Row.of(6L, 7L, 1D), Row.of(6L, 8L, 1D), Row.of(7L, 8L, 1D) }; BatchOperator edgeData = new MemSourceBatchOp(edges, new String[] {"source", "target", "weight"}); Row[] vertex = new Row[]{Row.of(1L)}; BatchOperator vertexData = new MemSourceBatchOp(vertex, new String[] {"vertex"}); RiskAlikeBuildGraphBatchOp louvainBatchOp = new RiskAlikeBuildGraphBatchOp() .setEdgeSourceCol("source") .setEdgeTargetCol("target") .setEdgeWeightCol("weight") .setVertexCol("vertex") .setExpandDegree(1) .linkFrom(vertexData, edgeData); louvainBatchOp.lazyPrint(); louvainBatchOp.getSideOutput(0).print(); } }
user_id | is_black |
---|---|
1 | true |
5 | false |
6 | false |
2 | true |
3 | true |
4 | true |
7 | false |
8 | false |
user_id | user_id_b | prediction_score | left_tag | right_tag |
---|---|---|---|---|
5 | 6 | 1.0000 | false | false |
4 | 5 | 1.0000 | true | false |
2 | 3 | 1.0000 | true | true |
2 | 4 | 1.0000 | true | true |
3 | 4 | 1.0000 | true | true |
7 | 8 | 1.0000 | false | false |
1 | 2 | 1.0000 | true | true |
1 | 3 | 1.0000 | true | true |
1 | 4 | 1.0000 | true | true |
5 | 7 | 1.0000 | false | false |
5 | 8 | 1.0000 | false | false |
6 | 7 | 1.0000 | false | false |
6 | 8 | 1.0000 | false | false |