Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions connect/src/main/protobuf/graphframes.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ message GraphFramesAPI {
NeighborhoodAwareCDLP neighborhood_aware_cdlp = 25;
AllPaths all_paths = 26;
HyperANF hyper_anf = 27;
SybilRank sybil_rank = 28;
}
}

Expand Down Expand Up @@ -202,6 +203,23 @@ message Pregel {
optional string required_edge_columns = 18;
}

message SybilRank {
// Exactly one of trusted_vertex_ids / trusted_vertices_col must be provided
repeated StringOrLongID trusted_vertex_ids = 1;
optional string trusted_vertices_col = 2;
// Numeric edge weight column; unset = unweighted (all weights 1.0)
optional string weight_col = 3;
// Total trust distributed over the trusted vertices; unset = number of vertices
optional double total_trust = 4;
double iteration_multiplier = 5;
bool is_directed = 6;
bool use_local_checkpoints = 7;
int32 checkpoint_interval = 8;
optional StorageLevel storage_level = 9;
// Explicit number of power iterations; overrides the iteration multiplier
optional int32 max_iter = 10;
}

message ShortestPaths {
repeated StringOrLongID landmarks = 1;
string algorithm = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,47 @@ object GraphFramesConnectUtils {
haBuilder.run()
}
}
case proto.GraphFramesAPI.MethodCase.SYBIL_RANK => {
val sybilRankProto = apiMessage.getSybilRank
val sybilRankBuilder = graphFrame.sybilRank
.setIterationMultiplier(sybilRankProto.getIterationMultiplier)
.setIsDirected(sybilRankProto.getIsDirected)
.setCheckpointInterval(sybilRankProto.getCheckpointInterval)
.setUseLocalCheckpoints(sybilRankProto.getUseLocalCheckpoints)

val hasTrustedIds = sybilRankProto.getTrustedVertexIdsList.size() > 0
val hasTrustedCol = sybilRankProto.hasTrustedVerticesCol
require(
hasTrustedIds != hasTrustedCol,
"SybilRank requires exactly one of trusted_vertex_ids and trusted_vertices_col.")

if (hasTrustedIds) {
sybilRankBuilder.setTrustedVertices(
sybilRankProto.getTrustedVertexIdsList.asScala.map(parseLongOrStringID).toSeq)
} else {
sybilRankBuilder.setTrustedVerticesCol(sybilRankProto.getTrustedVerticesCol)
}

if (sybilRankProto.hasWeightCol) {
sybilRankBuilder.setWeightCol(sybilRankProto.getWeightCol)
}

if (sybilRankProto.hasTotalTrust) {
sybilRankBuilder.setTotalTrust(sybilRankProto.getTotalTrust)
}

if (sybilRankProto.hasMaxIter) {
sybilRankBuilder.maxIter(sybilRankProto.getMaxIter)
}

if (sybilRankProto.hasStorageLevel) {
sybilRankBuilder
.setIntermediateStorageLevel(parseStorageLevel(sybilRankProto.getStorageLevel))
.run()
} else {
sybilRankBuilder.run()
}
}
case _ => throw new GraphFramesUnreachableException() // Unreachable
}
}
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/scala/org/graphframes/GraphFrame.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,16 @@ class GraphFrame private (
*/
def hyperANF: HyperANF = new HyperANF(this)

/**
* SybilRank algorithm for ranking the trustworthiness of accounts and detecting sybils (fake
* accounts) in social networks.
*
* See [[org.graphframes.lib.SybilRank]] for more details.
*
* @group stdlib
*/
def sybilRank: SybilRank = new SybilRank(this)

// ========= Graph Machine Learning ==========

/**
Expand Down
Loading
Loading