public function __construct(SimpleGraph $oGraph, GraphNode $oSourceNode, GraphNode $oSinkNode) { $sId = $oSourceNode->GetId() . '-to-' . $oSinkNode->GetId(); parent::__construct($oGraph, $sId, $oSourceNode, $oSinkNode); }
/** * Removes the given node but preserves the connectivity of the graph * all "source" nodes are connected to all "sink" nodes * @param GraphNode $oNode * @throws SimpleGraphException */ public function FilterNode(GraphNode $oNode) { if (!array_key_exists($oNode->GetId(), $this->aNodes)) { throw new SimpleGraphException('Cannot filter the node (id=' . $oNode->GetId() . ') from the graph. The node was not found in the graph.'); } $aSourceNodes = array(); $aSinkNodes = array(); foreach ($oNode->GetOutgoingEdges() as $oEdge) { $sSinkId = $oEdge->GetSinkNode()->GetId(); $aSinkNodes[$sSinkId] = $oEdge->GetSinkNode(); $this->_RemoveEdge($oEdge); } foreach ($oNode->GetIncomingEdges() as $oEdge) { $sSourceId = $oEdge->GetSourceNode()->GetId(); $aSourceNodes[$sSourceId] = $oEdge->GetSourceNode(); $this->_RemoveEdge($oEdge); } unset($this->aNodes[$oNode->GetId()]); foreach ($aSourceNodes as $sSourceId => $oSourceNode) { foreach ($aSinkNodes as $sSinkId => $oSinkNode) { $oEdge = new RelationEdge($this, $oSourceNode, $oSinkNode); } } }