Skip to content

Commit

Permalink
More restrictive circle detection that only reports circles with memb…
Browse files Browse the repository at this point in the history
…ers>2

i.e. a single back and forth transaction is no longer reported as a
circle.
  • Loading branch information
danistrebel committed Nov 24, 2013
1 parent 5db3ae0 commit 9aa4cbc
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.signalcollect.fraudppuccino.repeatedanalysis._
import com.signalcollect._
import scala.collection.mutable.ArrayBuffer
import com.signalcollect.fraudppuccino.structuredetection._
import scala.collection.mutable.HashSet

/**
* Detects if the target vertex of this transaction already occurred in the flow of
Expand All @@ -13,7 +14,7 @@ class CircleDetection(vertex: RepeatedAnalysisVertex[_]) extends VertexAlgorithm

var foundCircle = false

val accountTrail = ArrayBuffer[Any]()
val accountTrail = HashSet[Any]()

def getState = foundCircle

Expand All @@ -25,9 +26,12 @@ class CircleDetection(vertex: RepeatedAnalysisVertex[_]) extends VertexAlgorithm
}

def deliverSignal(signal: Any, sourceId: Option[Any], graphEditor: GraphEditor[Any, Any]) = {
if(vertex.id.asInstanceOf[Int] /10000 == 1000) {
println(vertex.id + " " + signal)
}
signal match {
case signaledTrail: Iterable[Any] => {
if(accountTrail.exists(_==targetId)) {
case signaledTrail: List[Any] => {
if(!signaledTrail.isEmpty && signaledTrail.tail.contains(targetId)) {
foundCircle = true
}
accountTrail++=signaledTrail
Expand All @@ -39,7 +43,7 @@ class CircleDetection(vertex: RepeatedAnalysisVertex[_]) extends VertexAlgorithm
}

def executeSignalOperation(graphEditor: GraphEditor[Any, Any], outgoingEdges: Iterable[(Any, EdgeMarker)]) {
outgoingEdges.filter(edge => edge._2 == DownstreamTransactionPatternEdge).foreach(edge => graphEditor.sendSignal(sourceId+:accountTrail, edge._1, Some(vertex.id)))
outgoingEdges.filter(edge => edge._2 == DownstreamTransactionPatternEdge).foreach(edge => graphEditor.sendSignal(sourceId+:accountTrail.toList, edge._1, Some(vertex.id)))
scoreSignal = 0
}

Expand Down

0 comments on commit 9aa4cbc

Please sign in to comment.