From 255df92a30157941627fb9ad42b392f1a2437135 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Tue, 28 Apr 2015 15:50:14 +0000 Subject: [PATCH] Code refactoring: coloring a relation graph (purpose: distinguish potentially impacted CIs and really impacted CIs, when analyzing a change ticket) SVN:trunk[3568] --- core/relationgraph.class.inc.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/core/relationgraph.class.inc.php b/core/relationgraph.class.inc.php index d1c90cb3e..292aa02cd 100644 --- a/core/relationgraph.class.inc.php +++ b/core/relationgraph.class.inc.php @@ -77,15 +77,15 @@ class RelationObjectNode extends GraphNode /** * Recursively mark the objects nodes as reached, unless we get stopped by a redundancy node */ - public function ReachDown() + public function ReachDown($sProperty, $value) { - if (!$this->GetProperty('is_reached', false)) + if (is_null($this->GetProperty($sProperty))) { - $this->SetProperty('is_reached', true); + $this->SetProperty($sProperty, $value); foreach ($this->GetOutgoingEdges() as $oOutgoingEdge) { // Recurse - $oOutgoingEdge->GetSinkNode()->ReachDown(); + $oOutgoingEdge->GetSinkNode()->ReachDown($sProperty, $value); } } } @@ -101,7 +101,6 @@ class RelationRedundancyNode extends GraphNode parent::__construct($oGraph, $sId); $this->SetProperty('min_up', $iMinUp); $this->SetProperty('threshold', $fThreshold); - $this->SetProperty('reach_count', 0); } /** @@ -125,16 +124,16 @@ class RelationRedundancyNode extends GraphNode /** * Recursively mark the objects nodes as reached, unless we get stopped by a redundancy node */ - public function ReachDown() + public function ReachDown($sProperty, $value) { - $this->SetProperty('reach_count', $this->GetProperty('reach_count', 0) + 1); - if ($this->GetProperty('reach_count') > $this->GetProperty('threshold')) + $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(); + $oOutgoingEdge->GetSinkNode()->ReachDown($sProperty, $value); } } } @@ -214,7 +213,7 @@ class RelationGraph extends SimpleGraph // Determine the reached nodes foreach ($this->aSourceNodes as $oSourceNode) { - $oSourceNode->ReachDown(); + $oSourceNode->ReachDown('is_reached', true); //echo "
After reaching from {$oSourceNode->GetId()}
\n".$this->DumpAsHtmlImage()."
\n"; } }