diff --git a/sources/Core/RelationGraph/RelationEdge.php b/sources/Core/RelationGraph/RelationEdge.php new file mode 100644 index 0000000000..f89da3c731 --- /dev/null +++ b/sources/Core/RelationGraph/RelationEdge.php @@ -0,0 +1,23 @@ +GetId().'-to-'.$oSinkNode->GetId(); + parent::__construct($oGraph, $sId, $oSourceNode, $oSinkNode, $bMustBeUnique); + } +} \ No newline at end of file diff --git a/sources/Core/RelationGraph/RelationObjectNode.php b/sources/Core/RelationGraph/RelationObjectNode.php new file mode 100644 index 0000000000..5aa479788a --- /dev/null +++ b/sources/Core/RelationGraph/RelationObjectNode.php @@ -0,0 +1,70 @@ +SetProperty('object', $oObject); + $this->SetProperty('label', get_class($oObject).'::'.$oObject->GetKey().' ('.$oObject->Get('friendlyname').')'); + } + + /** + * Make a normalized ID to ensure the uniqueness of such a node + * + * @param string $oObject + * + * @return string + */ + public static function MakeId($oObject) + { + return get_class($oObject).'::'.$oObject->GetKey(); + } + + /** + * Formatting for GraphViz + * + * @param bool $bNoLabel + * + * @return string + */ + public function GetDotAttributes($bNoLabel = false) + { + $sDot = parent::GetDotAttributes(); + if ($this->GetProperty('developped', false)) { + $sDot .= ',fontcolor=black'; + } else { + $sDot .= ',fontcolor=lightgrey'; + } + if ($this->GetProperty('source', false) || $this->GetProperty('sink', false)) { + $sDot .= ',shape=rectangle'; + } + if ($this->GetProperty('is_reached', false)) { + $sDot .= ',fillcolor="#ffdddd"'; + } else { + $sDot .= ',fillcolor=white'; + } + + return $sDot; + } + + /** + * Recursively mark the objects nodes as reached, unless we get stopped by a redundancy node or a 'not allowed' node + * + * @param string $sProperty + * @param $value + */ + public function ReachDown($sProperty, $value) + { + if (is_null($this->GetProperty($sProperty)) && ($this->GetProperty($sProperty.'_allowed') !== false)) { + $this->SetProperty($sProperty, $value); + foreach ($this->GetOutgoingEdges() as $oOutgoingEdge) { + // Recurse + $oOutgoingEdge->GetSinkNode()->ReachDown($sProperty, $value); + } + } + } +} \ No newline at end of file diff --git a/sources/Core/RelationGraph/RelationRedundancyNode.php b/sources/Core/RelationGraph/RelationRedundancyNode.php new file mode 100644 index 0000000000..d5aa2ed710 --- /dev/null +++ b/sources/Core/RelationGraph/RelationRedundancyNode.php @@ -0,0 +1,62 @@ +SetProperty('min_up', $iMinUp); + $this->SetProperty('threshold', $fThreshold); + } + + /** + * Make a normalized ID to ensure the uniqueness of such a node + * + * @param string $sRelCode + * @param string $sNeighbourId + * @param $oSourceObject + * @param \DBObject $oSinkObject + * + * @return string + */ + public static function MakeId($sRelCode, $sNeighbourId, $oSourceObject, $oSinkObject) + { + return 'redundancy-'.$sRelCode.'-'.$sNeighbourId.'-'.get_class($oSinkObject).'::'.$oSinkObject->GetKey(); + } + + /** + * Formatting for GraphViz + * + * @param bool $bNoLabel + * + * @return string + */ + public function GetDotAttributes($bNoLabel = false) + { + $sDisplayThreshold = sprintf('%.1f', $this->GetProperty('threshold')); + $sDot = 'shape=doublecircle,fillcolor=indianred,fontcolor=papayawhip,label="'.$sDisplayThreshold.'"'; + + return $sDot; + } + + /** + * Recursively mark the objects nodes as reached, unless we get stopped by a redundancy node + * + * @param string $sProperty + * @param $value + */ + public function ReachDown($sProperty, $value) + { + $this->SetProperty($sProperty.'_count', $this->GetProperty($sProperty.'_count', 0) + 1); + if ($this->GetProperty($sProperty.'_count') > $this->GetProperty('threshold')) { + // Looping... though there should be only ONE SINGLE outgoing edge + foreach ($this->GetOutgoingEdges() as $oOutgoingEdge) { + // Recurse + $oOutgoingEdge->GetSinkNode()->ReachDown($sProperty, $value); + } + } + } +} \ No newline at end of file