Skip to content

Commit

Permalink
Remove self dependencies from graph
Browse files Browse the repository at this point in the history
  • Loading branch information
DeGraciaMathieu committed Nov 19, 2024
1 parent b317a91 commit 97856cf
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Presenter\Analyze\Shared\Network\Network;
use App\Presenter\Analyze\Shared\Network\NetworkBuilder;
use App\Infrastructure\Graph\Adapters\Cytoscape\CytoscapeNetwork;
use App\Presenter\Analyze\Shared\Network\NetworkAttribute;

class CytoscapeNetworkBuilder implements NetworkBuilder
{
Expand Down Expand Up @@ -33,6 +34,10 @@ private function mapEdges(array $metrics): void

foreach ($item->dependencies() as $dependency) {

if ($this->isSelfDependency($dependency, $item)) {
continue;
}

if ($this->network->missingNode($dependency)) {
$this->network->addNode($dependency);
}
Expand All @@ -41,4 +46,12 @@ private function mapEdges(array $metrics): void
}
}
}

/**
* We remove self dependency from graph for readability reasons
*/
private function isSelfDependency(string $dependency, NetworkAttribute $item): bool
{
return $dependency === $item->name();
}
}

0 comments on commit 97856cf

Please sign in to comment.