-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merging legacy Develop into legacy Master to create release 0.4.1
Merging legacy Develop into legacy Master to create release 0.4.1
- Loading branch information
Showing
38 changed files
with
976 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash | ||
exec < /dev/tty && git cz --hook || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
src/main/scala/com/raphtory/algorithms/NeighbourAverageDegree.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.raphtory.algorithms.generic | ||
|
||
import com.raphtory.core.model.algorithm._ | ||
|
||
/** | ||
Description | ||
Returns outliers detected based on the community structure of the Graph. | ||
The algorithm assumes that the state of each vertex contains a community label (e.g., set by running LPA on the graph, initially) | ||
and then defines an outlier score based on a node's | ||
community membership and how it compares to its neighbors community memberships. | ||
Parameters | ||
label (String) - Identifier for community label | ||
cutoff (Double) - Outlier score threshold (default: 0.0). Identifies the outliers with an outlier score > cutoff. | ||
labeler (GraphAlgorithm) - Community algorithm to run to get labels (does nothing by default, i.e., labels should | ||
be already set on the input graph, either via chaining or defined as properties of the data) | ||
**/ | ||
class CBOD(label: String = "label", cutoff: Double = 0.0, output: String = "/tmp/CBOD", labeler:GraphAlgorithm = Identity()) | ||
extends GraphAlgorithm { | ||
/** | ||
Run CBOD algorithm and sets "outlierscore" state | ||
**/ | ||
override def apply(graph: GraphPerspective): GraphPerspective = { | ||
labeler.apply(graph) | ||
.step { vertex => //Get neighbors' labels | ||
val vlabel = vertex.getState[Long](key = label, includeProperties = true) | ||
vertex.messageAllNeighbours(vlabel) | ||
} | ||
.step { v => // Get outlier score | ||
val vlabel = v.getState[Long](key = label, includeProperties = true) | ||
val neighborLabels = v.messageQueue[Long] | ||
val outlierScore = 1 - (neighborLabels.count(_ == vlabel) / neighborLabels.length.toDouble) | ||
v.setState("outlierscore", outlierScore) | ||
} | ||
} | ||
|
||
/** | ||
* extract vertex ID and outlier score for vertices with outlierscore >= threshold | ||
**/ | ||
override def tabularise(graph: GraphPerspective): Table = { | ||
graph.select { vertex => | ||
Row( | ||
vertex.name(), | ||
vertex.getStateOrElse[Double]("outlierscore", 10.0) | ||
) | ||
} | ||
.filter(_.get(1).asInstanceOf[Double] >= cutoff) | ||
} | ||
|
||
override def write(table: Table): Unit = { | ||
table.writeTo(output) | ||
} | ||
} | ||
|
||
object CBOD { | ||
def apply( | ||
label: String = "label", | ||
cutoff: Double = 0.0, | ||
output: String = "/tmp/CBOD", | ||
labeler: GraphAlgorithm = Identity() | ||
) = | ||
new CBOD(label, cutoff, output, labeler) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.