src/Budkit/Datastore/Model/Graph.php
public function addEdge(&$nodeA, &$nodeB, $name = NULL, $directed = TRUE, $data = array(), $weight = 0)
    {

        $edge = new Graph\Edge($nodeA, $name, $nodeB, $data, $directed, $weight); //Will need to decide whether to use nodeAId-nodeBId as edgeId
        $edgeId = $edge->getId();

        //Directed edges have their Id's referenced in arcSet
        if ($directed && !in_array($edgeId, $this->arcSet))
            $this->arcSet[] = $edgeId;

        //@TODO This is not the ideal way to set parrallel edges, Parralel edges connect the same pair of nodes
        //If edge already exists, increment the weight;
        if (isset($this->edgeSet[$edgeId])) {
            $this->edgeSet[$edgeId]->weight++;
            $edgeData = $this->edgeSet[$edgeId]->getData();
            $data = array_merge($edgeData, $data);
            //Makeing a directed array undirected
            if (!$directed && in_array($edgeId, $this->arcSet))
                $this->arcSet = array_diff($this->arcSet, array($edgeId));
            return true;
        }
        //array_merge edge data
        if (!isset($this->edgeSet[$edgeId]))
            $this->edgeSet[$edgeId] = &$edge;

        //If directed, use edgeIsArc to indicate;
        return true;
    }
public function addEdge(&$nodeA, &$nodeB, $name = NULL, $directed = TRUE, $data = array(), $weight = 0)
    {

        $edge = new Graph\Edge($nodeA, $name, $nodeB, $data, $directed, $weight); //Will need to decide whether to use nodeAId-nodeBId as edgeId
        $edgeId = $edge->getId();

        //Directed edges have their Id's referenced in arcSet
        if ($directed && !in_array($edgeId, $this->arcSet))
            $this->arcSet[] = $edgeId;

        //@TODO This is not the ideal way to set parrallel edges, Parralel edges connect the same pair of nodes
        //If edge already exists, increment the weight;
        if (isset($this->edgeSet[$edgeId])) {
            $this->edgeSet[$edgeId]->weight++;
            $edgeData = $this->edgeSet[$edgeId]->getData();
            $data = array_merge($edgeData, $data);
            //Makeing a directed array undirected
            if (!$directed && in_array($edgeId, $this->arcSet))
                $this->arcSet = array_diff($this->arcSet, array($edgeId));
            return true;
        }
        //array_merge edge data
        if (!isset($this->edgeSet[$edgeId]))
            $this->edgeSet[$edgeId] = &$edge;

        //If directed, use edgeIsArc to indicate;
        return true;
    }
public function addEdge ( & $ nodeA , & $ nodeB , $ name = NULL , $ directed = TRUE , $ data = array ( ) , $ weight = 0 ) { $ edge = new Graph \ Edge ( $ nodeA , $ name , $ nodeB , $ data , $ directed , $ weight ) ; //Will need to decide whether to use nodeAId-nodeBId as edgeId $ edgeId = $ edge -> getId ( ) ; //Directed edges have their Id's referenced in arcSet if ( $ directed && ! in_array ( $ edgeId , $ this -> arcSet ) ) $ this -> arcSet [ ] = $ edgeId ; //@TODO This is not the ideal way to set parrallel edges, Parralel edges connect the same pair of nodes //If edge already exists, increment the weight; if ( isset ( $ this -> edgeSet [ $ edgeId ] ) ) { $ this -> edgeSet [ $ edgeId ] -> weight ++ ; $ edgeData = $ this -> edgeSet [ $ edgeId ] -> getData ( ) ; $ data = array_merge ( $ edgeData , $ data ) ; //Makeing a directed array undirected if ( ! $ directed && in_array ( $ edgeId , $ this -> arcSet ) ) $ this -> arcSet = array_diff ( $ this -> arcSet , array ( $ edgeId ) ) ; return true ; } //array_merge edge data if ( ! isset ( $ this -> edgeSet [ $ edgeId ] ) ) $ this -> edgeSet [ $ edgeId ] = & $ edge ; //If directed, use edgeIsArc to indicate; return true ; }
Adds an edge between two node endpoints.

@param type $nodeA
@param type $nodeB
@param type $name
@param type $data
@param type $directed
@param type $weight
@return boolean
Adds an edge between two node endpoints .